//读取位图信息
BYTE * FuncReadBmp(const char *strSourceFileName,int &width,int &height)
{
BITMAPFILEHEADER bfh;// bmp文件头
BITMAPINFOHEADER bih;// bmp头信息直接以二进制文件打开bmp,然后读取 位图头部头。。。
// BITMAPFILEHEADER bfh;// bmp文件头
// BITMAPINFOHEA/DER bih;// bmp头信息
RGBQUAD rq[256];// 调色板
int i=0,j=0;
int nAdjust; // 用于字节对齐
int nAdjust24; // 用于字节对齐
int nSize;
BYTE *data= NULL;
//new BYTE[bih.biWidth*bih.biHeight];
BYTE *pData24 = NULL;//new BYTE[bih.biWidth*bih.biHeight];
int nComponent = 0;// 打开图像文件
FILE *f = fopen(strSourceFileName,"rb");
if (f==NULL)
{
printf("Open file error!\n");
return NULL;
}// 读取文件头
fread(&bfh,sizeof(bfh),1,f);// 读取图像信息
fread(&bih,sizeof(bih),1,f);// 8位字节对齐
nAdjust = bih.biWidth%4;
if (nAdjust) nAdjust = 4-nAdjust;// 24位字节对齐
nAdjust24 = bih.biWidth*3%4;
if (nAdjust24) nAdjust24 = 4-nAdjust24;
switch (bih.biBitCount)
{
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载