Well, I was taking a look at the pnglib example from thomas's site and i found i could make it much more useful for myself by converting it to a class. So here it is if you want to use it. Also there is a file main.cpp in the archieve which demostrates how to load a png from a file using the class. Basically its the C example of thomas which i modified to show how easily you can use pngs with this class. So in order to run the main.cpp you need to have the pnglib package.

Anyway here's my description a bit-

This is how you load a png and then create a bitmap from it-


Png myPng("filename.png");
HBITMAP bmp= myPng.CreateBitmap(hWnd);

The cleanup function is inthe destructor so you dont need to worry about it.
Although the constructor is overloaded so that you can load a file straightaway, i would recommen using the Load function, cause it can tell you if an error occurs.

This is how you use it-


Png myPng;
if(!myPng.Load("filename.png"))
// error handling code


The Load functions and constructors are overloaded to supprt all the 3 types of loading possible. This is how you load from custom data.
Png myPng(customData,sizeof(customData));


To get the size of image, use GetSize function passing a pointer to PngSize, like this-
PngSize size;

myPng.GetSize(&size);


There are a few more functions to retrieve the color depth,etc.

P.S.- Thomas, it seems you forgot to specify the ColorType and interlacing format in your header file.


This file is in RAR format. Rename to .rar after downloading. I dont have winzip installed here, so i renamed the file to .zip so that it can be uploaded.
Posted on 2002-11-28 04:59:44 by clippy
Very nice :alright:. I'm actually using the library in some of my C++ projects so this class may come in handy.
P.S.- Thomas, it seems you forgot to specify the ColorType and interlacing format in your header file.

You're right :). I'll add them together with your wrapper class in the next update..

Thanks again,

Thomas
Posted on 2002-11-28 10:39:53 by Thomas