Bitmap biHeight Negative or Positive?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Bitmap biHeight Negative or Positive?

  1. #1
    Join Date
    Feb 2002
    Posts
    42

    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.

  2. #2
    Join Date
    Feb 2002
    Posts
    42
    ???

  3. #3
    Join Date
    May 2000
    Location
    Scotland, Livingston.
    Posts
    728
    Does the LoadImage fail?
    Whats the error returned from GetLastError()?
    Dave Mclelland.

  4. #4
    Join Date
    Feb 2002
    Posts
    42
    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.

  5. #5
    Join Date
    May 2000
    Location
    Scotland, Livingston.
    Posts
    728
    Please post your call to LoadImage and any other relevant code. Post the bitmap too if possible.
    Dave Mclelland.

  6. #6
    Join Date
    Feb 2002
    Posts
    42
    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,
    Lily311

  7. #7
    Join Date
    Feb 2010
    Posts
    2

    Re: Bitmap biHeight Negative or Positive?

    Hi All,

    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:

    Code:
    hBitmap = (HBITMAP)LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
    Any insight would be helpful. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center