]> git.pld-linux.org Git - packages/exact-image.git/blob - exactimage_0.8.5-1.patch
try some PNG 1.5 patch available
[packages/exact-image.git] / exactimage_0.8.5-1.patch
1 --- exactimage-0.8.5.orig/codecs/png.cc
2 +++ exactimage-0.8.5/codecs/png.cc
3 @@ -17,6 +17,7 @@
4  
5  #include <stdlib.h>
6  #include <png.h>
7 +#include <zlib.h>
8  
9  #include <iostream>
10  
11 @@ -58,7 +59,7 @@ int PNGCodec::readImage (std::istream* s
12    png_structp png_ptr;
13    png_infop info_ptr;
14    png_uint_32 width, height;
15 -  int bit_depth, color_type, interlace_type;
16 +  int bit_depth, color_type, interlace_type, num_trans;
17    
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);
26      return 0;
27    }
28    
29 @@ -82,7 +83,7 @@ int PNGCodec::readImage (std::istream* s
30    
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 */
36      return 0;
37    }
38 @@ -99,13 +100,13 @@ int PNGCodec::readImage (std::istream* s
39    png_read_info (png_ptr, info_ptr);
40    
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);
44    
45    image.w = width;
46    image.h = height;
47    image.bps = bit_depth;
48 -  image.spp = info_ptr->channels;
49 -  
50 +  image.spp = png_get_channels(png_ptr, info_ptr);
51 +
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);
58  
59 +  png_get_tRNS(png_ptr, info_ptr, NULL, &num_trans, NULL);
60 +
61    /* Expand paletted colors into true RGB triplets */
62    if (color_type == PNG_COLOR_TYPE_PALETTE) {
63      png_set_palette_to_rgb(png_ptr);
64      image.bps = 8;
65 -    if (info_ptr->num_trans)
66 +    if (num_trans)
67        image.spp = 4;
68      else
69        image.spp = 3;
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);
76      }
77    
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);
81    
82    /* that's it */
83    return true;
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);
90      return false;
91    }
92    
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);
96    
97 +  /* Need?
98    png_info_init (info_ptr);
99 -  
100 +  */
101 +
102    /* Set up our STL stream output control */ 
103    png_set_write_fn (png_ptr, stream, &stdstream_write_data, &stdstream_flush_data);
104    
This page took 0.105647 seconds and 3 git commands to generate.