http://www.cnblogs.com/mr-wid/archive/2013/04/19/3029842.html
先看这篇文章,关于pnglib的入门讲解
下面贴上源代码(在VC 6.0下编译通过):
#include "stdafx.h"
#include <stdio.h>
#include "png.h"
#include <stdlib.h>
typedef struct {
unsigned char* pixelData;
int imageWidth;
int imageHeight;
}ImageInfo;
typedef struct {
unsigned char* data;
int size;
int offset;
}ImageSource;
ImageInfo* decodePNGFromFile(char* fileName)
{
char png_header[8];
png_structp png_ptr;
png_infop info_ptr;
int width, height, rowBytes;
png_byte color_type;
png_byte bit_depth;
png_colorp palette;
/* open file and test for it being a png */
FILE *file = fopen(fileName, "rb");
fread(png_header, 1, 8, file);
if(png_sig_cmp((png_bytep)png_header, 0, 8))
{