Jump to content
  • Advertisement
Sign in to follow this  
Photon Man

Convert IDirect3DTexture9 to GDI HBITMAPs

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

I have an IDirect3DTexture9 that needs to be converted to (maybe an HBitmap?) or something that GDI can draw out to a window. I just can't seem to convert the actual RGB data of the IDirect3DTexture9 to an acceptable format for the GDI. I'm new to GDI, so source examples would be great. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I only recommend you try doing this if you enjoy punishing yourself. GDI=pain. [wink]

This page has a reasonably good overview of the steps involved. It's most efficient if you create a surface and use SetDIBits() but it is pretty fiddly getting all of the BGR24's encoded correctly (inc. alignment).

Alternatively you can follow similar steps and cheat with SetPixel() which is much slower but hides much of the GDI complexity for you.

As for converting the format - I'm pretty sure GDI DIB's are BGR24, which is backwards to direct3d, so if you have a D3DFMT_X8R8G8B8 it's as simple as swapping the R and B bytes. For 16bit formats it gets much hairier and you need to scale up from 5 or 6 bits to 8 and reorder - a simple bit shift can work, but for quality you may want a more sophisticated algorithm.


hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!