Bitmap question
-
Dear all, This problem of mine has been bugging me crazy. I have to load a 24bit .bmp file and convert it to a 32 bit bmp file. I've manage to load the bitmap file, display it on the screen and even made the code to make it a 32bit bitmap. The problem is to attach the modified bits to the m_bmpBitmap CBitmap object. Then I get the info of the m_bmpBitmap with the BITMAP structure. BITMAP bm; m_bmpBitmap.GetBitmap(&bm); The bm.bmBits is 0x0 which it shouldn't be. All the CreateBitmap() and GetBitmap() funtions return successful but I can't even display the image to screen and I feel it is due to bm.bmBits = 0x0. I've even tried to create a 24 bit bitmap with the same method below and it didn't work too. I would like to be able to view the image that I created and as well as to be able to save it. I welcome any new ideas on how to approach this matter. Many many thanks. Chun Te, Ewe -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ CBitmap m_bmpBitmapOri; CBitmap m_bmpBitmap; BYTE *m_pOriSrc, *m_pSrc; HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), "h:\\logo.bmp" ,IMAGE_BITMAP, 0, 0, R_LOADFROMFILE | LR_CREATEDIBSECTION); m_bmpBitmapOri.Attach(hBitmap); BITMAP bmOri; m_bmpBitmapOri.GetBitmap(&bmOri); // Get the loaded bitmap m_pOriSrc = (BYTE*)bmOri.bmBits; // Pointer to the original bitmap bits // Prepare a new location if(m_pSrc!=NULL) delete [] m_pSrc; m_pSrc = new BYTE[(bmOri.bmHeight+1)*bmOri.bmWidth*4]; ... some code to change from 24bpps to 32 bpps (if needed I can provide) ... if (m_bImageValid) m_bmpBitmap.DeleteObject(); // Creating the image m_bmpBitmap.CreateBitmap( bmOri.bmWidth, bmOri.bmHeight, 1, 32, m_pSrc ); BITMAP bm; // Obtain info regarding bitmap m_bmpBitmap.GetBitmap(&bm); // // Create a device contect to load the bitmap into CDC dcMem; CClientDC pDC(this); dcMem.CreateCompatibleDC(&pDC); dcMem.SelectObject(m_bmpBitmap); pDC.BitBlt(250, 7, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY); // Won't display image