diff options
author | Samuli Suominen <ssuominen@gentoo.org> | 2011-09-17 19:03:45 +0000 |
---|---|---|
committer | Samuli Suominen <ssuominen@gentoo.org> | 2011-09-17 19:03:45 +0000 |
commit | 99ec45f2f24f5ba788e4df0bdccfee619cab6048 (patch) | |
tree | 167a8cff6f34fa0d2486f813982b76589df6594c /net-im/amsn | |
parent | [bump] dev-perl/Audio-Scan-0.930.0 (diff) | |
download | historical-99ec45f2f24f5ba788e4df0bdccfee619cab6048.tar.gz historical-99ec45f2f24f5ba788e4df0bdccfee619cab6048.tar.bz2 historical-99ec45f2f24f5ba788e4df0bdccfee619cab6048.zip |
Fix building with libpng15 wrt #383209 by Diego Elio Pettenò
Package-Manager: portage-2.2.0_alpha55/cvs/Linux x86_64
Diffstat (limited to 'net-im/amsn')
-rw-r--r-- | net-im/amsn/ChangeLog | 6 | ||||
-rw-r--r-- | net-im/amsn/Manifest | 17 | ||||
-rw-r--r-- | net-im/amsn/amsn-0.98.4-r1.ebuild | 8 | ||||
-rw-r--r-- | net-im/amsn/files/amsn-0.98.4-libpng15.patch | 471 |
4 files changed, 488 insertions, 14 deletions
diff --git a/net-im/amsn/ChangeLog b/net-im/amsn/ChangeLog index e93cdcc08e5d..e2cb6eafb7f8 100644 --- a/net-im/amsn/ChangeLog +++ b/net-im/amsn/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for net-im/amsn # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-im/amsn/ChangeLog,v 1.104 2011/04/28 15:42:27 signals Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-im/amsn/ChangeLog,v 1.105 2011/09/17 19:03:45 ssuominen Exp $ + + 17 Sep 2011; Samuli Suominen <ssuominen@gentoo.org> amsn-0.98.4-r1.ebuild, + +files/amsn-0.98.4-libpng15.patch: + Fix building with libpng15 wrt #383209 by Diego Elio Pettenò *amsn-0.98.4-r1 (28 Apr 2011) diff --git a/net-im/amsn/Manifest b/net-im/amsn/Manifest index 203af19178cc..1624d01f95cc 100644 --- a/net-im/amsn/Manifest +++ b/net-im/amsn/Manifest @@ -6,22 +6,19 @@ AUX amsn-0.97.2-http-fix.patch 771 RMD160 10eb6467d140e84ae8bc1726013b1630b1af78 AUX amsn-0.97_rc1-nostrip.patch 281 RMD160 9276deedc6df1ea49031a11e61b171a7739703b4 SHA1 00e23dae355531073cb5317d64c1a5703b703981 SHA256 309684e00439feaee29240f59b486bbcd895bbfb057da99b1d06c6c57d98929d AUX amsn-0.98-noautoupdate.patch 1371 RMD160 ea2b1ca3dfda02b07be649973d273ec0eccb53a1 SHA1 6d472886ab0d9a218000f17bdcbf4fc143a37baa SHA256 e4ffbe486dd48b72e8a5fda212c76a800b760e2b9dab22c34df280cb544274af AUX amsn-0.98.4-amsnplus-ldflags.patch 452 RMD160 54d0f8c4cfc5b13e225d9fbd3426ad3d5a928613 SHA1 6d9dd12ec2bd2cc35f5e3effa74b00f7405f05ef SHA256 8c91329a99585153e353cfef73601b073337fc2306adeed0725fa7c1e2dccb6b +AUX amsn-0.98.4-libpng15.patch 16533 RMD160 52e068036a76805218663ee4cf4726a59806f30e SHA1 1f048d24dc52bdb8efbecfb275d64717903e5829 SHA256 4b13cf0e00978f72323790ea872a331241145ab4a9ac8649d25a4d07cbe2bab9 AUX amsn-0.98.4-v4l2.patch 850 RMD160 8657bd6e05cb42ebc702e9863274a4755878bb57 SHA1 0838d1e15953cf413351c36fdfcc9e2ee88e709c SHA256 67b2e5c212ba91c5dedb4e82a14cf53ea6f1aa81dd1de879953f8378d66bbbe4 DIST amsn-0.98.3-src.tar.bz2 13275477 RMD160 20f707062da4a5ab1eb6beec49d01dfd2ba90a99 SHA1 aa8383a11ce66352aceee27f9c291c1410b3403d SHA256 43b76da9d886fd2cdcf8a7e21c9872141228a2ad1defaca8ad537722a32e0d88 DIST amsn-0.98.4-src.tar.bz2 13513233 RMD160 8e0c3bdde902540fe759b01978447cc60d8fbeb3 SHA1 e00761c945ad47e0b715c69f1f9f18f5a4bf287c SHA256 7aa11a7199b4cda5e814493dd160915ab4c4f96c04de2c1fe7c2fe23eeaba871 EBUILD amsn-0.98.3.ebuild 1879 RMD160 740fc499d88e512c1a4256b349e455f0bab3c376 SHA1 16ab6050e4f31a396d0e6b67904e07745555352b SHA256 a84fa8b1a7fca24448ced62a3af7cb504221c1d0975a8b3244497bed2ffd959a -EBUILD amsn-0.98.4-r1.ebuild 2135 RMD160 44ad02ff2976f4e1212cd265d877201d511b0bc8 SHA1 84801b01007f5ad5a1ce058c79510f835f9a5ab1 SHA256 97b44bd30e1a519dc9126d177de1721b6dc291eca0a33d8e780de6fb69ec386e +EBUILD amsn-0.98.4-r1.ebuild 2187 RMD160 c710ac25e012c85c602c19dc31def29deb9cbc43 SHA1 b4f11b0d16c33828e57b7553a88b1b52567e683e SHA256 b708b2eaf92e27669a484ffd0abb7165c0485c0ea54c6087ff89deb75aadace5 EBUILD amsn-0.98.4.ebuild 1878 RMD160 7fe60ce2b5fe1f6851fcaf9cf75820e1327f6868 SHA1 251b1397d1a7512c28fb303eec46506472acd2de SHA256 d66257d76d87cde3d1e2ace8b313bdc226d7de2a3bca8f930b9e07bfb3c6d87b -MISC ChangeLog 13304 RMD160 93c3807553ee6fc9fa172949d231f400cde5a92c SHA1 0c818c1c635999d8444c5ff1ae24f9330bc8f6c2 SHA256 1dd3da9c62f26ba6dac7dbe6b8907dd66b555914effc5fca564041de2acbf263 +MISC ChangeLog 13485 RMD160 bfc7585fc10e526183ef7f1b0e0713679e02cb42 SHA1 b9c249f06b3cd9425502fdfc0707073039f17af7 SHA256 97e39a4aa245a3972e2872e2c3f8c23b5447f5930b21998f5c0330a3d974fd52 MISC metadata.xml 228 RMD160 d75298dd38147e4c60991454366d6d9cc14985bb SHA1 9f2cadd0fee8f845e833c429f3e6d3a4e2a207b4 SHA256 0ca6e1352c0e4284a99ed8f0267b6835a5e33e2d8b94a08f1af6ad58fd72d942 -----BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.17 (GNU/Linux) +Version: GnuPG v2.0.18 (GNU/Linux) -iQEcBAEBCAAGBQJNuYrsAAoJEMxKBLrQri3oeSsH/3MVpxarLNsWQUGxDu2aOOEa -BvpLtB91x2yfYkP6WSr4iYFR0ZCpG5t2S7hzvM+vTsDk7KcLdoX0R+uILzUMeUoZ -2WqdpNB5wxHtfIL5RtnO483hyAK9b1M61Z2MTp0LWV85J3RJjmXOMh88o8igqwwV -cbjro9DFgjCzyxX3O0p2OlgcIuYzsKfIIQgqscTbVI50rUJpGYARBJY7J2tgIh3/ -WqX87Jf1aPCjLLsZsQRikEQnhjki8+FnjiosgKGNZzK8aalKF5aqyjwdcltdODPx -/coLwjeA2R8fT4DDhGJNB7mhngGcKuQ5VvEOLHlutW60d7Ta7hWcHmjTDtu32mk= -=hSTv +iF4EAREIAAYFAk50700ACgkQXkR9YqOcLPHn0gD9H/+N3rkvxZk0K0TWQlPrO444 +fRkOSxnxUWP5c+mlqY8A/ii5t49C3aBpga4aqkhReDgqQSgT9foFkKfouW2rkudO +=v7QA -----END PGP SIGNATURE----- diff --git a/net-im/amsn/amsn-0.98.4-r1.ebuild b/net-im/amsn/amsn-0.98.4-r1.ebuild index 93d8238468f1..2d46ec7103ef 100644 --- a/net-im/amsn/amsn-0.98.4-r1.ebuild +++ b/net-im/amsn/amsn-0.98.4-r1.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-im/amsn/amsn-0.98.4-r1.ebuild,v 1.1 2011/04/28 15:42:27 signals Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-im/amsn/amsn-0.98.4-r1.ebuild,v 1.2 2011/09/17 19:03:45 ssuominen Exp $ EAPI=2 @@ -41,9 +41,11 @@ RDEPEND="${DEPEND} # >=media-plugins/gst-plugins-ffmpeg-0.10.7 src_prepare() { - epatch "${FILESDIR}/${PN}-0.98-noautoupdate.patch" \ + epatch \ + "${FILESDIR}"/${PN}-0.98-noautoupdate.patch \ "${FILESDIR}"/${PN}-0.98.4-v4l2.patch \ - "${FILESDIR}"/${PN}-0.98.4-amsnplus-ldflags.patch + "${FILESDIR}"/${PN}-0.98.4-amsnplus-ldflags.patch \ + "${FILESDIR}"/${PN}-0.98.4-libpng15.patch # only portage should strip files, bug 285682 sed -i -e "s/LDFLAGS += -s/LDFLAGS += /" Makefile.in || die "sed failed" # Ships with a 32-bit binary, we want to rebuild it diff --git a/net-im/amsn/files/amsn-0.98.4-libpng15.patch b/net-im/amsn/files/amsn-0.98.4-libpng15.patch new file mode 100644 index 000000000000..24f875d02d09 --- /dev/null +++ b/net-im/amsn/files/amsn-0.98.4-libpng15.patch @@ -0,0 +1,471 @@ +--- utils/TkCximage/src/CxImage/ximapng.cpp ++++ utils/TkCximage/src/CxImage/ximapng.cpp +@@ -15,7 +15,7 @@ + void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message) + { + strcpy(info.szLastError,message); +- longjmp(png_ptr->jmpbuf, 1); ++ longjmp(png_jmpbuf(png_ptr), 1); + } + //////////////////////////////////////////////////////////////////////////////// + #if CXIMAGE_SUPPORT_DECODE +@@ -62,7 +62,7 @@ + /* Set error handling if you are using the setjmp/longjmp method (this is + * the normal method of doing things with libpng). REQUIRED unless you + * set up your own error handlers in the png_create_read_struct() earlier. */ +- if (setjmp(png_ptr->jmpbuf)) { ++ if (setjmp(png_jmpbuf(png_ptr))) { + /* Free all of the memory associated with the png_ptr and info_ptr */ + delete [] row_pointers; + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); +@@ -77,15 +77,15 @@ + png_read_info(png_ptr, info_ptr); + + if (info.nEscape == -1){ +- head.biWidth = info_ptr->width; +- head.biHeight= info_ptr->height; ++ head.biWidth = png_get_image_width(png_ptr, info_ptr); ++ head.biHeight= png_get_image_height(png_ptr, info_ptr); + info.dwType = CXIMAGE_FORMAT_PNG; +- longjmp(png_ptr->jmpbuf, 1); ++ longjmp(png_jmpbuf(png_ptr), 1); + } + + /* calculate new number of channels */ + int channels=0; +- switch(info_ptr->color_type){ ++ switch(png_get_color_type(png_ptr, info_ptr)){ + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_PALETTE: + channels = 1; +@@ -101,71 +101,76 @@ + break; + default: + strcpy(info.szLastError,"unknown PNG color type"); +- longjmp(png_ptr->jmpbuf, 1); ++ longjmp(png_jmpbuf(png_ptr), 1); + } + + //find the right pixel depth used for cximage +- int pixel_depth = info_ptr->pixel_depth; ++#if MIGHT_BE_BUGGY ++ int pixel_depth = png_get_pixel_depth(png_ptr, info_ptr); + if (channels == 1 && pixel_depth>8) pixel_depth=8; ++#endif ++ int pixel_depth; ++ if (channels == 1) pixel_depth=8; + if (channels == 2) pixel_depth=8; + if (channels >= 3) pixel_depth=24; + +- if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){ +- longjmp(png_ptr->jmpbuf, 1); ++ if (!Create(png_get_image_width(png_ptr, info_ptr), png_get_image_height(png_ptr, info_ptr), pixel_depth, CXIMAGE_FORMAT_PNG)){ ++ longjmp(png_jmpbuf(png_ptr), 1); + } + + /* get metrics */ +- switch (info_ptr->phys_unit_type) ++ png_uint_32 res_x, res_y; ++ int unit_type; ++ png_get_pHYs_dpi(png_ptr, info_ptr, &res_x, &res_y, &unit_type); ++ switch (unit_type) + { + case PNG_RESOLUTION_UNKNOWN: +- SetXDPI(info_ptr->x_pixels_per_unit); +- SetYDPI(info_ptr->y_pixels_per_unit); ++ SetXDPI(res_x); ++ SetYDPI(res_y); + break; + case PNG_RESOLUTION_METER: +- SetXDPI((long)floor(info_ptr->x_pixels_per_unit * 254.0 / 10000.0 + 0.5)); +- SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5)); ++ SetXDPI((long)floor(res_x * 254.0 / 10000.0 + 0.5)); ++ SetYDPI((long)floor(res_y * 254.0 / 10000.0 + 0.5)); + break; + } + +- if (info_ptr->num_palette>0){ +- SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette); +- SetClrImportant(info_ptr->num_palette); +- } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs ++ png_colorp palette; ++ int num_palette; ++ png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); ++ if (num_palette>0){ ++ SetPalette((rgb_color*)palette,num_palette); ++ SetClrImportant(num_palette); ++ } else if (png_get_bit_depth(png_ptr, info_ptr) ==2) { //<DP> needed for 2 bpp grayscale PNGs + SetPaletteColor(0,0,0,0); + SetPaletteColor(1,85,85,85); + SetPaletteColor(2,170,170,170); + SetPaletteColor(3,255,255,255); + } else SetGrayPalette(); //<DP> needed for grayscale PNGs + +- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3; ++ int nshift = max(0,(png_get_bit_depth(png_ptr, info_ptr)>>3)-1)<<3; + +- if (info_ptr->num_trans!=0){ //palette transparency +- if (info_ptr->num_trans==1){ +- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){ +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- info.nBkgndIndex = info_ptr->trans_color.index; +-#else +- info.nBkgndIndex = info_ptr->trans_values.index; +-#endif ++png_uint_32 png_get_tRNS (png_const_structp png_ptr, png_infop ++info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p ++*trans_color); ++ png_bytep trans_alpha; ++ int num_trans; ++ png_color_16p trans_color; ++ png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color); ++ if (num_trans!=0){ //palette transparency ++ if (num_trans==1){ ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE){ ++ info.nBkgndIndex = trans_color->index; + } else{ +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- info.nBkgndIndex = info_ptr->trans_color.gray>>nshift; +-#else +- info.nBkgndIndex = info_ptr->trans_values.gray>>nshift; +-#endif ++ info.nBkgndIndex = trans_color->gray>>nshift; + } + } +- if (info_ptr->num_trans>1){ ++ if (num_trans>1){ + RGBQUAD* pal=GetPalette(); + if (pal){ + DWORD ip; +- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++) +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- pal[ip].rgbReserved=info_ptr->trans_alpha[ip]; +-#else +- pal[ip].rgbReserved=info_ptr->trans[ip]; +-#endif +- for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){ ++ for (ip=0;ip<min(head.biClrUsed,(unsigned long)num_trans);ip++) ++ pal[ip].rgbReserved=trans_alpha[ip]; ++ for (ip=num_trans;ip<head.biClrUsed;ip++){ + pal[ip].rgbReserved=255; + } + info.bAlphaPaletteEnabled=true; +@@ -178,15 +183,9 @@ + int num_trans; + png_color_16 *image_background; + if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){ +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift); +- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift); +- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift); +-#else +- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift); +- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift); +- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_values.blue>>nshift); +-#endif ++ info.nBkgndColor.rgbRed = (BYTE)(trans_color->red>>nshift); ++ info.nBkgndColor.rgbGreen = (BYTE)(trans_color->green>>nshift); ++ info.nBkgndColor.rgbBlue = (BYTE)(trans_color->blue>>nshift); + info.nBkgndColor.rgbReserved = 0; + info.nBkgndIndex = 0; + } +@@ -202,15 +201,15 @@ + } + + // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA) +- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){ ++ if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR){ + png_set_bgr(png_ptr); + } + + // <vho> - handle cancel +- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1); ++ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1); + + // row_bytes is the width x number of channels x (bit-depth / 8) +- row_pointers = new BYTE[info_ptr->rowbytes + 8]; ++ row_pointers = new BYTE[png_get_rowbytes(png_ptr, info_ptr) + 8]; + + // turn on interlace handling + int number_passes = png_set_interlace_handling(png_ptr); +@@ -221,8 +220,10 @@ + SetCodecOption(0); + } + +- int chan_offset = info_ptr->bit_depth >> 3; +- int pixel_offset = info_ptr->pixel_depth >> 3; ++ int bit_depth = png_get_bit_depth(png_ptr, info_ptr); ++ int chan_offset = bit_depth >> 3; ++ //int pixel_offset = info_ptr->pixel_depth >> 3; ++ int pixel_offset = (bit_depth * channels) >> 3; + + for (int pass=0; pass < number_passes; pass++) { + iter.Upset(); +@@ -230,7 +231,7 @@ + do { + + // <vho> - handle cancel +- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1); ++ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1); + + #if CXIMAGE_SUPPORT_ALPHA // <vho> + if (AlphaIsValid()) { +@@ -241,7 +242,7 @@ + BYTE* prow= iter.GetRow(ay); + + //recover data from previous scan +- if (info_ptr->interlace_type && pass>0 && pass!=7){ ++ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0 && pass!=7){ + for(ax=0;ax<head.biWidth;ax++){ + long px = ax * pixel_offset; + if (channels == 2){ +@@ -278,10 +279,10 @@ + #endif // CXIMAGE_SUPPORT_ALPHA // vho + { + //recover data from previous scan +- if (info_ptr->interlace_type && pass>0){ +- iter.GetRow(row_pointers, info_ptr->rowbytes); ++ if (png_get_interlace_type(png_ptr, info_ptr) && pass>0){ ++ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr)); + //re-expand buffer for images with bit depth > 8 +- if (info_ptr->bit_depth > 8){ ++ if (png_get_bit_depth(png_ptr, info_ptr) > 8){ + for(long ax=(head.biWidth*channels-1);ax>=0;ax--) + row_pointers[ax*chan_offset] = row_pointers[ax]; + } +@@ -291,15 +292,15 @@ + png_read_row(png_ptr, row_pointers, NULL); + + //shrink 16 bit depth images down to 8 bits +- if (info_ptr->bit_depth > 8){ ++ if (png_get_bit_depth(png_ptr, info_ptr) > 8){ + for(long ax=0;ax<(head.biWidth*channels);ax++) + row_pointers[ax] = row_pointers[ax*chan_offset]; + } + + //copy the pixels +- iter.SetRow(row_pointers, info_ptr->rowbytes); ++ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr, info_ptr)); + //<DP> expand 2 bpp images only in the last pass +- if (info_ptr->bit_depth==2 && pass==(number_passes-1)) ++ if (png_get_bit_depth(png_ptr, info_ptr)==2 && pass==(number_passes-1)) + expand2to4bpp(iter.GetRow()); + + //go on +@@ -340,6 +341,11 @@ + BYTE trans[256]; //for transparency (don't move) + png_struct *png_ptr; + png_info *info_ptr; ++ png_uint_32 width, height; ++ png_byte bit_depth; ++ png_byte color_type; ++ png_byte interlace_type; ++ BYTE channels; + + cx_try + { +@@ -362,9 +368,8 @@ + /* Set error handling. REQUIRED if you aren't supplying your own + * error hadnling functions in the png_create_write_struct() call. + */ +- if (setjmp(png_ptr->jmpbuf)){ ++ if (setjmp(png_jmpbuf(png_ptr))){ + /* If we get here, we had a problem reading the file */ +- if (info_ptr->palette) free(info_ptr->palette); + png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr); + cx_throw("Error saving PNG file"); + } +@@ -376,20 +381,18 @@ + png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data); + + /* set the file information here */ +- info_ptr->width = GetWidth(); +- info_ptr->height = GetHeight(); +- info_ptr->pixel_depth = (BYTE)GetBpp(); +- info_ptr->channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1; +- info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels); +- info_ptr->compression_type = info_ptr->filter_type = 0; +- info_ptr->valid = 0; ++ width = GetWidth(); ++ height = GetHeight(); ++ //pixel_depth = (BYTE)GetBpp(); ++ channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1; ++ bit_depth = (BYTE)(GetBpp()/channels); + + switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){ + case 1: +- info_ptr->interlace_type = PNG_INTERLACE_ADAM7; ++ interlace_type = PNG_INTERLACE_ADAM7; + break; + default: +- info_ptr->interlace_type = PNG_INTERLACE_NONE; ++ interlace_type = PNG_INTERLACE_NONE; + } + + /* set compression level */ +@@ -399,19 +402,19 @@ + + if (GetNumColors()){ + if (bGrayScale){ +- info_ptr->color_type = PNG_COLOR_TYPE_GRAY; ++ color_type = PNG_COLOR_TYPE_GRAY; + } else { +- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; ++ color_type = PNG_COLOR_TYPE_PALETTE; + } + } else { +- info_ptr->color_type = PNG_COLOR_TYPE_RGB; ++ color_type = PNG_COLOR_TYPE_RGB; + } + #if CXIMAGE_SUPPORT_ALPHA + if (AlphaIsValid()){ +- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; +- info_ptr->channels++; +- info_ptr->bit_depth = 8; +- info_ptr->pixel_depth += 8; ++ color_type |= PNG_COLOR_MASK_ALPHA; ++ channels++; ++ bit_depth = 8; ++ //pixel_depth += 8; + } + #endif + +@@ -428,29 +431,21 @@ + /* set metrics */ + png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER); + +- png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth, +- info_ptr->color_type, info_ptr->interlace_type, ++ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, ++ color_type, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + //<DP> simple transparency + if (info.nBkgndIndex >= 0){ +- info_ptr->num_trans = 1; +- info_ptr->valid |= PNG_INFO_tRNS; +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- info_ptr->trans_alpha = trans; +- info_ptr->trans_color.index = (BYTE)info.nBkgndIndex; +- info_ptr->trans_color.red = tc.rgbRed; +- info_ptr->trans_color.green = tc.rgbGreen; +- info_ptr->trans_color.blue = tc.rgbBlue; +- info_ptr->trans_color.gray = info_ptr->trans_color.index; +-#else +- info_ptr->trans = trans; +- info_ptr->trans_values.index = (BYTE)info.nBkgndIndex; +- info_ptr->trans_values.red = tc.rgbRed; +- info_ptr->trans_values.green = tc.rgbGreen; +- info_ptr->trans_values.blue = tc.rgbBlue; +- info_ptr->trans_values.gray = info_ptr->trans_values.index; +-#endif ++ png_color_16 trans_color; ++ ++ trans_color.index = (BYTE)info.nBkgndIndex; ++ trans_color.red = tc.rgbRed; ++ trans_color.green = tc.rgbGreen; ++ trans_color.blue = tc.rgbBlue; ++ trans_color.gray = (BYTE)info.nBkgndIndex; ++ ++ png_set_tRNS(png_ptr, info_ptr, trans, 1, &trans_color); + + // the transparency indexes start from 0 for non grayscale palette + if (!bGrayScale && head.biClrUsed && info.nBkgndIndex) +@@ -459,30 +454,27 @@ + + /* set the palette if there is one */ + if (GetPalette()){ +- if (!bGrayScale){ +- info_ptr->valid |= PNG_INFO_PLTE; +- } +- + int nc = GetClrImportant(); + if (nc==0) nc = GetNumColors(); + + if (info.bAlphaPaletteEnabled){ + for(WORD ip=0; ip<nc;ip++) + trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved; +- info_ptr->num_trans = (WORD)nc; +- info_ptr->valid |= PNG_INFO_tRNS; +-#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4 +- info_ptr->trans_alpha = trans; +-#else +- info_ptr->trans = trans; +-#endif ++ png_set_tRNS(png_ptr, info_ptr, trans, (WORD)nc, NULL); + } + + // copy the palette colors +- info_ptr->palette = new png_color[nc]; +- info_ptr->num_palette = (png_uint_16) nc; +- for (int i=0; i<nc; i++) +- GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); ++ if (!bGrayScale) { ++ png_color *palette; ++ ++ palette = (png_color *)png_malloc(png_ptr, nc*sizeof(palette[0])); ++ for (int i=0; i<nc; i++) ++ GetPaletteColor(i, &palette[i].red, &palette[i].green, &palette[i].blue); ++ png_set_PLTE(png_ptr, info_ptr, palette, nc); ++ png_data_freer(png_ptr, info_ptr, ++ PNG_DESTROY_WILL_FREE_DATA, ++ PNG_FREE_PLTE); ++ } + } + + #if CXIMAGE_SUPPORT_ALPHA // <vho> +@@ -496,8 +488,8 @@ + } } } + #endif // CXIMAGE_SUPPORT_ALPHA // <vho> + +- int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8)); +- info_ptr->rowbytes = row_size; ++ int row_size = max(info.dwEffWidth, png_get_rowbytes(png_ptr, info_ptr)); ++ //info_ptr->rowbytes = row_size; + BYTE *row_pointers = new BYTE[row_size]; + + /* write the file information */ +@@ -515,7 +507,7 @@ + if (AlphaIsValid()){ + for (long ax=head.biWidth-1; ax>=0;ax--){ + c = BlindGetPixelColor(ax,ay); +- int px = ax * info_ptr->channels; ++ int px = ax * png_get_channels(png_ptr, info_ptr); + if (!bGrayScale){ + row_pointers[px++]=c.rgbRed; + row_pointers[px++]=c.rgbGreen; +@@ -530,7 +522,7 @@ + #endif //CXIMAGE_SUPPORT_ALPHA // <vho> + { + iter.GetRow(row_pointers, row_size); +- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP ++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB) //HACK BY OP + RGBtoBGR(row_pointers, row_size); + png_write_row(png_ptr, row_pointers); + } +@@ -547,12 +539,6 @@ + /* It is REQUIRED to call this to finish writing the rest of the file */ + png_write_end(png_ptr, info_ptr); + +- /* if you malloced the palette, free it here */ +- if (info_ptr->palette){ +- delete [] (info_ptr->palette); +- info_ptr->palette = NULL; +- } +- + /* clean up after the write, and free any memory allocated */ + png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr); + +--- utils/TkCximage/src/CxImage/ximapng.h ++++ utils/TkCximage/src/CxImage/ximapng.h +@@ -64,8 +64,8 @@ + + static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg) + { +- strncpy((char*)png_ptr->error_ptr,error_msg,255); +- longjmp(png_ptr->jmpbuf, 1); ++ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255); ++ longjmp(png_jmpbuf(png_ptr), 1); + } + }; + |