blob: bddd251698de0adf6dee8cda0b7b6eba89e72686 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
--- ccp4mg-utils/ppmutil.cc
+++ ccp4mg-utils/ppmutil.cc
@@ -2494,15 +2494,21 @@
pixels = new unsigned char[width*height*colourspace];
+ png_colorp palette;
+ int num_trans;
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >=4
+ png_bytep trans_alpha;
+#endif
+
for (int i=0; i<height; i++){
if(color_type==PNG_COLOR_TYPE_PALETTE){
for (int j=0; j<width; j++){
- pixels[i*width*colourspace+j*colourspace] = png_ptr->palette[row_pointers[i][j]].red;
- pixels[i*width*colourspace+j*colourspace+1] = png_ptr->palette[row_pointers[i][j]].green;
- pixels[i*width*colourspace+j*colourspace+2] = png_ptr->palette[row_pointers[i][j]].blue;
- if(row_pointers[i][j]<png_ptr->num_trans){
+ pixels[i*width*colourspace+j*colourspace] = palette[row_pointers[i][j]].red;
+ pixels[i*width*colourspace+j*colourspace+1] = palette[row_pointers[i][j]].green;
+ pixels[i*width*colourspace+j*colourspace+2] = palette[row_pointers[i][j]].blue;
+ if(row_pointers[i][j]<num_trans){
#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >=4
- pixels[i*width*colourspace+j*colourspace+3] = png_ptr->trans_alpha[row_pointers[i][j]];
+ pixels[i*width*colourspace+j*colourspace+3] = trans_alpha[row_pointers[i][j]];
#else
pixels[i*width*colourspace+j*colourspace+3] = png_ptr->trans[row_pointers[i][j]];
#endif
|