PDA

View Full Version : Loading bitmaps w/ LoadImage and GetObject??



delic
10-06-2002, 11:09 AM
I am trying to load a bitmap from a file.. the following sequence of calls seems to work but the bmp.bits pointer is 0x000000. I assume this is not correct??Anyone ever load bitmaps in this way??

HBITMAP pbitmap=(HBITMAP)LoadImage(0,Filename,IMAGE_BITMAP ,0,0,LR_LOADFROMFILE);
GetObject(pbitmap, sizeof(BITMAP), (LPSTR)&bmp);

*Aaron*
10-06-2002, 11:28 AM
Taken from the Win32 API documentation:
If hgdiobj identifies a bitmap created by calling CreateDIBSection, and the specified buffer is large enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap?s bit values.

If hgdiobj identifies a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap?s bit values by calling the GetDIBits or GetBitmapBits function.

delic
10-06-2002, 01:21 PM
hey thanks the mistake was that I was missing |LR_CREATEDIBSECTION in the loadimage call for anyone interested..