X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2F3dengfx%2Fsrc%2Fgfx%2Fimage_png.c;h=2c9b3606e2ca91b166265d7a708acae68f31f680;hb=594591c9a7a04a16dd1446ad83c3597fc0244b52;hp=1b0f75944c46221c73b3e37d720eacc39ccd7001;hpb=6e23259dbabaeb1711a2a5ca25b9cb421f693759;p=summerhack diff --git a/src/3dengfx/src/gfx/image_png.c b/src/3dengfx/src/gfx/image_png.c index 1b0f759..2c9b360 100644 --- a/src/3dengfx/src/gfx/image_png.c +++ b/src/3dengfx/src/gfx/image_png.c @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifdef IMGLIB_USE_PNG #include -#include +#include "png.h" #include "color_bits.h" #include "common/types.h" @@ -51,6 +51,7 @@ void *load_png(FILE *fp, unsigned long *xsz, unsigned long *ysz) { png_info *info_ptr; int i; uint32_t **lineptr, *pixels; + png_uint_32 width, height; int channel_bits, color_type, ilace_type, compression, filtering; if(!(png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0))) { @@ -63,8 +64,8 @@ void *load_png(FILE *fp, unsigned long *xsz, unsigned long *ysz) { fclose(fp); return 0; } - - if(setjmp(png_jmpbuf(png_ptr))) { + + if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, 0); fclose(fp); return 0; @@ -75,7 +76,9 @@ void *load_png(FILE *fp, unsigned long *xsz, unsigned long *ysz) { png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, 0); - png_get_IHDR(png_ptr, info_ptr, xsz, ysz, &channel_bits, &color_type, &ilace_type, &compression, &filtering); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &channel_bits, &color_type, &ilace_type, &compression, &filtering); + *xsz = width; + *ysz = height; pixels = malloc(*xsz * *ysz * sizeof(uint32_t)); lineptr = (uint32_t**)png_get_rows(png_ptr, info_ptr);