BOOL WriteDIB (CString szFile, CBitmap * pBitmap) // HANDLE handle {/ * BITMAPFILEHEADER hdr; LPBITMAPINFOHEADER lpbi; if (hDIB!) Return FALSE; CFile file; if (file.Open (szFile, CFile :: modeWrite | CFile!: : MODECREATE)) RETURN FALSE; lpbi = (lpbitmapinfohead) HDIB; int ncolors = 1 << lpbi-> bibitcount; // fill in the fields of the file header hdr.bfType = ((Word) ('m "<< 8 ) | 'B'); // is always "bm" // hdr.bfsize = "globalsize" (hdib) sizeof (hdr); hdr.bfreserved1 = "0;" // hdr.bfreserved2 = "0;" HDr.bfoffbits = "(DWORD)" (SIZEOF (HDR) LPBI-> Bisize // NCOLORS * SIZEOF (RGBQUAD)); // Write The File HEADER File.Write (& HDR, SIZEOF (HDR)); // Write the DIB header and the bits file.Write (lpbi, GlobalSize (hDIB)); return TRUE; * / BITMAPINFO * m_pBMI; BYTE * m_pDIBData; BITMAPFILEHEADER bfh; BITMAPINFOHEADER bi; BITMAP BM; PBitmap-> GetObject (sizeof (BM) , & BM); CClientDC DC (this); bi.bisize = sizeof (Bi.biwidth = bm.bmwidth; bi.biheight = bm.bmHeight; bi.Biplanes = 1; bi.biBitcount = 24; bi.bicompression = 0; bi.biXPELSPERMETER = 0; bi.biypelspermeter = 0; bi.bi.bi.bi.bi.bi.bflrimport = 0; bfh.bfType = 0x4d42; bfh.bfofbits = Sizeof bfh) sizeof (BITMAPINFOHEADER); bfh.bfSize = bfh.bfOffBits BM.bmWidth * BM.bmHeight * 3; bfh.bfReserved1 = 0; bfh.bfReserved2 = 0; m_pBMI = (BITMAPINFO *) new char [sizeof (BITMAPINFO )]; m_pdibdata = (byte *) New char [bfh.bfsize-bfh.bfoffbits]; Memcpy (m_pbmi, & bi, sizeof (bitmapinfohead)); getDibits (dc.getsafehdc (), (hbitmap) Pbitmap->