1 --- exactimage-0.8.5.orig/codecs/png.cc
2 +++ exactimage-0.8.5/codecs/png.cc
11 @@ -58,7 +59,7 @@ int PNGCodec::readImage (std::istream* s
14 png_uint_32 width, height;
15 - int bit_depth, color_type, interlace_type;
16 + int bit_depth, color_type, interlace_type, num_trans;
18 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
19 NULL /*user_error_ptr*/,
20 @@ -71,7 +72,7 @@ int PNGCodec::readImage (std::istream* s
21 /* Allocate/initialize the memory for image information. REQUIRED. */
22 info_ptr = png_create_info_struct(png_ptr);
23 if (info_ptr == NULL) {
24 - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
25 + png_destroy_read_struct(&png_ptr, NULL, NULL);
29 @@ -82,7 +83,7 @@ int PNGCodec::readImage (std::istream* s
31 if (setjmp(png_jmpbuf(png_ptr))) {
32 /* Free all of the memory associated with the png_ptr and info_ptr */
33 - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
34 + png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
35 /* If we get here, we had a problem reading the file */
38 @@ -99,13 +100,13 @@ int PNGCodec::readImage (std::istream* s
39 png_read_info (png_ptr, info_ptr);
41 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
42 - &interlace_type, int_p_NULL, int_p_NULL);
43 + &interlace_type, NULL, NULL);
47 image.bps = bit_depth;
48 - image.spp = info_ptr->channels;
50 + image.spp = png_get_channels(png_ptr, info_ptr);
52 png_uint_32 res_x, res_y;
53 res_x = png_get_x_pixels_per_meter(png_ptr, info_ptr);
54 res_y = png_get_y_pixels_per_meter(png_ptr, info_ptr);
55 @@ -119,11 +120,13 @@ int PNGCodec::readImage (std::istream* s
56 * (not useful if you are using png_set_packing). */
57 // png_set_packswap(png_ptr);
59 + png_get_tRNS(png_ptr, info_ptr, NULL, &num_trans, NULL);
61 /* Expand paletted colors into true RGB triplets */
62 if (color_type == PNG_COLOR_TYPE_PALETTE) {
63 png_set_palette_to_rgb(png_ptr);
65 - if (info_ptr->num_trans)
70 @@ -196,11 +199,11 @@ int PNGCodec::readImage (std::istream* s
71 for (int pass = 0; pass < number_passes; ++pass)
72 for (unsigned int y = 0; y < height; ++y) {
73 row_pointers[0] = image.getRawData() + y * stride;
74 - png_read_rows(png_ptr, row_pointers, png_bytepp_NULL, 1);
75 + png_read_rows(png_ptr, row_pointers, NULL, 1);
78 /* clean up after the read, and free any memory allocated - REQUIRED */
79 - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
80 + png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
84 @@ -224,7 +227,7 @@ bool PNGCodec::writeImage (std::ostream*
85 /* Allocate/initialize the memory for image information. REQUIRED. */
86 info_ptr = png_create_info_struct(png_ptr);
87 if (info_ptr == NULL) {
88 - png_destroy_write_struct(&png_ptr, png_infopp_NULL);
89 + png_destroy_write_struct(&png_ptr, NULL);
93 @@ -244,8 +247,10 @@ bool PNGCodec::writeImage (std::ostream*
94 else if (quality > Z_BEST_COMPRESSION) quality = Z_BEST_COMPRESSION;
95 png_set_compression_level(png_ptr, quality);
98 png_info_init (info_ptr);
102 /* Set up our STL stream output control */
103 png_set_write_fn (png_ptr, stream, &stdstream_write_data, &stdstream_flush_data);