Archived

This topic is now archived and is closed to further replies.

SikCiv

How do I pass an array to an hbitmap?

Recommended Posts

Kentamanos    122
Not sure exactly what you are trying to do, but I think you should look at CreateDIBSection instead. I used this for a project once.

Give that a shot and let me know if you need more help.

------------------

-Kentamanos

Share this post


Link to post
Share on other sites
SikCiv    122
OK im using CreateDIBSection.
But I am having crashes when I run the program.


I have a pointer which contains my 640x480x24bit data, (BYTE* imageData).
I need to create an HBITMAP to pass on to DDCopyBitmap so I can load the image data onto a DDraw surface.

I have filled out a BITMAPINFO called lpbi,
then i make an HDC and the bits pointer, then create the hbitmap...

HDC hDC = GetDC( NULL );
BYTE* BitmapBits = NULL;

HBITMAP hBitmap = CreateDIBSection(hDC,lpbi,
DIB_RGB_COLORS,(void**)&BitmapBits,
NULL, 0)

ok i have an hbitmap with empty data,

?? what next ??

should I memcpy the imageData to the BitmapBits, then do a DDCopyBitmap(..)

Or can I assign the 4th param in CreateDibSection to my imageData?
(preffered to save memory space)

Share this post


Link to post
Share on other sites
SikCiv    122
flash update...


the memcpy way worked, but still I am allocating too much memory, can I assign the 4th param to the imageData (already contains the bitmap data)?

Also,

my image files are 24bit, but my surfaces are 16bit. Does DDraw (DDCopyBitmap) altomatically convert the bitmaps to 16bit when dumping them to the surface? Or are the surfaces actually 24bit, but when blitted convert to 16bit?


Share this post


Link to post
Share on other sites
SikCiv    122
I have a normal array of data (malloc used) and it contains graphical data at 640x480.
How do I create an HBITMAP out of this array?

I have tried using CreateBitmap but it doesnt work properly.

Any ideas?

Share this post


Link to post
Share on other sites