• Advertisement
Sign in to follow this  

How to Get the Size of a .png file

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

Hey guys, I am writing a sprite class in DirectX. I load a .png file as a texture to use on the sprite and then draw it, this currently works fine. However I want to check if the mouse has clicked in the sprite, for this i need to have a function return the RECT of the sprite, and the only way i can see to do this is to make a RECT. I know the xPos, yPos and zPos of the Sprite(position it is set to) but i dont know the length os the texture, or the Height of the Texture, are there any easy(or difficult :P) ways of finding the Width and Height (e.g 100x400) of a File without having to enter them manually? Any input is appreciated :) thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
How are you loading the file? Most texture loaders will have some mechanism for telling you the size of the image when you load it.

Share this post


Link to post
Share on other sites
at the moment i am using D3DXCreateTextureFromFileEx(...); is there another way, and easier way?

Share this post


Link to post
Share on other sites
Take a look at the pSrcInfo argument.

Share this post


Link to post
Share on other sites
D3DXCreateTextureFromFileEx() reports information about the texture via the pSrcInfo pointer. Set it to a D3DXIMAGE_INFO and read out from that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement