Jump to content
  • Advertisement
Sign in to follow this  
Brisco

How to determine size of textures (in bytes)

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

Hello! I have a question about textures in DirectX... I need to know the size of a texture - or better, the size of every mip level considering the used format. This is no problem for uncompressed textures, I simply determine the dimensions of a mip level and multiply them with the bytes that are required per pixel for the specified format... but what about compressed textures? I think there should be a way to determine the required memory?

Share this post


Link to post
Share on other sites
Advertisement
If you know the initial size I believe the sizes work in the following manner
Eg.

256 x 256
128 x 128
64 x 64

That's how it will work, you will also want to specify the number of mipmap levels to create...

Eg.
From the SDK Docs.
"The following example shows how your application can call the IDirect3DDevice9::CreateTexture method to build a chain of five mipmap levels: 256x256, 128x128, 64x64, 32x32, and 16x16.

// This code example assumes that m_d3dDevice is a
// valid pointer to a IDirect3DDevice9 interface

IDirect3DTexture9 * pMipMap;
m_pD3DDevice->CreateTexture(256, 256, 5, 0, D3DFMT_R8G8B8,
D3DPOOL_MANAGED, &pMipMap);

"

Hope this helps a bit.

Share this post


Link to post
Share on other sites
If you want to know the size of a non mip-levelled texture just open it first as a file with fstream.

ace

Share this post


Link to post
Share on other sites
That's right, but it doesn't help me to get the exact size in bytes of a compressed texture. In fact, I know the size of any mip level - and as long as the texture is not compressed, I also know the size in bytes because it can be easily calculated by width*height*bytesperpixel.

My goal is, to lock a texture and write the complete data into a file in my own format, this is part of an object persistence framework I have written, but to do this, I need to know the exact size in bytes.

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!