Jump to content
  • Advertisement

Archived

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

zohare

create a bitmap from DC

This topic is 6552 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

Advertisement
Well, I''m not exactly sure what you mean by creating a bitmap from it. A bitmap can be loaded and then put onto a directdraw surface, which you could do by including ddutil and using the ddLoadBitmap function.

Masters Software

Share this post


Link to post
Share on other sites
That''s a good question. The DDLoadBitmap() will load a bitmap into a DirectDraw surface. But you want to go the other way around-- Have a DirectDraw surface and create a (DIB) Bitmap from it.

To be honest, I don''t know if there is a really easy way to do it using any DirectDraw API calls.

To do it by hand, you need to read up on how to write a DIB bitmap. Then you would just write the contents of the DC or DirectDraw surface (a pixel at a time if necessary.) Preserving the DC''s pixel format is probably a bit tricky, esp with 15 or 16-bit graphic formats.

// CHRIS

Share this post


Link to post
Share on other sites
1) Get a DC from your DDraw surface

2) Use CreateCompatibleDC() to create a DC compatible with your DDraw surface''s DC

3) Use CreateCompatibleBitmap() to create abitmap with the same properties as your surface.

4) Use SelectObject() to select the bitmap into your compatible DC.

5) Use BitBlt() to copy the contents of the DDraw surface''s DC into the new DC.

Share this post


Link to post
Share on other sites
Problem is that when I create the bitmap that way I get a 16bpp bitmap. How cn I control the format of the created bitmap, for example if I want 24bpp bitmap?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!