Thu Aug 4 23:58:36 2011 UTC ()
Add upstream bug report URL.


(wiz)
diff -r1.9 -r1.10 pkgsrc/chat/amsn/distinfo
diff -r1.3 -r1.4 pkgsrc/chat/amsn/patches/patch-utils_TkCximage_src_CxImage_ximapng.cpp
diff -r1.1 -r1.2 pkgsrc/chat/amsn/patches/patch-utils_TkCximage_src_CxImage_ximapng.h

cvs diff -r1.9 -r1.10 pkgsrc/chat/amsn/Attic/distinfo (switch to unified diff)

--- pkgsrc/chat/amsn/Attic/distinfo 2011/08/01 01:16:50 1.9
+++ pkgsrc/chat/amsn/Attic/distinfo 2011/08/04 23:58:35 1.10
@@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
1$NetBSD: distinfo,v 1.9 2011/08/01 01:16:50 dholland Exp $ 1$NetBSD: distinfo,v 1.10 2011/08/04 23:58:35 wiz Exp $
2 2
3SHA1 (amsn-0.98.3-src.tar.bz2) = aa8383a11ce66352aceee27f9c291c1410b3403d 3SHA1 (amsn-0.98.3-src.tar.bz2) = aa8383a11ce66352aceee27f9c291c1410b3403d
4RMD160 (amsn-0.98.3-src.tar.bz2) = 20f707062da4a5ab1eb6beec49d01dfd2ba90a99 4RMD160 (amsn-0.98.3-src.tar.bz2) = 20f707062da4a5ab1eb6beec49d01dfd2ba90a99
5Size (amsn-0.98.3-src.tar.bz2) = 13275477 bytes 5Size (amsn-0.98.3-src.tar.bz2) = 13275477 bytes
6SHA1 (patch-configure) = ddbd6a9616683c44202a551d734b2c9b10b2e05b 6SHA1 (patch-configure) = ddbd6a9616683c44202a551d734b2c9b10b2e05b
7SHA1 (patch-utils_TkCximage_src_CxImage_ximapng.cpp) = 823904f7b17aff6034339e7873135edb7362b489 7SHA1 (patch-utils_TkCximage_src_CxImage_ximapng.cpp) = fc0e4a13e3d13948240a31c001c525def9d37fe9
8SHA1 (patch-utils_TkCximage_src_CxImage_ximapng.h) = 1d7a1cc0acd397629a0e6b1f83f9fdf943fb6d8a 8SHA1 (patch-utils_TkCximage_src_CxImage_ximapng.h) = 77fec828125c21000252b995cfdaa13116478254

cvs diff -r1.3 -r1.4 pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.cpp (switch to unified diff)

--- pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.cpp 2011/08/01 01:16:50 1.3
+++ pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.cpp 2011/08/04 23:58:36 1.4
@@ -1,462 +1,463 @@ @@ -1,462 +1,463 @@
1$NetBSD: patch-utils_TkCximage_src_CxImage_ximapng.cpp,v 1.3 2011/08/01 01:16:50 dholland Exp $ 1$NetBSD: patch-utils_TkCximage_src_CxImage_ximapng.cpp,v 1.4 2011/08/04 23:58:36 wiz Exp $
2 2
3Fix build with png-1.5. 3Fix build with png-1.5.
 4https://sourceforge.net/tracker/?func=detail&aid=3386428&group_id=54091&atid=472655
4 5
5--- utils/TkCximage/src/CxImage/ximapng.cpp.orig 2010-01-29 09:09:27.000000000 +0000 6--- utils/TkCximage/src/CxImage/ximapng.cpp.orig 2010-01-29 09:09:27.000000000 +0000
6+++ utils/TkCximage/src/CxImage/ximapng.cpp 7+++ utils/TkCximage/src/CxImage/ximapng.cpp
7@@ -15,7 +15,7 @@ 8@@ -15,7 +15,7 @@
8 void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message) 9 void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message)
9 { 10 {
10 strcpy(info.szLastError,message); 11 strcpy(info.szLastError,message);
11- longjmp(png_ptr->jmpbuf, 1); 12- longjmp(png_ptr->jmpbuf, 1);
12+ longjmp(png_jmpbuf(png_ptr), 1); 13+ longjmp(png_jmpbuf(png_ptr), 1);
13 } 14 }
14 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
15 #if CXIMAGE_SUPPORT_DECODE 16 #if CXIMAGE_SUPPORT_DECODE
16@@ -62,7 +62,7 @@ bool CxImagePNG::Decode(CxFile *hFile) 17@@ -62,7 +62,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
17 /* Set error handling if you are using the setjmp/longjmp method (this is 18 /* Set error handling if you are using the setjmp/longjmp method (this is
18 * the normal method of doing things with libpng). REQUIRED unless you 19 * the normal method of doing things with libpng). REQUIRED unless you
19 * set up your own error handlers in the png_create_read_struct() earlier. */ 20 * set up your own error handlers in the png_create_read_struct() earlier. */
20- if (setjmp(png_ptr->jmpbuf)) { 21- if (setjmp(png_ptr->jmpbuf)) {
21+ if (setjmp(png_jmpbuf(png_ptr))) { 22+ if (setjmp(png_jmpbuf(png_ptr))) {
22 /* Free all of the memory associated with the png_ptr and info_ptr */ 23 /* Free all of the memory associated with the png_ptr and info_ptr */
23 delete [] row_pointers; 24 delete [] row_pointers;
24 png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); 25 png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
25@@ -77,15 +77,15 @@ bool CxImagePNG::Decode(CxFile *hFile) 26@@ -77,15 +77,15 @@ bool CxImagePNG::Decode(CxFile *hFile)
26 png_read_info(png_ptr, info_ptr); 27 png_read_info(png_ptr, info_ptr);
27  28
28 if (info.nEscape == -1){ 29 if (info.nEscape == -1){
29- head.biWidth = info_ptr->width; 30- head.biWidth = info_ptr->width;
30- head.biHeight= info_ptr->height; 31- head.biHeight= info_ptr->height;
31+ head.biWidth = png_get_image_width(png_ptr, info_ptr); 32+ head.biWidth = png_get_image_width(png_ptr, info_ptr);
32+ head.biHeight= png_get_image_height(png_ptr, info_ptr); 33+ head.biHeight= png_get_image_height(png_ptr, info_ptr);
33 info.dwType = CXIMAGE_FORMAT_PNG; 34 info.dwType = CXIMAGE_FORMAT_PNG;
34- longjmp(png_ptr->jmpbuf, 1); 35- longjmp(png_ptr->jmpbuf, 1);
35+ longjmp(png_jmpbuf(png_ptr), 1); 36+ longjmp(png_jmpbuf(png_ptr), 1);
36 } 37 }
37  38
38 /* calculate new number of channels */ 39 /* calculate new number of channels */
39 int channels=0; 40 int channels=0;
40- switch(info_ptr->color_type){ 41- switch(info_ptr->color_type){
41+ switch(png_get_color_type(png_ptr, info_ptr)){ 42+ switch(png_get_color_type(png_ptr, info_ptr)){
42 case PNG_COLOR_TYPE_GRAY: 43 case PNG_COLOR_TYPE_GRAY:
43 case PNG_COLOR_TYPE_PALETTE: 44 case PNG_COLOR_TYPE_PALETTE:
44 channels = 1; 45 channels = 1;
45@@ -101,71 +101,76 @@ bool CxImagePNG::Decode(CxFile *hFile) 46@@ -101,71 +101,76 @@ bool CxImagePNG::Decode(CxFile *hFile)
46 break; 47 break;
47 default: 48 default:
48 strcpy(info.szLastError,"unknown PNG color type"); 49 strcpy(info.szLastError,"unknown PNG color type");
49- longjmp(png_ptr->jmpbuf, 1); 50- longjmp(png_ptr->jmpbuf, 1);
50+ longjmp(png_jmpbuf(png_ptr), 1); 51+ longjmp(png_jmpbuf(png_ptr), 1);
51 } 52 }
52  53
53 //find the right pixel depth used for cximage 54 //find the right pixel depth used for cximage
54- int pixel_depth = info_ptr->pixel_depth; 55- int pixel_depth = info_ptr->pixel_depth;
55+#if MIGHT_BE_BUGGY 56+#if MIGHT_BE_BUGGY
56+ int pixel_depth = png_get_pixel_depth(png_ptr, info_ptr); 57+ int pixel_depth = png_get_pixel_depth(png_ptr, info_ptr);
57 if (channels == 1 && pixel_depth>8) pixel_depth=8; 58 if (channels == 1 && pixel_depth>8) pixel_depth=8;
58+#endif 59+#endif
59+ int pixel_depth; 60+ int pixel_depth;
60+ if (channels == 1) pixel_depth=8; 61+ if (channels == 1) pixel_depth=8;
61 if (channels == 2) pixel_depth=8; 62 if (channels == 2) pixel_depth=8;
62 if (channels >= 3) pixel_depth=24; 63 if (channels >= 3) pixel_depth=24;
63  64
64- if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){ 65- if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){
65- longjmp(png_ptr->jmpbuf, 1); 66- longjmp(png_ptr->jmpbuf, 1);
66+ if (!Create(png_get_image_width(png_ptr, info_ptr), png_get_image_height(png_ptr, info_ptr), pixel_depth, CXIMAGE_FORMAT_PNG)){ 67+ if (!Create(png_get_image_width(png_ptr, info_ptr), png_get_image_height(png_ptr, info_ptr), pixel_depth, CXIMAGE_FORMAT_PNG)){
67+ longjmp(png_jmpbuf(png_ptr), 1); 68+ longjmp(png_jmpbuf(png_ptr), 1);
68 } 69 }
69  70
70 /* get metrics */ 71 /* get metrics */
71- switch (info_ptr->phys_unit_type) 72- switch (info_ptr->phys_unit_type)
72+ png_uint_32 res_x, res_y; 73+ png_uint_32 res_x, res_y;
73+ int unit_type; 74+ int unit_type;
74+ png_get_pHYs_dpi(png_ptr, info_ptr, &res_x, &res_y, &unit_type); 75+ png_get_pHYs_dpi(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
75+ switch (unit_type) 76+ switch (unit_type)
76 { 77 {
77 case PNG_RESOLUTION_UNKNOWN: 78 case PNG_RESOLUTION_UNKNOWN:
78- SetXDPI(info_ptr->x_pixels_per_unit); 79- SetXDPI(info_ptr->x_pixels_per_unit);
79- SetYDPI(info_ptr->y_pixels_per_unit); 80- SetYDPI(info_ptr->y_pixels_per_unit);
80+ SetXDPI(res_x); 81+ SetXDPI(res_x);
81+ SetYDPI(res_y); 82+ SetYDPI(res_y);
82 break; 83 break;
83 case PNG_RESOLUTION_METER: 84 case PNG_RESOLUTION_METER:
84- SetXDPI((long)floor(info_ptr->x_pixels_per_unit * 254.0 / 10000.0 + 0.5)); 85- SetXDPI((long)floor(info_ptr->x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
85- SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5)); 86- SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
86+ SetXDPI((long)floor(res_x * 254.0 / 10000.0 + 0.5)); 87+ SetXDPI((long)floor(res_x * 254.0 / 10000.0 + 0.5));
87+ SetYDPI((long)floor(res_y * 254.0 / 10000.0 + 0.5)); 88+ SetYDPI((long)floor(res_y * 254.0 / 10000.0 + 0.5));
88 break; 89 break;
89 } 90 }
90  91
91- if (info_ptr->num_palette>0){ 92- if (info_ptr->num_palette>0){
92- SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette); 93- SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette);
93- SetClrImportant(info_ptr->num_palette); 94- SetClrImportant(info_ptr->num_palette);
94- } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs 95- } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
95+ png_colorp palette; 96+ png_colorp palette;
96+ int num_palette; 97+ int num_palette;
97+ png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); 98+ png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
98+ if (num_palette>0){ 99+ if (num_palette>0){
99+ SetPalette((rgb_color*)palette,num_palette); 100+ SetPalette((rgb_color*)palette,num_palette);
100+ SetClrImportant(num_palette); 101+ SetClrImportant(num_palette);
101+ } else if (png_get_bit_depth(png_ptr, info_ptr) ==2) { //<DP> needed for 2 bpp grayscale PNGs 102+ } else if (png_get_bit_depth(png_ptr, info_ptr) ==2) { //<DP> needed for 2 bpp grayscale PNGs
102 SetPaletteColor(0,0,0,0); 103 SetPaletteColor(0,0,0,0);
103 SetPaletteColor(1,85,85,85); 104 SetPaletteColor(1,85,85,85);
104 SetPaletteColor(2,170,170,170); 105 SetPaletteColor(2,170,170,170);
105 SetPaletteColor(3,255,255,255); 106 SetPaletteColor(3,255,255,255);
106 } else SetGrayPalette(); //<DP> needed for grayscale PNGs 107 } else SetGrayPalette(); //<DP> needed for grayscale PNGs
107  108
108- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3; 109- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
109+ int nshift = max(0,(png_get_bit_depth(png_ptr, info_ptr)>>3)-1)<<3; 110+ int nshift = max(0,(png_get_bit_depth(png_ptr, info_ptr)>>3)-1)<<3;
110  111
111- if (info_ptr->num_trans!=0){ //palette transparency 112- if (info_ptr->num_trans!=0){ //palette transparency
112- if (info_ptr->num_trans==1){ 113- if (info_ptr->num_trans==1){
113- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){ 114- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){
114-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 115-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
115- info.nBkgndIndex = info_ptr->trans_color.index; 116- info.nBkgndIndex = info_ptr->trans_color.index;
116-#else 117-#else
117- info.nBkgndIndex = info_ptr->trans_values.index; 118- info.nBkgndIndex = info_ptr->trans_values.index;
118-#endif 119-#endif
119+png_uint_32 png_get_tRNS (png_const_structp png_ptr, png_infop 120+png_uint_32 png_get_tRNS (png_const_structp png_ptr, png_infop
120+info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p 121+info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p
121+*trans_color); 122+*trans_color);
122+ png_bytep trans_alpha; 123+ png_bytep trans_alpha;
123+ int num_trans; 124+ int num_trans;
124+ png_color_16p trans_color; 125+ png_color_16p trans_color;
125+ png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color); 126+ png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color);
126+ if (num_trans!=0){ //palette transparency 127+ if (num_trans!=0){ //palette transparency
127+ if (num_trans==1){ 128+ if (num_trans==1){
128+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE){ 129+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE){
129+ info.nBkgndIndex = trans_color->index; 130+ info.nBkgndIndex = trans_color->index;
130 } else{ 131 } else{
131-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 132-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
132- info.nBkgndIndex = info_ptr->trans_color.gray>>nshift; 133- info.nBkgndIndex = info_ptr->trans_color.gray>>nshift;
133-#else 134-#else
134- info.nBkgndIndex = info_ptr->trans_values.gray>>nshift; 135- info.nBkgndIndex = info_ptr->trans_values.gray>>nshift;
135-#endif 136-#endif
136+ info.nBkgndIndex = trans_color->gray>>nshift; 137+ info.nBkgndIndex = trans_color->gray>>nshift;
137 } 138 }
138 } 139 }
139- if (info_ptr->num_trans>1){ 140- if (info_ptr->num_trans>1){
140+ if (num_trans>1){ 141+ if (num_trans>1){
141 RGBQUAD* pal=GetPalette(); 142 RGBQUAD* pal=GetPalette();
142 if (pal){ 143 if (pal){
143 DWORD ip; 144 DWORD ip;
144- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++) 145- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
145-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 146-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
146- pal[ip].rgbReserved=info_ptr->trans_alpha[ip]; 147- pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
147-#else 148-#else
148- pal[ip].rgbReserved=info_ptr->trans[ip]; 149- pal[ip].rgbReserved=info_ptr->trans[ip];
149-#endif 150-#endif
150- for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){ 151- for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){
151+ for (ip=0;ip<min(head.biClrUsed,(unsigned long)num_trans);ip++) 152+ for (ip=0;ip<min(head.biClrUsed,(unsigned long)num_trans);ip++)
152+ pal[ip].rgbReserved=trans_alpha[ip]; 153+ pal[ip].rgbReserved=trans_alpha[ip];
153+ for (ip=num_trans;ip<head.biClrUsed;ip++){ 154+ for (ip=num_trans;ip<head.biClrUsed;ip++){
154 pal[ip].rgbReserved=255; 155 pal[ip].rgbReserved=255;
155 } 156 }
156 info.bAlphaPaletteEnabled=true; 157 info.bAlphaPaletteEnabled=true;
157@@ -178,15 +183,9 @@ bool CxImagePNG::Decode(CxFile *hFile) 158@@ -178,15 +183,9 @@ bool CxImagePNG::Decode(CxFile *hFile)
158 int num_trans; 159 int num_trans;
159 png_color_16 *image_background; 160 png_color_16 *image_background;
160 if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){ 161 if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){
161-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 162-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
162- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift); 163- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift);
163- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift); 164- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift);
164- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift); 165- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift);
165-#else 166-#else
166- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift); 167- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift);
167- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift); 168- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift);
168- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_values.blue>>nshift); 169- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_values.blue>>nshift);
169-#endif 170-#endif
170+ info.nBkgndColor.rgbRed = (BYTE)(trans_color->red>>nshift); 171+ info.nBkgndColor.rgbRed = (BYTE)(trans_color->red>>nshift);
171+ info.nBkgndColor.rgbGreen = (BYTE)(trans_color->green>>nshift); 172+ info.nBkgndColor.rgbGreen = (BYTE)(trans_color->green>>nshift);
172+ info.nBkgndColor.rgbBlue = (BYTE)(trans_color->blue>>nshift); 173+ info.nBkgndColor.rgbBlue = (BYTE)(trans_color->blue>>nshift);
173 info.nBkgndColor.rgbReserved = 0; 174 info.nBkgndColor.rgbReserved = 0;
174 info.nBkgndIndex = 0; 175 info.nBkgndIndex = 0;
175 } 176 }
176@@ -202,15 +201,15 @@ bool CxImagePNG::Decode(CxFile *hFile) 177@@ -202,15 +201,15 @@ bool CxImagePNG::Decode(CxFile *hFile)
177 } 178 }
178  179
179 // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA) 180 // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA)
180- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){ 181- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){
181+ if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR){ 182+ if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR){
182 png_set_bgr(png_ptr); 183 png_set_bgr(png_ptr);
183 } 184 }
184  185
185 // <vho> - handle cancel 186 // <vho> - handle cancel
186- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1); 187- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
187+ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1); 188+ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1);
188  189
189 // row_bytes is the width x number of channels x (bit-depth / 8) 190 // row_bytes is the width x number of channels x (bit-depth / 8)
190- row_pointers = new BYTE[info_ptr->rowbytes + 8]; 191- row_pointers = new BYTE[info_ptr->rowbytes + 8];
191+ row_pointers = new BYTE[png_get_rowbytes(png_ptr, info_ptr) + 8]; 192+ row_pointers = new BYTE[png_get_rowbytes(png_ptr, info_ptr) + 8];
192  193
193 // turn on interlace handling 194 // turn on interlace handling
194 int number_passes = png_set_interlace_handling(png_ptr); 195 int number_passes = png_set_interlace_handling(png_ptr);
195@@ -221,8 +220,10 @@ bool CxImagePNG::Decode(CxFile *hFile) 196@@ -221,8 +220,10 @@ bool CxImagePNG::Decode(CxFile *hFile)
196 SetCodecOption(0); 197 SetCodecOption(0);
197 } 198 }
198  199
199- int chan_offset = info_ptr->bit_depth >> 3; 200- int chan_offset = info_ptr->bit_depth >> 3;
200- int pixel_offset = info_ptr->pixel_depth >> 3; 201- int pixel_offset = info_ptr->pixel_depth >> 3;
201+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr); 202+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
202+ int chan_offset = bit_depth >> 3; 203+ int chan_offset = bit_depth >> 3;
203+ //int pixel_offset = info_ptr->pixel_depth >> 3; 204+ //int pixel_offset = info_ptr->pixel_depth >> 3;
204+ int pixel_offset = (bit_depth * channels) >> 3; 205+ int pixel_offset = (bit_depth * channels) >> 3;
205  206
206 for (int pass=0; pass < number_passes; pass++) { 207 for (int pass=0; pass < number_passes; pass++) {
207 iter.Upset(); 208 iter.Upset();
208@@ -230,7 +231,7 @@ bool CxImagePNG::Decode(CxFile *hFile) 209@@ -230,7 +231,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
209 do { 210 do {
210  211
211 // <vho> - handle cancel 212 // <vho> - handle cancel
212- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1); 213- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
213+ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1); 214+ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1);
214  215
215 #if CXIMAGE_SUPPORT_ALPHA // <vho> 216 #if CXIMAGE_SUPPORT_ALPHA // <vho>
216 if (AlphaIsValid()) { 217 if (AlphaIsValid()) {
217@@ -241,7 +242,7 @@ bool CxImagePNG::Decode(CxFile *hFile) 218@@ -241,7 +242,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
218 BYTE* prow= iter.GetRow(ay); 219 BYTE* prow= iter.GetRow(ay);
219  220
220 //recover data from previous scan 221 //recover data from previous scan
221- if (info_ptr->interlace_type && pass>0 && pass!=7){ 222- if (info_ptr->interlace_type && pass>0 && pass!=7){
222+ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0 && pass!=7){ 223+ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0 && pass!=7){
223 for(ax=0;ax<head.biWidth;ax++){ 224 for(ax=0;ax<head.biWidth;ax++){
224 long px = ax * pixel_offset; 225 long px = ax * pixel_offset;
225 if (channels == 2){ 226 if (channels == 2){
226@@ -278,10 +279,10 @@ bool CxImagePNG::Decode(CxFile *hFile) 227@@ -278,10 +279,10 @@ bool CxImagePNG::Decode(CxFile *hFile)
227 #endif // CXIMAGE_SUPPORT_ALPHA // vho 228 #endif // CXIMAGE_SUPPORT_ALPHA // vho
228 { 229 {
229 //recover data from previous scan 230 //recover data from previous scan
230- if (info_ptr->interlace_type && pass>0){ 231- if (info_ptr->interlace_type && pass>0){
231- iter.GetRow(row_pointers, info_ptr->rowbytes); 232- iter.GetRow(row_pointers, info_ptr->rowbytes);
232+ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0){ 233+ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0){
233+ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr)); 234+ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr));
234 //re-expand buffer for images with bit depth > 8 235 //re-expand buffer for images with bit depth > 8
235- if (info_ptr->bit_depth > 8){ 236- if (info_ptr->bit_depth > 8){
236+ if (png_get_bit_depth(png_ptr, info_ptr) > 8){ 237+ if (png_get_bit_depth(png_ptr, info_ptr) > 8){
237 for(long ax=(head.biWidth*channels-1);ax>=0;ax--) 238 for(long ax=(head.biWidth*channels-1);ax>=0;ax--)
238 row_pointers[ax*chan_offset] = row_pointers[ax]; 239 row_pointers[ax*chan_offset] = row_pointers[ax];
239 } 240 }
240@@ -291,15 +292,15 @@ bool CxImagePNG::Decode(CxFile *hFile) 241@@ -291,15 +292,15 @@ bool CxImagePNG::Decode(CxFile *hFile)
241 png_read_row(png_ptr, row_pointers, NULL); 242 png_read_row(png_ptr, row_pointers, NULL);
242  243
243 //shrink 16 bit depth images down to 8 bits 244 //shrink 16 bit depth images down to 8 bits
244- if (info_ptr->bit_depth > 8){ 245- if (info_ptr->bit_depth > 8){
245+ if (png_get_bit_depth(png_ptr, info_ptr) > 8){ 246+ if (png_get_bit_depth(png_ptr, info_ptr) > 8){
246 for(long ax=0;ax<(head.biWidth*channels);ax++) 247 for(long ax=0;ax<(head.biWidth*channels);ax++)
247 row_pointers[ax] = row_pointers[ax*chan_offset]; 248 row_pointers[ax] = row_pointers[ax*chan_offset];
248 } 249 }
249  250
250 //copy the pixels 251 //copy the pixels
251- iter.SetRow(row_pointers, info_ptr->rowbytes); 252- iter.SetRow(row_pointers, info_ptr->rowbytes);
252+ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr)); 253+ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr));
253 //<DP> expand 2 bpp images only in the last pass 254 //<DP> expand 2 bpp images only in the last pass
254- if (info_ptr->bit_depth==2 && pass==(number_passes-1)) 255- if (info_ptr->bit_depth==2 && pass==(number_passes-1))
255+ if (png_get_bit_depth(png_ptr, info_ptr)==2 && pass==(number_passes-1)) 256+ if (png_get_bit_depth(png_ptr, info_ptr)==2 && pass==(number_passes-1))
256 expand2to4bpp(iter.GetRow()); 257 expand2to4bpp(iter.GetRow());
257  258
258 //go on 259 //go on
259@@ -340,6 +341,11 @@ bool CxImagePNG::Encode(CxFile *hFile) 260@@ -340,6 +341,11 @@ bool CxImagePNG::Encode(CxFile *hFile)
260 BYTE trans[256]; //for transparency (don't move) 261 BYTE trans[256]; //for transparency (don't move)
261 png_struct *png_ptr; 262 png_struct *png_ptr;
262 png_info *info_ptr; 263 png_info *info_ptr;
263+ png_uint_32 width, height; 264+ png_uint_32 width, height;
264+ png_byte bit_depth; 265+ png_byte bit_depth;
265+ png_byte color_type; 266+ png_byte color_type;
266+ png_byte interlace_type; 267+ png_byte interlace_type;
267+ BYTE channels; 268+ BYTE channels;
268  269
269 cx_try 270 cx_try
270 { 271 {
271@@ -362,9 +368,8 @@ bool CxImagePNG::Encode(CxFile *hFile) 272@@ -362,9 +368,8 @@ bool CxImagePNG::Encode(CxFile *hFile)
272 /* Set error handling. REQUIRED if you aren't supplying your own 273 /* Set error handling. REQUIRED if you aren't supplying your own
273 * error hadnling functions in the png_create_write_struct() call. 274 * error hadnling functions in the png_create_write_struct() call.
274 */ 275 */
275- if (setjmp(png_ptr->jmpbuf)){ 276- if (setjmp(png_ptr->jmpbuf)){
276+ if (setjmp(png_jmpbuf(png_ptr))){ 277+ if (setjmp(png_jmpbuf(png_ptr))){
277 /* If we get here, we had a problem reading the file */ 278 /* If we get here, we had a problem reading the file */
278- if (info_ptr->palette) free(info_ptr->palette); 279- if (info_ptr->palette) free(info_ptr->palette);
279 png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr); 280 png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
280 cx_throw("Error saving PNG file"); 281 cx_throw("Error saving PNG file");
281 } 282 }
282@@ -376,20 +381,18 @@ bool CxImagePNG::Encode(CxFile *hFile) 283@@ -376,20 +381,18 @@ bool CxImagePNG::Encode(CxFile *hFile)
283 png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data); 284 png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
284  285
285 /* set the file information here */ 286 /* set the file information here */
286- info_ptr->width = GetWidth(); 287- info_ptr->width = GetWidth();
287- info_ptr->height = GetHeight(); 288- info_ptr->height = GetHeight();
288- info_ptr->pixel_depth = (BYTE)GetBpp(); 289- info_ptr->pixel_depth = (BYTE)GetBpp();
289- info_ptr->channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1; 290- info_ptr->channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1;
290- info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels); 291- info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels);
291- info_ptr->compression_type = info_ptr->filter_type = 0; 292- info_ptr->compression_type = info_ptr->filter_type = 0;
292- info_ptr->valid = 0; 293- info_ptr->valid = 0;
293+ width = GetWidth(); 294+ width = GetWidth();
294+ height = GetHeight(); 295+ height = GetHeight();
295+ //pixel_depth = (BYTE)GetBpp(); 296+ //pixel_depth = (BYTE)GetBpp();
296+ channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1; 297+ channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1;
297+ bit_depth = (BYTE)(GetBpp()/channels); 298+ bit_depth = (BYTE)(GetBpp()/channels);
298  299
299 switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){ 300 switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){
300 case 1: 301 case 1:
301- info_ptr->interlace_type = PNG_INTERLACE_ADAM7; 302- info_ptr->interlace_type = PNG_INTERLACE_ADAM7;
302+ interlace_type = PNG_INTERLACE_ADAM7; 303+ interlace_type = PNG_INTERLACE_ADAM7;
303 break; 304 break;
304 default: 305 default:
305- info_ptr->interlace_type = PNG_INTERLACE_NONE; 306- info_ptr->interlace_type = PNG_INTERLACE_NONE;
306+ interlace_type = PNG_INTERLACE_NONE; 307+ interlace_type = PNG_INTERLACE_NONE;
307 } 308 }
308  309
309 /* set compression level */ 310 /* set compression level */
310@@ -399,19 +402,19 @@ bool CxImagePNG::Encode(CxFile *hFile) 311@@ -399,19 +402,19 @@ bool CxImagePNG::Encode(CxFile *hFile)
311  312
312 if (GetNumColors()){ 313 if (GetNumColors()){
313 if (bGrayScale){ 314 if (bGrayScale){
314- info_ptr->color_type = PNG_COLOR_TYPE_GRAY; 315- info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
315+ color_type = PNG_COLOR_TYPE_GRAY; 316+ color_type = PNG_COLOR_TYPE_GRAY;
316 } else { 317 } else {
317- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; 318- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
318+ color_type = PNG_COLOR_TYPE_PALETTE; 319+ color_type = PNG_COLOR_TYPE_PALETTE;
319 } 320 }
320 } else { 321 } else {
321- info_ptr->color_type = PNG_COLOR_TYPE_RGB; 322- info_ptr->color_type = PNG_COLOR_TYPE_RGB;
322+ color_type = PNG_COLOR_TYPE_RGB; 323+ color_type = PNG_COLOR_TYPE_RGB;
323 } 324 }
324 #if CXIMAGE_SUPPORT_ALPHA 325 #if CXIMAGE_SUPPORT_ALPHA
325 if (AlphaIsValid()){ 326 if (AlphaIsValid()){
326- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; 327- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
327- info_ptr->channels++; 328- info_ptr->channels++;
328- info_ptr->bit_depth = 8; 329- info_ptr->bit_depth = 8;
329- info_ptr->pixel_depth += 8; 330- info_ptr->pixel_depth += 8;
330+ color_type |= PNG_COLOR_MASK_ALPHA; 331+ color_type |= PNG_COLOR_MASK_ALPHA;
331+ channels++; 332+ channels++;
332+ bit_depth = 8; 333+ bit_depth = 8;
333+ //pixel_depth += 8; 334+ //pixel_depth += 8;
334 } 335 }
335 #endif 336 #endif
336  337
337@@ -428,29 +431,21 @@ bool CxImagePNG::Encode(CxFile *hFile) 338@@ -428,29 +431,21 @@ bool CxImagePNG::Encode(CxFile *hFile)
338 /* set metrics */ 339 /* set metrics */
339 png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER); 340 png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER);
340  341
341- png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth, 342- png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth,
342- info_ptr->color_type, info_ptr->interlace_type, 343- info_ptr->color_type, info_ptr->interlace_type,
343+ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, 344+ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
344+ color_type, interlace_type, 345+ color_type, interlace_type,
345 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); 346 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
346  347
347 //<DP> simple transparency 348 //<DP> simple transparency
348 if (info.nBkgndIndex >= 0){ 349 if (info.nBkgndIndex >= 0){
349- info_ptr->num_trans = 1; 350- info_ptr->num_trans = 1;
350- info_ptr->valid |= PNG_INFO_tRNS; 351- info_ptr->valid |= PNG_INFO_tRNS;
351-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 352-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
352- info_ptr->trans_alpha = trans; 353- info_ptr->trans_alpha = trans;
353- info_ptr->trans_color.index = (BYTE)info.nBkgndIndex; 354- info_ptr->trans_color.index = (BYTE)info.nBkgndIndex;
354- info_ptr->trans_color.red = tc.rgbRed; 355- info_ptr->trans_color.red = tc.rgbRed;
355- info_ptr->trans_color.green = tc.rgbGreen; 356- info_ptr->trans_color.green = tc.rgbGreen;
356- info_ptr->trans_color.blue = tc.rgbBlue; 357- info_ptr->trans_color.blue = tc.rgbBlue;
357- info_ptr->trans_color.gray = info_ptr->trans_color.index; 358- info_ptr->trans_color.gray = info_ptr->trans_color.index;
358-#else 359-#else
359- info_ptr->trans = trans; 360- info_ptr->trans = trans;
360- info_ptr->trans_values.index = (BYTE)info.nBkgndIndex; 361- info_ptr->trans_values.index = (BYTE)info.nBkgndIndex;
361- info_ptr->trans_values.red = tc.rgbRed; 362- info_ptr->trans_values.red = tc.rgbRed;
362- info_ptr->trans_values.green = tc.rgbGreen; 363- info_ptr->trans_values.green = tc.rgbGreen;
363- info_ptr->trans_values.blue = tc.rgbBlue; 364- info_ptr->trans_values.blue = tc.rgbBlue;
364- info_ptr->trans_values.gray = info_ptr->trans_values.index; 365- info_ptr->trans_values.gray = info_ptr->trans_values.index;
365-#endif 366-#endif
366+ png_color_16 trans_color; 367+ png_color_16 trans_color;
367+ 368+
368+ trans_color.index = (BYTE)info.nBkgndIndex; 369+ trans_color.index = (BYTE)info.nBkgndIndex;
369+ trans_color.red = tc.rgbRed; 370+ trans_color.red = tc.rgbRed;
370+ trans_color.green = tc.rgbGreen; 371+ trans_color.green = tc.rgbGreen;
371+ trans_color.blue = tc.rgbBlue; 372+ trans_color.blue = tc.rgbBlue;
372+ trans_color.gray = (BYTE)info.nBkgndIndex; 373+ trans_color.gray = (BYTE)info.nBkgndIndex;
373+ 374+
374+ png_set_tRNS(png_ptr, info_ptr, trans, 1, &trans_color); 375+ png_set_tRNS(png_ptr, info_ptr, trans, 1, &trans_color);
375  376
376 // the transparency indexes start from 0 for non grayscale palette 377 // the transparency indexes start from 0 for non grayscale palette
377 if (!bGrayScale && head.biClrUsed && info.nBkgndIndex) 378 if (!bGrayScale && head.biClrUsed && info.nBkgndIndex)
378@@ -459,30 +454,27 @@ bool CxImagePNG::Encode(CxFile *hFile) 379@@ -459,30 +454,27 @@ bool CxImagePNG::Encode(CxFile *hFile)
379  380
380 /* set the palette if there is one */ 381 /* set the palette if there is one */
381 if (GetPalette()){ 382 if (GetPalette()){
382- if (!bGrayScale){ 383- if (!bGrayScale){
383- info_ptr->valid |= PNG_INFO_PLTE; 384- info_ptr->valid |= PNG_INFO_PLTE;
384- } 385- }
385- 386-
386 int nc = GetClrImportant(); 387 int nc = GetClrImportant();
387 if (nc==0) nc = GetNumColors(); 388 if (nc==0) nc = GetNumColors();
388  389
389 if (info.bAlphaPaletteEnabled){ 390 if (info.bAlphaPaletteEnabled){
390 for(WORD ip=0; ip<nc;ip++) 391 for(WORD ip=0; ip<nc;ip++)
391 trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved; 392 trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved;
392- info_ptr->num_trans = (WORD)nc; 393- info_ptr->num_trans = (WORD)nc;
393- info_ptr->valid |= PNG_INFO_tRNS; 394- info_ptr->valid |= PNG_INFO_tRNS;
394-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 395-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
395- info_ptr->trans_alpha = trans; 396- info_ptr->trans_alpha = trans;
396-#else 397-#else
397- info_ptr->trans = trans; 398- info_ptr->trans = trans;
398-#endif 399-#endif
399+ png_set_tRNS(png_ptr, info_ptr, trans, (WORD)nc, NULL); 400+ png_set_tRNS(png_ptr, info_ptr, trans, (WORD)nc, NULL);
400 } 401 }
401  402
402 // copy the palette colors 403 // copy the palette colors
403- info_ptr->palette = new png_color[nc]; 404- info_ptr->palette = new png_color[nc];
404- info_ptr->num_palette = (png_uint_16) nc; 405- info_ptr->num_palette = (png_uint_16) nc;
405- for (int i=0; i<nc; i++) 406- for (int i=0; i<nc; i++)
406- GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); 407- GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
407+ if (!bGrayScale) { 408+ if (!bGrayScale) {
408+ png_color *palette; 409+ png_color *palette;
409+ 410+
410+ palette = (png_color *)png_malloc(png_ptr, nc*sizeof(palette[0])); 411+ palette = (png_color *)png_malloc(png_ptr, nc*sizeof(palette[0]));
411+ for (int i=0; i<nc; i++) 412+ for (int i=0; i<nc; i++)
412+ GetPaletteColor(i, &palette[i].red, &palette[i].green, &palette[i].blue); 413+ GetPaletteColor(i, &palette[i].red, &palette[i].green, &palette[i].blue);
413+ png_set_PLTE(png_ptr, info_ptr, palette, nc); 414+ png_set_PLTE(png_ptr, info_ptr, palette, nc);
414+ png_data_freer(png_ptr, info_ptr, 415+ png_data_freer(png_ptr, info_ptr,
415+ PNG_DESTROY_WILL_FREE_DATA, 416+ PNG_DESTROY_WILL_FREE_DATA,
416+ PNG_FREE_PLTE); 417+ PNG_FREE_PLTE);
417+ } 418+ }
418 }  419 }
419  420
420 #if CXIMAGE_SUPPORT_ALPHA // <vho> 421 #if CXIMAGE_SUPPORT_ALPHA // <vho>
421@@ -496,8 +488,8 @@ bool CxImagePNG::Encode(CxFile *hFile) 422@@ -496,8 +488,8 @@ bool CxImagePNG::Encode(CxFile *hFile)
422 } } } 423 } } }
423 #endif // CXIMAGE_SUPPORT_ALPHA // <vho> 424 #endif // CXIMAGE_SUPPORT_ALPHA // <vho>
424  425
425- int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8)); 426- int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
426- info_ptr->rowbytes = row_size; 427- info_ptr->rowbytes = row_size;
427+ int row_size = max(info.dwEffWidth, png_get_rowbytes(png_ptr, info_ptr)); 428+ int row_size = max(info.dwEffWidth, png_get_rowbytes(png_ptr, info_ptr));
428+ //info_ptr->rowbytes = row_size; 429+ //info_ptr->rowbytes = row_size;
429 BYTE *row_pointers = new BYTE[row_size]; 430 BYTE *row_pointers = new BYTE[row_size];
430  431
431 /* write the file information */ 432 /* write the file information */
432@@ -515,7 +507,7 @@ bool CxImagePNG::Encode(CxFile *hFile) 433@@ -515,7 +507,7 @@ bool CxImagePNG::Encode(CxFile *hFile)
433 if (AlphaIsValid()){ 434 if (AlphaIsValid()){
434 for (long ax=head.biWidth-1; ax>=0;ax--){ 435 for (long ax=head.biWidth-1; ax>=0;ax--){
435 c = BlindGetPixelColor(ax,ay); 436 c = BlindGetPixelColor(ax,ay);
436- int px = ax * info_ptr->channels; 437- int px = ax * info_ptr->channels;
437+ int px = ax * png_get_channels(png_ptr, info_ptr); 438+ int px = ax * png_get_channels(png_ptr, info_ptr);
438 if (!bGrayScale){ 439 if (!bGrayScale){
439 row_pointers[px++]=c.rgbRed; 440 row_pointers[px++]=c.rgbRed;
440 row_pointers[px++]=c.rgbGreen; 441 row_pointers[px++]=c.rgbGreen;
441@@ -530,7 +522,7 @@ bool CxImagePNG::Encode(CxFile *hFile) 442@@ -530,7 +522,7 @@ bool CxImagePNG::Encode(CxFile *hFile)
442 #endif //CXIMAGE_SUPPORT_ALPHA // <vho> 443 #endif //CXIMAGE_SUPPORT_ALPHA // <vho>
443 { 444 {
444 iter.GetRow(row_pointers, row_size); 445 iter.GetRow(row_pointers, row_size);
445- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP 446- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
446+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) //HACK BY OP 447+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) //HACK BY OP
447 RGBtoBGR(row_pointers, row_size); 448 RGBtoBGR(row_pointers, row_size);
448 png_write_row(png_ptr, row_pointers); 449 png_write_row(png_ptr, row_pointers);
449 } 450 }
450@@ -547,12 +539,6 @@ bool CxImagePNG::Encode(CxFile *hFile) 451@@ -547,12 +539,6 @@ bool CxImagePNG::Encode(CxFile *hFile)
451 /* It is REQUIRED to call this to finish writing the rest of the file */ 452 /* It is REQUIRED to call this to finish writing the rest of the file */
452 png_write_end(png_ptr, info_ptr); 453 png_write_end(png_ptr, info_ptr);
453  454
454- /* if you malloced the palette, free it here */ 455- /* if you malloced the palette, free it here */
455- if (info_ptr->palette){ 456- if (info_ptr->palette){
456- delete [] (info_ptr->palette); 457- delete [] (info_ptr->palette);
457- info_ptr->palette = NULL; 458- info_ptr->palette = NULL;
458- } 459- }
459- 460-
460 /* clean up after the write, and free any memory allocated */ 461 /* clean up after the write, and free any memory allocated */
461 png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr); 462 png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
462  463

cvs diff -r1.1 -r1.2 pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.h (switch to unified diff)

--- pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.h 2011/04/03 15:26:36 1.1
+++ pkgsrc/chat/amsn/patches/Attic/patch-utils_TkCximage_src_CxImage_ximapng.h 2011/08/04 23:58:36 1.2
@@ -1,17 +1,18 @@ @@ -1,17 +1,18 @@
1$NetBSD: patch-utils_TkCximage_src_CxImage_ximapng.h,v 1.1 2011/04/03 15:26:36 wiz Exp $ 1$NetBSD: patch-utils_TkCximage_src_CxImage_ximapng.h,v 1.2 2011/08/04 23:58:36 wiz Exp $
2 2
3Fix build with png-1.5. 3Fix build with png-1.5.
 4https://sourceforge.net/tracker/?func=detail&aid=3386428&group_id=54091&atid=472655
4 5
5--- utils/TkCximage/src/CxImage/ximapng.h.orig 2008-03-07 19:14:37.000000000 +0000 6--- utils/TkCximage/src/CxImage/ximapng.h.orig 2008-03-07 19:14:37.000000000 +0000
6+++ utils/TkCximage/src/CxImage/ximapng.h 7+++ utils/TkCximage/src/CxImage/ximapng.h
7@@ -64,8 +64,8 @@ protected: 8@@ -64,8 +64,8 @@ protected:
8  9
9 static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg) 10 static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg)
10 { 11 {
11- strncpy((char*)png_ptr->error_ptr,error_msg,255); 12- strncpy((char*)png_ptr->error_ptr,error_msg,255);
12- longjmp(png_ptr->jmpbuf, 1); 13- longjmp(png_ptr->jmpbuf, 1);
13+ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255); 14+ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255);
14+ longjmp(png_jmpbuf(png_ptr), 1); 15+ longjmp(png_jmpbuf(png_ptr), 1);
15 } 16 }
16 }; 17 };
17  18