Advertisement

If only...

Started by November 21, 2002 04:22 AM
10 comments, last by Tooko 21 years, 11 months ago
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.
the future is just like the past, just later. - TANSTAAFL
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.
Advertisement
quote: Original post by Tooko
I''m loading a file into e HBITMAP and then putting the integer into a file using fwrite().

Show us some code!
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.
the future is just like the past, just later. - TANSTAAFL
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.
Umm, you seem to know how, so... how?

The past was unknown, the future was predicted.
the future is just like the past, just later. - TANSTAAFL
Advertisement
GetObject.
iirc, GetObject won''t populate bmBits. i''ve always used GetDIBits.
Ok, could I see some sample code, please!?

The past was unknown, the future was predicted.
the future is just like the past, just later. - TANSTAAFL
sure thing.

http://msdn.microsoft.com/

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

This topic is closed to new replies.

Advertisement