October 16th, 2003, 03:59 AM
Bitmap biHeight Negative or Positive?
As I observed, most bitmaps are bottom-up DIB and the biHeight
of BITMAPINFOHEADER are positive. After scanned a bitmap,
I have to save the RGB data in a top-down way because of time issue.
So I set the biHeight negative. If I double-click the bmp file
directly, it can be shown correctly, but can't load it with ::LoadImage();
If I change biHeight to positive, I can load it with ::LoadImage(),
but the bitmap is upside-down.
Any help be appreciated.
October 16th, 2003, 09:39 PM
October 16th, 2003, 09:41 PM
Does the LoadImage fail?
Whats the error returned from GetLastError()?
October 16th, 2003, 11:04 PM
VC Debug Window said:
HEAP[test.exe]: Invalid allocation size - FFF84800 (exceeded 7ffdefff)
GetLastError() returns 0x0008. That is Not enough storage is available to process this command.
My bitmap width: 658, height: 256. I think, when I set the height negative, LoadImage() still treats it as unsigned data, and gets the bitmap size by width*height. That's a too huge size.
October 19th, 2003, 04:10 PM
Please post your call to LoadImage and any other relevant code. Post the bitmap too if possible.
October 21st, 2003, 05:19 AM
Hi, Dave McLelland:
Thanks for your kindness and help.
I rearranged the bmp data in the bottom-up way, kept the height positive, and solved the problem with LoadImage.
But the problem I've mentioned above Does exist. If you still wondered, just modify any bmp to a negative height, load it with LoadImage, and I believe it will return NULL.
Anyway, if you get different result, kindly let me know please.
Regards & Thanks,
February 9th, 2010, 12:50 PM
Re: Bitmap biHeight Negative or Positive?
I'm wondering if any more light has been shed on this issue (I realize it is a very old post)? I started running into it recently pretty consistently on XP and even occasionally on Vista with very small bitmaps.
Just the normal LoadImage code:
Any insight would be helpful. Thanks!
hBitmap = (HBITMAP)LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!