Accessing Direct3D Texture Dimensions in C#

Started by
2 comments, last by remigius 17 years, 11 months ago
Is there any way to get the width and height of a Direct3D texture in C#? I know you can do it in C++ by using the D3DXCreateTextureFromFileEX function and passing in a pointer to a D3DXIMAGE_INFO struct to the function. Any thoughts? Thanks,
Advertisement
textureLoader.ImageInformationFromFile shold do the job.

Also, TextureLoader has an overloaded FromFile() method that takes an ImageInformation structure that gets filled in like the D3DXIMAGE_INFO structure.
Note that Evil Steve's remark also applies here. If you load a 200x200 image into a texture, the actual texture size will probably be 256x256. To get this texture size, you can use the Width and Height in the surface description of the first MIP level:

SurfaceDescription sd = texture.GetLevelDescription(0);
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement