{
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER *lpbi=(BITMAPINFOHEADER*)hData;
bfh.bfType=0x4D42; //BM
bfh.bfSize=sizeof(bfh)+GlobalSize(hData);
bfh.bfReserved1=bfh.bfReserved2=0;
int colors=1<biBitCount;
if(colors>256) colors=0;
bfh.bfOffBits=sizeof(bfh)+lpbi->biSize+colors*sizeof(RGBQUAD);
HANDLE hFile=CreateFile(filename,GENERIC_WRITE
,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile)
{
DWORD write;
WriteFile(hFile,&bfh,sizeof(bfh),&write,NULL);
WriteFile(hFile,lpbi,GlobalSize(hData),&write,NULL);
int i=sizeof(hData);
CloseHandle(hFile);
return true;
}
return false;
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/