Sign in to follow this  
Mantrid

Querying texture dimensions

Recommended Posts

hi all i use D3DXCreateTextureFromFile to load a texture, then D3DXCreateSprite to use the loaded texture as a simple sprite. is there a way of querying either of these to find the dimensions of the image? it's for a menu item that i want the user to be able to click with the mouse also a bit off-topic but still texture-related and just something that's niggling me. the background for my menu is a 640*480 targa file. depending on screen size i scale it in the 'y' direction to fit fullscreen after doing a call to get the screen dimensions, yet for some reason i don't need to do this in the 'x' dimension as it magically comes out like that already (even if i dont scale the 'y')... in 1024 pixels, but nothing higher than that. i don't see why it'll stretch to fit 1024 if it's 640width but if i try to scale it for anything bigger it still comes out too wide :-/ cheers everyone :) [Edited by - Mantrid on December 4, 2005 10:24:21 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Mantrid
i use D3DXCreateTextureFromFile to load a texture, then D3DXCreateSprite to use the loaded texture as a simple sprite.

is there a way of querying either of these to find the dimensions of the image? it's for a menu item that i want the user to be able to click with the mouse

You can call D3DXGetImageInfoFromFile before loading the file to get its info (including dimensions). Or you can call IDirect3DTexture9::GetLevelDesc to retrieve the description of level 0, which also contains the width and height.

The former will return the dimensions of the file, which might not be the same as those of the texture - D3DXCreateTextureFromFile can and will scale the texture in certain situations.

Share this post


Link to post
Share on other sites
oh that's brilliant, i'll try all that out. could also explain the second problem maybe, cheers :)

edit: i used D3DXGetImageInfoFromFile and that got the first problem solved thanks very much!! just wondering about the second now

[Edited by - Mantrid on December 4, 2005 10:25:11 PM]

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