diff --git a/gr-utils/loadpng.c b/gr-utils/loadpng.c index a220d695..ec00786f 100644 --- a/gr-utils/loadpng.c +++ b/gr-utils/loadpng.c @@ -54,7 +54,7 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) { png_structp png_ptr; png_infop info_ptr; png_bytep *row_pointers; -// png_byte color_type; + png_byte color_type; // int number_of_passes; unsigned char header[8]; @@ -96,11 +96,16 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) { *xsize=width/2; *ysize=height; -// color_type = png_get_color_type(png_ptr, info_ptr); + color_type = png_get_color_type(png_ptr, info_ptr); bit_depth = png_get_bit_depth(png_ptr, info_ptr); + + if (debug) { printf("PNG: width=%d height=%d depth=%d\n",width,height,bit_depth); + if (color_type==PNG_COLOR_TYPE_RGB) printf("Type RGB\n"); + else if (color_type==PNG_COLOR_TYPE_RGB_ALPHA) printf("Type RGBA\n"); + else if (color_type==PNG_COLOR_TYPE_PALETTE) printf("Type palette\n"); } // number_of_passes = png_set_interlace_handling(png_ptr); @@ -122,33 +127,60 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) { } out_ptr=image; - for(y=0;y