How to get the size of base texture or IDirect3DBaseTexture9* ?
I have an issue with my program. I need to perform a Cyclic Redundancy Check on an IDirect3DBaseTexture9, but I need its size! so I have this:
IDirect3DBaseTexture9* pBaseTexture;
// assume that pBaseTexture now points to a valid IDirect3DBaseTexture9
How can I find the size of the texture that pBaseTexture now points to?
Thanks.
The GetLevelDesc method will give you a description of a mip map inside the texture. You can use the Width, Height and Format member to calculate the size in bytes.
Hello Erik1..4
I recently had to determine size of different pixel formats. I post here a fragment of code that stores this info in two STL maps.
With this info, width and height you can calculate the size of the texture. Be careful about compressed formats, they store info about a 4x4 block of pixels, so you have to round width and height to the next multiple of 4.
I also appreciate anybody to fix any error in format sizes ;)
Regards,
Chema
I recently had to determine size of different pixel formats. I post here a fragment of code that stores this info in two STL maps.
With this info, width and height you can calculate the size of the texture. Be careful about compressed formats, they store info about a 4x4 block of pixels, so you have to round width and height to the next multiple of 4.
I also appreciate anybody to fix any error in format sizes ;)
std::map< D3DFORMAT, unsigned long > formatSizes; std::map< D3DFORMAT, bool > compressedFormats; // Compressed formats hold 16 pixels per texel compressedFormats[D3DFMT_DXT1] = true; compressedFormats[D3DFMT_DXT2] = true; compressedFormats[D3DFMT_DXT3] = true; compressedFormats[D3DFMT_DXT4] = true; compressedFormats[D3DFMT_DXT5] = true; // Hardcoded info about sizes of different formats (in bytes) formatSizes[D3DFMT_A2R10G10B10] = 4; formatSizes[D3DFMT_A8R8G8B8] = 4; formatSizes[D3DFMT_X8R8G8B8] = 4; formatSizes[D3DFMT_A1R5G5B5] = 2; formatSizes[D3DFMT_X1R5G5B5] = 2; formatSizes[D3DFMT_R5G6B5] = 2; formatSizes[D3DFMT_D16_LOCKABLE] = 2; formatSizes[D3DFMT_D32] = 4; formatSizes[D3DFMT_D15S1] = 2; formatSizes[D3DFMT_D24S8] = 4; formatSizes[D3DFMT_D24X8] = 4; formatSizes[D3DFMT_D24X4S4] = 4; formatSizes[D3DFMT_D32F_LOCKABLE] = 4; formatSizes[D3DFMT_D24FS8] = 4; formatSizes[D3DFMT_D16] = 2; formatSizes[D3DFMT_DXT1] = 8; formatSizes[D3DFMT_DXT2] = 16; formatSizes[D3DFMT_DXT3] = 16; formatSizes[D3DFMT_DXT4] = 16; formatSizes[D3DFMT_DXT5] = 16; formatSizes[D3DFMT_R16F] = 2; formatSizes[D3DFMT_G16R16F] = 4; formatSizes[D3DFMT_A16B16G16R16F] = 8; formatSizes[D3DFMT_MULTI2_ARGB8] = 4; // correct???? formatSizes[D3DFMT_R8G8_B8G8] = 2; formatSizes[D3DFMT_UYVY] = 2; formatSizes[D3DFMT_YUY2] = 2; formatSizes[D3DFMT_INDEX32] = 4; formatSizes[D3DFMT_INDEX16] = 2; formatSizes[D3DFMT_VERTEXDATA] = 0; formatSizes[D3DFMT_R32F] = 4; formatSizes[D3DFMT_G32R32F] = 8; formatSizes[D3DFMT_A32B32G32R32F] = 16; formatSizes[D3DFMT_L6V5U5] = 2; formatSizes[D3DFMT_X8L8V8U8] = 4; formatSizes[D3DFMT_A2W10V10U10] = 4; formatSizes[D3DFMT_V8U8] = 2; formatSizes[D3DFMT_Q8W8V8U8] = 4; formatSizes[D3DFMT_V16U16] = 4; formatSizes[D3DFMT_Q16W16V16U16] = 8; formatSizes[D3DFMT_CxV8U8] = 2; formatSizes[D3DFMT_R8G8B8] = 3; formatSizes[D3DFMT_A8R8G8B8] = 4; formatSizes[D3DFMT_X8R8G8B8] = 4; formatSizes[D3DFMT_R5G6B5] = 2; formatSizes[D3DFMT_X1R5G5B5] = 2; formatSizes[D3DFMT_A1R5G5B5] = 2; formatSizes[D3DFMT_A4R4G4B4] = 2; formatSizes[D3DFMT_R3G3B2] = 1; formatSizes[D3DFMT_A8] = 1; formatSizes[D3DFMT_A8R3G3B2] = 2; formatSizes[D3DFMT_X4R4G4B4] = 2; formatSizes[D3DFMT_A2B10G10R10] = 4; formatSizes[D3DFMT_A8B8G8R8] = 4; formatSizes[D3DFMT_X8B8G8R8] = 4; formatSizes[D3DFMT_G16R16] = 4; formatSizes[D3DFMT_A2R10G10B10] = 4; formatSizes[D3DFMT_A16B16G16R16] = 8; formatSizes[D3DFMT_A8P8] = 2; // ?????? formatSizes[D3DFMT_P8] = 1; formatSizes[D3DFMT_L8] = 1; formatSizes[D3DFMT_L16] = 2; formatSizes[D3DFMT_A8L8] = 2; formatSizes[D3DFMT_A4L4] = 1;
Regards,
Chema
You can't use GetLevelDesc on a IDirect3DBaseTexture9 *.
If you know which type of texture it is (e.g. a IDirect3DTexture9, a IDirect3DVolumeTexture, etc.) you can typecast it and use GetLevelDesc. Then, with the type of encoding and the resolution, you can compute the size of the texture.
(the GetType() method of IDirect3DResource9 might be of some help)
If you know which type of texture it is (e.g. a IDirect3DTexture9, a IDirect3DVolumeTexture, etc.) you can typecast it and use GetLevelDesc. Then, with the type of encoding and the resolution, you can compute the size of the texture.
(the GetType() method of IDirect3DResource9 might be of some help)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement