What Data Format Shoulsd I Use

Started by
2 comments, last by dave 19 years, 6 months ago
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
Advertisement
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.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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
oh im with you now... :)

This topic is closed to new replies.

Advertisement