时间: 2021-07-31 作者:daque
int savebmp(handle hdata,lpstr filename){bitmapfileheader bfh;bitmapinfoheader *lpbi=(bitmapinfoheader*)hdata;bfh.bftype=0x4d42; //bmbfh.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; }