Can't understnand what is wrong with this code:
HBITMAP bm = 0;
BITMAP Bitmap;
bm = (HBITMAP)LoadImage (0, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
int error = GetObject( &Bitmap, sizeof( BITMAP ), &bm );
The LoadImage function returns non null pointer. However GetObject returns 0, which indicates on error. I want to get size info and image data from HBITMAP pointer (the pointer can be passed as parameter, so I can't change the way I load the bitmap file).
Maybe putting the parameters in the right places will help:
HBITMAP bm = 0;
BITMAP Bitmap;
bm = (HBITMAP)LoadImage (0, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
int error = GetObject( bm, sizeof( BITMAP ), &Bitmap ); // << NOTE ORDERING
See the documentation on GetObject()
for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With