Hi, On Feb 27, 2015, at 11:03, Sven Eckelmann <[email protected]> wrote:
> From: Nobuhiro Iwamatsu <[email protected]> ok, looks like it still builds for me after this changes - anybody double checked what happened to: + /* Need? png_info_init (info_ptr); ? Committed r2062. René > --- > codecs/png.cc | 27 ++++++++++++++++----------- > 1 file changed, 16 insertions(+), 11 deletions(-) > > diff --git a/codecs/png.cc b/codecs/png.cc > index be70a53..ec5b16f 100644 > --- a/codecs/png.cc > +++ b/codecs/png.cc > @@ -17,6 +17,7 @@ > > #include <stdlib.h> > #include <png.h> > +#include <zlib.h> > > #include <iostream> > > @@ -58,7 +59,7 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > png_structp png_ptr; > png_infop info_ptr; > png_uint_32 width, height; > - int bit_depth, color_type, interlace_type; > + int bit_depth, color_type, interlace_type, num_trans; > > png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, > NULL /*user_error_ptr*/, > @@ -71,7 +72,7 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > /* Allocate/initialize the memory for image information. REQUIRED. */ > info_ptr = png_create_info_struct(png_ptr); > if (info_ptr == NULL) { > - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); > + png_destroy_read_struct(&png_ptr, NULL, NULL); > return 0; > } > > @@ -82,7 +83,7 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > > if (setjmp(png_jmpbuf(png_ptr))) { > /* Free all of the memory associated with the png_ptr and info_ptr */ > - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); > + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); > /* If we get here, we had a problem reading the file */ > return 0; > } > @@ -99,13 +100,13 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > png_read_info (png_ptr, info_ptr); > > png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, > - &interlace_type, int_p_NULL, int_p_NULL); > + &interlace_type, NULL, NULL); > > image.w = width; > image.h = height; > image.bps = bit_depth; > - image.spp = info_ptr->channels; > - > + image.spp = png_get_channels(png_ptr, info_ptr); > + > png_uint_32 res_x, res_y; > res_x = png_get_x_pixels_per_meter(png_ptr, info_ptr); > res_y = png_get_y_pixels_per_meter(png_ptr, info_ptr); > @@ -119,11 +120,13 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > * (not useful if you are using png_set_packing). */ > // png_set_packswap(png_ptr); > > + png_get_tRNS(png_ptr, info_ptr, NULL, &num_trans, NULL); > + > /* Expand paletted colors into true RGB triplets */ > if (color_type == PNG_COLOR_TYPE_PALETTE) { > png_set_palette_to_rgb(png_ptr); > image.bps = 8; > - if (info_ptr->num_trans) > + if (num_trans) > image.spp = 4; > else > image.spp = 3; > @@ -196,11 +199,11 @@ int PNGCodec::readImage (std::istream* stream, Image& > image, const std::string& > for (int pass = 0; pass < number_passes; ++pass) > for (unsigned int y = 0; y < height; ++y) { > row_pointers[0] = image.getRawData() + y * stride; > - png_read_rows(png_ptr, row_pointers, png_bytepp_NULL, 1); > + png_read_rows(png_ptr, row_pointers, NULL, 1); > } > > /* clean up after the read, and free any memory allocated - REQUIRED */ > - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); > + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); > > /* that's it */ > return true; > @@ -224,7 +227,7 @@ bool PNGCodec::writeImage (std::ostream* stream, Image& > image, int quality, > /* Allocate/initialize the memory for image information. REQUIRED. */ > info_ptr = png_create_info_struct(png_ptr); > if (info_ptr == NULL) { > - png_destroy_write_struct(&png_ptr, png_infopp_NULL); > + png_destroy_write_struct(&png_ptr, NULL); > return false; > } > > @@ -244,8 +247,10 @@ bool PNGCodec::writeImage (std::ostream* stream, Image& > image, int quality, > else if (quality > Z_BEST_COMPRESSION) quality = Z_BEST_COMPRESSION; > png_set_compression_level(png_ptr, quality); > > + /* Need? > png_info_init (info_ptr); > - > + */ > + > /* Set up our STL stream output control */ > png_set_write_fn (png_ptr, stream, &stdstream_write_data, > &stdstream_flush_data); > > -- > 2.1.4 > -- ExactCODE GmbH, Lietzenburger Str. 42, DE-10789 Berlin DE Legal: Amtsgericht Berlin (Charlottenburg) HRB 105123B, Tax-ID#: DE251602478 Managing Director: René Rebe http://exactcode.com | http://exactscan.com | http://ocrkit.com | http://t2-project.org | http://rene.rebe.de
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [email protected] with a subject of: unsubscribe exact-image
