Sign in to follow this  
Photon Man

Convert IDirect3DTexture9 to GDI HBITMAPs

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this