Hallo to all,

I tried to bring a bitmap on the screen.
I loaded it with CreateFile()/ReadFile(). Then I got the DC and got the bitmaphandle via CreateBitmap(). Ok. But when I used SelectObject() with both, I got errorcode 87. Why ???
The loaded Bitmap is 24 Bit, the DC works in 16 Bit mode. Is this incompatible ? Who can help me?

Sorry for my bad english.


Nordwind64
Posted on 2001-09-14 09:40:00 by Nordwind64
I dont think the ReadFile() method of loading a bitmap will work properly. I've never tried, as i always pack my bitmaps in exe resources. But browsing thru the win API i stumbled upon the LoadImage() API.. this might do the trick as there is an option for load from file. At least then you will definitely have a handle to a Bitmap. (ReadFile only gives you a handle to pure data).

NaN
Posted on 2001-09-14 10:42:26 by NaN
hi,
nan is right. if you try to use ReadFile to open a bitmap, you have to fill a bitmap structure (dunno which it was) with the data the bitmap has. it is of very great detail.

take nans advice and use LoadImage.

NOP-erator
Posted on 2001-09-14 11:10:23 by NOP-erator
You can use both LoadImage() and file I/O to read bitmaps. One advantage to using LoadImage() is it fills in the structures for you and automatically returns a bitmap handle. With file I/O, I've always used CreateDIBitmap() to create a bitmap and had trouble with CreateBitma(). So see which one works better for you.
Posted on 2001-09-14 11:38:32 by comrade
Hallo,

thank you, but...

LoadImage() or LoadBitmap() won't work with my Problem, because the datas were decompressed before. I Know LoadImage() and LoadBitmap() but I could not write the datas to disk and then load again...

Any help ?
Posted on 2001-09-14 13:17:16 by Nordwind64
Hallo !!!!!

I've found the way............

GlobalAlloc()
CreateFile()
ReadFile()
CreateCompatibleDC()
CreateDIBSection()
SelectObject()
GetDIBits()
...now copy memory...
SetDIBits()

..........and it works very fine !!!!!


Nordwind 64
Posted on 2001-09-14 16:06:50 by Nordwind64