Sign in to follow this  
dave

What Data Format Shoulsd I Use

Recommended Posts

Ok so ive got a pointer the bits in a locked rectangle, but what data format are theyb stored in, so i can memcpy them to an array? ace

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
Ok so ive got a pointer the bits in a locked rectangle, but what data format are theyb stored in, so i can memcpy them to an array?

ace



The format of the data will be in whichever format the surface/texture was created in.

If you didn't create the texture yourself (perhaps due to using something such as D3DXCreateTextureFromFile() which decided on a format for you), then you can use IDirect3DTexture9::GetLevelDesc() to find out.

The name of the format tells you how it's layed out in memory; D3DFMT_R5G6B5 for example means 5-bits of red, then 6-bits of green, then 5-bits of blue, and 5+6+5=16 so each pixel is 16-bits or a "WORD" wide. Another example, D3DFMT_X8B8G8R8 means 8 unused bits (X8), followed by 8 blue bits (B8), 8 green bits (G8) and finally 8 red bits (R8); 8+8+8+8=32=DWORD.

Share this post


Link to post
Share on other sites
Umm, maybe i should have explained, this is a lock rect on a surface not a texture, probably similar, but basically i need to know how toread the color of a pixel within that rect and im nnot sure how...


ace

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