diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/render/pngfile.cc | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/render/pngfile.cc b/src/render/pngfile.cc index da434db..ca8c8d5 100644 --- a/src/render/pngfile.cc +++ b/src/render/pngfile.cc @@ -75,15 +75,14 @@ Image *PNG::load(const char *filename) /* read the PNG header */ png_init_io(png_ptr, png_file->handle()); png_set_sig_bytes(png_ptr, 8); - png_read_info(png_ptr, info_ptr); - int png_width = info_ptr->width; - int png_height = info_ptr->height; - //int png_color_type = info_ptr->color_type; - int png_depth = info_ptr->bit_depth; + int png_width = png_get_image_width(png_ptr, info_ptr); // image width + int png_height = png_get_image_height(png_ptr, info_ptr); // image height + int png_depth = png_get_bit_depth(png_ptr, info_ptr); // bits per channel + int png_channels = png_get_channels(png_ptr, info_ptr); // channels + int png_rowbytes = png_get_rowbytes(png_ptr, info_ptr); // bytes per row - //int number_of_passes = png_set_interlace_handling(png_ptr); png_set_interlace_handling(png_ptr); png_read_update_info(png_ptr, info_ptr); @@ -94,8 +93,7 @@ Image *PNG::load(const char *filename) return 0; } - unsigned int channels = info_ptr->rowbytes / png_width; - image = new Image(png_width, png_height, channels); + image = new Image(png_width, png_height, png_channels); /* read image data */ if (setjmp(png_jmpbuf(png_ptr))) { @@ -109,7 +107,7 @@ Image *PNG::load(const char *filename) png_bytep row_pointers[png_height]; for (size_t i = 0; i < (size_t)png_height; i++) - row_pointers[i] = (png_bytep)(*image)[i * info_ptr->rowbytes]; + row_pointers[i] = (png_bytep)(*image)[i * png_rowbytes]; // read pixel data png_read_image(png_ptr, row_pointers); |