Advertisement

Need help on loading a custom graphic file format in GDI

Started by December 04, 2000 01:40 PM
1 comment, last by Crazy_Vasey 24 years, 1 month ago
I''m guessing here but I think I need to fill out a HBITMAP struct. I can''t find any info on the HBITMAP struct could someone please tell me what I have to do and a rough idea of how to do it?
First of all, HBITMAP is a handle to a bitmap, and not a structure.

Assuming you''re using the GDI, you need to create a bitmap in memory (eg using CreateCompatibleBitmap(hDC, width, height), which returns an HBITMAP) and then fill in a BITMAPINFO structure describing your format (bits-per-pixel, etc. There''s tonnes of $#!+ to fill in). You can then call SetDIBits() to transfer your image to the bitmap.

As you''re reading the bitmap from a file, you''ll need to read in its header describing its size and bit-depth etc. before creating the bitmap in memory. Then read in the image itself and uncompress it or whatever to a large buffer, before calling SetDIBits().

If you have the MSDN, this is all in there somewhere. Try looking under Platform SDK/Graphics and Multimedia/GDI/Bitmaps... If you don''t have it, it''s available online at Microsoft''s website (http://msdn.microsoft.com/).

Good luck!
Advertisement
Thanks! I''ll go try that now.

This topic is closed to new replies.

Advertisement