Archived

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

If only...

This topic is 5504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The topic is a little of the subject, but hey. I''m loading a file into e HBITMAP and then putting the integer into a file using fwrite(). No errors so far. Programs closes, Ok, but the file is only 4bytes. Logically, it should be the 17.5kb that the *.bmp is. So, arises my two questions. A) Is a HBITMAP only a pointer (or something similar) to a file. B) Would saving a LPDIRECTDRAWSURFACE7 with fwrite() work. Any help would be nice... The past was unknown, the future was predicted.

Share this post


Link to post
Share on other sites
The file is probably 4 bytes large because you are trying to store a pointer to the bitmap structure. In the hbitmap structure there is a pointer to the bitmap data, you need to store this data together with the height width and color depth of the image. And no you can''t save a directdraw surface by just storing its pointer.

Share this post


Link to post
Share on other sites
HBITMAP bmp = LoadBitmap(hInstance, "Image.bmp");
FILE *file = fopen("File.dat", "wb");
fwrite(&bmp, sizeof(bmp), 1, file);
flose(file);

The past was unknown, the future was predicted.

Share this post


Link to post
Share on other sites
What you''ve got there is a HBITMAP. In microsoft-ese (hungarian notation) that''s short for "handle to bitmap". A handle is a 32-bit value which may or may not be a pointer, which refers to an object managed by the OS. Don''t bother storing it or reading it. Use WinAPI functions to get the data stored in the bitmap itself, and store that.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
iirc, GetObject won''t populate bmBits. i''ve always used GetDIBits.

Share this post


Link to post
Share on other sites
Wait a sec, I agree. I use GetObject to actually get the size of a bitmap when loading into a DXSurface.

The past was unknown, the future was predicted.

Share this post


Link to post
Share on other sites