How to Get the Size of a .png file

Started by
4 comments, last by Andy474 14 years, 11 months ago
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
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.
at the moment i am using D3DXCreateTextureFromFileEx(...); is there another way, and easier way?
Take a look at the pSrcInfo argument.
D3DXCreateTextureFromFileEx() reports information about the texture via the pSrcInfo pointer. Set it to a D3DXIMAGE_INFO and read out from that.
Cheers Guys xD

This topic is closed to new replies.

Advertisement