GetLastError
(1)
SzFileName
(1)
LoadImage
(1)
LOADFROMFILE
(1)
DEFAULTSIZE
(1)
Bitmaps
(1)
HBITMAP
(1)
Pixels
(1)

LoadImage() fails on some bitmaps

Asked By Agromatic
22-Jan-10 02:17 PM
Hello,

I am having problems with LoadImage and bitmaps.  Basically, I am
creating a bitmap, writing it to disk and reading it back later.  It
problem seems to be with top-down bitmaps that are under a certain
number of pixels tall (through testing so far, the number of pixels is
between 8 and 16).  All other bitmaps work fine.  Also, I can open the
bitmaps just fine with any application.  Here is the code:

HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, szFileName, IMAGE_BITMAP,
0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE | LR_DEFAULTSIZE);

During debugging, if I break on this line and open the bitmap in a hex
editor to edit the height bytes from (for instance) FF FF FF FF to 01
00 00 00 the function will succeed.

I did some looking around and the only restriction I have found
regarding regarding top-down bitmaps is that they cannot be compressed
(which mine are not).  I suppose its possible that total size matters,
but I have not really tested that yet.  Does anyone have any additional
info?

FWIW:  GetLastError is returning 0
Post Question To EggHeadCafe