Reputation: 6797
I would like to get the dimension of a PNG image file inside my local folder on Windows. How can I achieve this using visual c++?
Upvotes: 0
Views: 1393
Reputation: 2857
aside from the well-known GDI APIs (I get the feeling you are trying to avoid these) it is worth giving http://msdn.microsoft.com/en-us/library/bb776499%28v=VS.85%29.aspx a shot. Never used it myself though :/
Upvotes: 0
Reputation: 67380
Should be easy, the png file is formed by an 8 byte intro, followed by a header chunk. Inside the header chunk you have the length (4 bytes), type (4 bytes), followed by the width and height.
So basically, the width is the 4 byte number at 8+8=16 bytes in the file, and the height is at 8+8+4=20 bytes in the file. Just read them!
Upvotes: 2