文号
t13627
阅读
7692
回复
3
收藏
2
C++:Read Bitmap File
2009/03/23
IP:广东
#include <iostream>
#include <fstream>

using namespace std;

int R[1000];
int G[1000];
int B[1000];

int main()
{
    ifstream OpenFile("e:\\1.bmp");
    int ch;
    int i=0;
    int j;
    int g,b;
    bool if32bit;
    for(j=0;j<28;j++)
    {
        printf("%d ",OpenFile.get());                
    }
    
    ch=OpenFile.get();
    
    if(ch==24)
    {
        printf("this is a 24bit bitmap\n");
        if32bit=false;
    }
    else
    {
        printf("this is a 32bit bitmap\n");
        if32bit=true;
    }
    
    for(j=0;j<25;j++)
    {
        OpenFile.get();                
    }
    
    //for(j=0;j<50;j++)
    while(ch!=EOF)
    {
       ch=OpenFile.get();
       i++;
       g=OpenFile.get();
       b=OpenFile.get();
       if(if32bit)
       {
           OpenFile.get();
       }
       printf("%d,%d,%d ",ch,g,b);
    }
    OpenFile.close();
system("pause");
}
93°作者
17年10个月前IP:未同步
84277
1楼
不给俺加分?
+16
科创币
小光telnet
2009/03/23
引用
评论
17年10个月前IP:未同步
84285
2楼
读取文件头啊……
引用
评论
93°作者
17年10个月前IP:未同步
84287
3楼
文件头?
引用
评论
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的