(VC++)API编程读bmp图片

时间:2012-11-03 12:58:29
【文件属性】:
文件名称:(VC++)API编程读bmp图片
文件大小:1001KB
文件格式:RAR
更新时间:2012-11-03 12:58:29
VC API BMP 读取bmp图片的源程序,API编程,含需要的头文件 #include "windows.h" #include "StdAfx.h" #include #include //定义一些变量 unsigned char *pBmpBuf; //读入图像数据的指针 int bmpWidth; //图像的宽 int bmpHeight; //图像的高 RGBQUAD *pColorTable; //颜色表指针 unsigned int biBitCount; //图像类型,每像素位数 bool readBmp(char *bmpName) { //二进制读方式打开指定的图像文件 FILE *fp = fopen(bmpName, "rb"); if(fp == 0) return 0; //跳过位图文件头结构BITMAPFILEHEADER fseek(fp,sizeof(BITMAPFILEHEADER),0); //fseek(fp,14,0); //定义位图信息头结构变量,读取位图信息头进内存,存放在变量head中 BITMAPINFOHEADER head; fread(&head, sizeof(BITMAPINFOHEADER),1,fp); //获取图像宽,高,每像素所占位数等信息 bmpWidth = head.biWidth; bmpHeight = head.biHeight; biBitCount = head.biBitCount; //定义变量,计算图像每行所占的字节数(必须是4的倍数)
【文件预览】:
API编程读bmp
----StdAfx.cpp(294B)
----test.cpp(565B)
----readbmp.dsw(539B)
----readbmp.plg(900B)
----readbmp.opt(48KB)
----readbmp.dsp(3KB)
----readbmp.ncb(33KB)
----Debug()
--------vc60.pdb(76KB)
--------vc60.idb(137KB)
--------readbmp.pdb(25KB)
--------readbmp.pch(3.4MB)
--------readbmp.obj(13KB)
----StdAfx.h(667B)
----readbmp.cpp(3KB)

网友评论

  • 可用,非常好
  • 这个确实不错
  • 相当不错,对我有帮助
  • 还不错,但好像有点错误
  • 对我有帮助,学习了。
  • 代码清晰,注释明朗,值得初学者参考。
  • 不能运行,怎么回事呢
  • 已编译就出错,不能运行
  • 正需要呢,感谢分享。另外有个问题,这个读取BMP的代码是否可以直接用于MFC的按钮点击事件?
  • 不能运行。有一个错误!悲剧