Definition at line 67 of file Bitmap.h. References BYTE. Referenced by SaveGray2BitmapFile(), and SaveRgb2BitmapFile(). 00068 { 00069 00070 // if it is NOT the multiple of 4,just full it to. 00071 int byteWidth=(3*Width+3)/4*4; 00072 long m_ImageSize = byteWidth*Height; 00073 00074 BITMAPFILEHEADER bmfHdr; 00075 BITMAPINFO *pInfo; 00076 00077 bmfHdr.bfType=0x4d42; //bmfHdr.bfType='MB'; 00078 bmfHdr.bfSize=m_ImageSize+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 00079 bmfHdr.bfReserved1=0; 00080 bmfHdr.bfReserved2=0; 00081 bmfHdr.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 00082 00083 // note: 00084 // ------------------------------------------------------------ 00085 // If biHeight is positive, the bitmap is a bottom-up DIB and 00086 // its origin is the lower-left corner. 00087 // If biHeight is negative, the bitmap is a top-down DIB and 00088 // its origin is the upper-left corner. 00089 // ------------------------------------------------------------ 00090 pInfo = (BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER)); 00091 pInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 00092 pInfo->bmiHeader.biWidth=Width; 00093 pInfo->bmiHeader.biHeight=Height; 00094 pInfo->bmiHeader.biPlanes=1; 00095 pInfo->bmiHeader.biBitCount=24; 00096 pInfo->bmiHeader.biCompression=BI_RGB; 00097 pInfo->bmiHeader.biSizeImage=m_ImageSize; 00098 pInfo->bmiHeader.biXPelsPerMeter=0; 00099 pInfo->bmiHeader.biYPelsPerMeter=0; 00100 pInfo->bmiHeader.biClrUsed=0; 00101 pInfo->bmiHeader.biClrImportant=0; 00102 00103 FILE* fp = fopen(filename, "wb"); 00104 if (fp==NULL) 00105 { 00106 printf("Can not open the file: %s\n",filename); 00107 return; 00108 } 00109 00110 fwrite((LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), 1, fp); 00111 fwrite(pInfo, sizeof(BITMAPINFOHEADER), 1, fp); 00112 fwrite(buf, sizeof(BYTE), m_ImageSize, fp); 00113 00114 fclose(fp); 00115 free(pInfo); 00116 }
|