Originally posted by: Ricky Chow
void CFaceDetectionDlg::OnFileOpen()
FileName[0] = '\0';
openInformation.lStructSize = sizeof(OPENFILENAME);
GetOpenFileName (&openInformation);
LoadBMPImage (FileName, m_originalPicture, &m_originalPicturePalette);
// Create a memory DC compatible with the paint DC
// The variable bitmap is a CBitmap object
memDC.DeleteDC ();
I just use the loadBMPImage function to load the BMP and store the result in two member variables m_originalPicture (CBitmap) and m_originalPicturePalette (CPalette). For the first time, it works. However, debug assertion fail occurs at the second time. Why? My code for open & draw the BMP is as follow :
{
char FileName[500], FileTitle[100];
OPENFILENAME openInformation;
memset (&openInformation, 0, sizeof(OPENFILENAME));
openInformation.hwndOwner = NULL;
openInformation.hInstance = NULL;
openInformation.lpstrFilter = TEXT("Bitmap files *.bmp\0*.bmp\0All Files *.*\0*.*\0\0");
openInformation.lpstrCustomFilter = NULL;
openInformation.nMaxCustFilter = 0;
openInformation.nFilterIndex = 1;
openInformation.lpstrFile = FileName;
openInformation.nMaxFile = 500;
openInformation.lpstrFileTitle = FileTitle;
openInformation.nMaxFileTitle = 99;
openInformation.lpstrInitialDir = NULL;
openInformation.lpstrTitle = "Open BMP File";
openInformation.Flags = OFN_FILEMUSTEXIST;
openInformation.lpstrDefExt = "BMP";
openInformation.lCustData = NULL;
openInformation.lpfnHook = NULL;
openInformation.lpTemplateName = NULL;
CDC memDC;
CClientDC dc(this);
memDC.CreateCompatibleDC (&dc);
memDC.SelectObject (m_originalPicture);
BITMAP bm;
m_originalPicture.GetBitmap( &bm );
dc.StretchBlt (20, 60, 250, 250, &memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}
Originally posted by: Ronen Magid
The section in the load bitmap method fails in this line:
HBITMAP hBmp = CreateDIBitmap(...............
it returns a HBITMAP which is null and therefore the
"attach" which follows it asserts....
The bitmap im trying to load is "healthy".
any solutions ?
Ronen
Originally posted by: Marius Alexandru
How can i gain access to modify the pixel array of a bitmap (object)
ReplyOriginally posted by: Windy
I am a beginner of VC++, and I want to use these codes to
realize opening,loading and displaying a BMP file in a MDI
application.But I don't know how to use these codes,can you
help me and give me an example of using?
Thanks a lot,
Windy
ReplyOriginally posted by: Jeremy Bake
RetroActive
trying ot use this function I found that although you passed in a CBitmap object it never got referenced in
the function. I found by changing the end of te function to:
...
if( pOldPalette )
dc.SelectPalette( pOldPalette, FALSE );
::GlobalFree(hDIB);
bitmap.Attach(hBmp); //this is all that's new
return TRUE;
}
that it now worked perfectly.
Originally posted by: Michael Fountain
This load bitmap from bmp file code is great, but some of your other
examples (fade to gray ect.)pass a HANDLE Hdib. How do you get the HANDLE for the bitmap you just loaded
from a bmp file?