-
April 26th, 2009, 02:43 AM
#1
Load BMP into Memory, then get HBITMAP
I've spent two days trying to figure out how to load a 24 bit RGB bmp file into memory, and then later convert the DIB memory contents into a BITMAP and HBITMAP so I can selectObject the **** thing into a compatible memory DC. I thought GdipCreateBitmapFromGdiDib would get me there, but I still need to get the HBITMAP for the SelectObject and have no way to get an HBITMAP in this case because if I define a BITMAP structure, it is not a Windows record that has a handle to it. The doc says I cannot modify the BITMAP contents once the bitmap is created, so I can't just create a dummy bitmap of 1x1 pixel and then adjust the dimensions later.
It seems like the most simple and reasonable thing to be able to do, to allocate a chunk of ram, load a bmp file into it and then create a memory DC and bitmap structure (without re-copying the bitmap data into a newly allocated buffer) so that GDI functions can write on it. I can LoadBitmap things that are resources, and LoadImages from the file system, but there seems to be no way to treat a memory image of a BMP file as a DIB and get a handle to a bitmap without copying the **** thing...
Any insight on this would be greatly appreciated. I probably can find a solution in an open source project, and I guess I'll go searching there now.
-
April 26th, 2009, 06:16 AM
#2
Re: Load BMP into Memory, then get HBITMAP
-
May 19th, 2009, 05:44 PM
#3
Re: Load BMP into Memory, then get HBITMAP
Just one more detail, the first thing you need to know after you load a bitmap in the memory is the format of a BMP file. It's here: http://www.fortunecity.com/skyscrape.../bmpffrmt.html (or else, look for BMP on www.wotsit.org) .
-
May 21st, 2009, 06:41 AM
#4
Re: Load BMP into Memory, then get HBITMAP
Have you tried looking at the articles in the Bitmap and Palettes section on Codeguru? There are articles that talk about working with 24 bit bitmaps.
Gort...Klaatu, Barada Nikto!
-
May 21st, 2009, 09:45 PM
#5
Re: Load BMP into Memory, then get HBITMAP
Why would you want to load the bitmap in the memory first? Is that anything you want to modify? GDI+ allows you to load files from memory. Some people make use of this feature to load their encrypted images into the memory and decrypt the contents in memory and load the decrypted image from memory. I doubt the OP would want to change his GDI code to use GDI+. Too much work.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|