Sign in to follow this  
Andy474

How to Get the Size of a .png file

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
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
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

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