From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Rc04n-0000rE-KL for garchives@archives.gentoo.org; Sat, 17 Dec 2011 19:37:45 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 029B421C126; Sat, 17 Dec 2011 19:37:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B536021C126 for ; Sat, 17 Dec 2011 19:37:37 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C5DDC1B4001 for ; Sat, 17 Dec 2011 19:37:36 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 2265) id 9E77A2004B; Sat, 17 Dec 2011 19:37:35 +0000 (UTC) From: "Chi-Thanh Christopher Nguyen (chithanh)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, chithanh@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in x11-libs/qt-gui/files: qt-gui-4.6-libpng-1.5.patch X-VCS-Repository: gentoo-x86 X-VCS-Files: qt-gui-4.6-libpng-1.5.patch X-VCS-Directories: x11-libs/qt-gui/files X-VCS-Committer: chithanh X-VCS-Committer-Name: Chi-Thanh Christopher Nguyen Content-Type: text/plain; charset=utf8 Message-Id: <20111217193735.9E77A2004B@flycatcher.gentoo.org> Date: Sat, 17 Dec 2011 19:37:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 757996aa-9b42-4506-95c3-733007ea07e1 X-Archives-Hash: 90defe830348f6ca6f37fd467d918171 chithanh 11/12/17 19:37:35 Added: qt-gui-4.6-libpng-1.5.patch Log: Add patch to fix building against libpng-1.5, bug #393141. Non-maintain= er commit, ok'ed by tampakrap on IRC. =20 (Portage version: 2.2.0_alpha79/cvs/Linux x86_64) Revision Changes Path 1.1 x11-libs/qt-gui/files/qt-gui-4.6-libpng-1.5.patch file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-libs/qt-gui/fi= les/qt-gui-4.6-libpng-1.5.patch?rev=3D1.1&view=3Dmarkup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-libs/qt-gui/fi= les/qt-gui-4.6-libpng-1.5.patch?rev=3D1.1&content-type=3Dtext/plain Index: qt-gui-4.6-libpng-1.5.patch =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >From 8a81562af30435f82255830489dca691031a5408 Mon Sep 17 00:00:00 2001 From: aavit Date: Tue, 9 Feb 2010 10:32:04 +0100 Subject: [PATCH] Use libpng API as recommended. Preparation for upgrade t= o libpng 1.4.0. The libpng doc advises against accessing the info_ptr structure directly, and in 1.4.0 the members are flagged as deprecated, so such access gives compilation warnings. This patch makes qpnghandler use the recommended access functions instead. Reviewed-by: Trond --- src/gui/image/qpnghandler.cpp | 135 +++++++++++++++++++----------------= ------ 1 files changed, 62 insertions(+), 73 deletions(-) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cp= p index d5406cb..bba54b9 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -50,8 +50,13 @@ #include #include =20 +#ifdef QT_USE_BUNDLED_LIBPNG +#include <../../3rdparty/libpng/png.h> +#include <../../3rdparty/libpng/pngconf.h> +#else #include #include +#endif =20 #ifdef Q_OS_WINCE #define CALLBACK_CALL_TYPE __cdecl @@ -162,11 +167,16 @@ void setup_qt(QImage& image, png_structp png_ptr, p= ng_infop info_ptr, float scre png_uint_32 height; int bit_depth; int color_type; + png_bytep trans_alpha =3D 0; + png_color_16p trans_color_p =3D 0; + int num_trans; + png_colorp palette =3D 0; + int num_palette; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_= type, 0, 0, 0); =20 if (color_type =3D=3D PNG_COLOR_TYPE_GRAY) { // Black & White or 8-bit grayscale - if (bit_depth =3D=3D 1 && info_ptr->channels =3D=3D 1) { + if (bit_depth =3D=3D 1 && png_get_channels(png_ptr, info_ptr) =3D= =3D 1) { png_set_invert_mono(png_ptr); png_read_update_info(png_ptr, info_ptr); if (image.size() !=3D QSize(width, height) || image.format()= !=3D QImage::Format_Mono) { @@ -207,20 +217,16 @@ void setup_qt(QImage& image, png_structp png_ptr, p= ng_infop info_ptr, float scre int c =3D i*255/(ncols-1); image.setColor(i, qRgba(c,c,c,0xff)); } - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { -#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR =3D=3D 1 && PNG_LI= BPNG_VER_MINOR < 4) - const int g =3D info_ptr->trans_values.gray; -#else - const int g =3D info_ptr->trans_color.gray; -#endif + if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans= , &trans_color_p) && trans_color_p) { + const int g =3D trans_color_p->gray; if (g < ncols) { image.setColor(g, 0); } } } } else if (color_type =3D=3D PNG_COLOR_TYPE_PALETTE - && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE) - && info_ptr->num_palette <=3D 256) + && png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette= ) + && num_palette <=3D 256) { // 1-bit and 8-bit color if (bit_depth !=3D 1) @@ -233,29 +239,26 @@ void setup_qt(QImage& image, png_structp png_ptr, p= ng_infop info_ptr, float scre if (image.isNull()) return; } - image.setColorCount(info_ptr->num_palette); + png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); + image.setColorCount(num_palette); int i =3D 0; - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - while (i < info_ptr->num_trans) { + if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &t= rans_color_p) && trans_alpha) { + while (i < num_trans) { image.setColor(i, qRgba( - info_ptr->palette[i].red, - info_ptr->palette[i].green, - info_ptr->palette[i].blue, -#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR =3D=3D 1 && PNG_LI= BPNG_VER_MINOR < 4) - info_ptr->trans[i] -#else - info_ptr->trans_alpha[i] -#endif + palette[i].red, + palette[i].green, + palette[i].blue, + trans_alpha[i] ) ); i++; } } - while (i < info_ptr->num_palette) { + while (i < num_palette) { image.setColor(i, qRgba( - info_ptr->palette[i].red, - info_ptr->palette[i].green, - info_ptr->palette[i].blue, + palette[i].red, + palette[i].green, + palette[i].blue, 0xff ) ); @@ -531,33 +534,36 @@ QImage::Format QPngHandlerPrivate::readImageFormat(= ) QImage::Format format =3D QImage::Format_Invalid; png_uint_32 width, height; int bit_depth, color_type; - if (info_ptr->color_type =3D=3D PNG_COLOR_TYPE_GRAY) { + png_colorp palette; + int num_palette; + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &co= lor_type, 0, 0, 0); + if (color_type =3D=3D PNG_COLOR_TYPE_GRAY) { // Black & White or 8-bit grayscale - if (info_ptr->bit_depth =3D=3D 1 && info_ptr->channels =3D=3D= 1) { + if (bit_depth =3D=3D 1 && png_get_channels(png_ptr, info_ptr= ) =3D=3D 1) { format =3D QImage::Format_Mono; - } else if (info_ptr->bit_depth =3D=3D 16 && png_get_valid(pn= g_ptr, info_ptr, PNG_INFO_tRNS)) { + } else if (bit_depth =3D=3D 16 && png_get_valid(png_ptr, inf= o_ptr, PNG_INFO_tRNS)) { format =3D QImage::Format_ARGB32; } else { format =3D QImage::Format_Indexed8; } - } else if (info_ptr->color_type =3D=3D PNG_COLOR_TYPE_PALETTE - && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE) - && info_ptr->num_palette <=3D 256) + } else if (color_type =3D=3D PNG_COLOR_TYPE_PALETTE + && png_get_PLTE(png_ptr, info_ptr, &palette, &num_pal= ette) + && num_palette <=3D 256) { // 1-bit and 8-bit color - if (info_ptr->bit_depth !=3D 1) + if (bit_depth !=3D 1) png_set_packing(png_ptr); png_read_update_info(png_ptr, info_ptr); png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,= &color_type, 0, 0, 0); format =3D bit_depth =3D=3D 1 ? QImage::Format_Mono : QImage= ::Format_Indexed8; } else { // 32-bit - if (info_ptr->bit_depth =3D=3D 16) + if (bit_depth =3D=3D 16) png_set_strip_16(png_ptr); =20 format =3D QImage::Format_ARGB32; // Only add filler if no alpha, or we can get 5 channel data= . - if (!(info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + if (!(color_type & PNG_COLOR_MASK_ALPHA) && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { // We want 4 bytes, but it isn't an alpha channel format =3D QImage::Format_RGB32; @@ -648,7 +654,7 @@ static void set_text(const QImage &image, png_structp= png_ptr, png_infop info_pt text_ptr[i].text =3D qstrdup(value.constData()); text_ptr[i].text_length =3D 0; text_ptr[i].itxt_length =3D value.size(); - text_ptr[i].lang =3D "UTF-8"; + text_ptr[i].lang =3D const_cast("UTF-8"); text_ptr[i].lang_key =3D qstrdup(it.key().toUtf8().constData()); #endif ++i; @@ -735,64 +741,51 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::write= Image(const QImage& image_in, png_set_compression_level(png_ptr, quality); } =20 - if (gamma !=3D 0.0) { - png_set_gAMA(png_ptr, info_ptr, 1.0/gamma); - } - png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn)= ; =20 - info_ptr->channels =3D - (image.depth() =3D=3D 32) - ? (image.format() =3D=3D QImage::Format_RGB32 ? 3 : 4) - : 1; - png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(), image.depth() =3D=3D 1 ? 1 : 8 /* per channel */, image.depth() =3D=3D 32 ? image.format() =3D=3D QImage::Format_RGB32 ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA - : PNG_COLOR_TYPE_PALETTE, 0, 0, 0); + : PNG_COLOR_TYPE_PALETTE, 0, 0, 0); // also sets #channels =20 + if (gamma !=3D 0.0) { + png_set_gAMA(png_ptr, info_ptr, 1.0/gamma); + } =20 - //png_set_sBIT(png_ptr, info_ptr, 8); - info_ptr->sig_bit.red =3D 8; - info_ptr->sig_bit.green =3D 8; - info_ptr->sig_bit.blue =3D 8; + png_color_8 sig_bit; + sig_bit.red =3D 8; + sig_bit.green =3D 8; + sig_bit.blue =3D 8; + sig_bit.alpha =3D image.hasAlphaChannel() ? 8 : 0; + png_set_sBIT(png_ptr, info_ptr, &sig_bit); =20 if (image.format() =3D=3D QImage::Format_MonoLSB) png_set_packswap(png_ptr); =20 - png_colorp palette =3D 0; - png_bytep copy_trans =3D 0; if (image.colorCount()) { // Paletted int num_palette =3D image.colorCount(); - palette =3D new png_color[num_palette]; - png_set_PLTE(png_ptr, info_ptr, palette, num_palette); - int* trans =3D new int[num_palette]; + png_color palette[num_palette]; + png_byte trans[num_palette]; int num_trans =3D 0; for (int i=3D0; ipalette[i].red =3D qRed(rgb); - info_ptr->palette[i].green =3D qGreen(rgb); - info_ptr->palette[i].blue =3D qBlue(rgb); - trans[i] =3D rgb >> 24; + QRgb rgba=3Dimage.color(i); + palette[i].red =3D qRed(rgba); + palette[i].green =3D qGreen(rgba); + palette[i].blue =3D qBlue(rgba); + trans[i] =3D qAlpha(rgba); if (trans[i] < 255) { num_trans =3D i+1; } } + png_set_PLTE(png_ptr, info_ptr, palette, num_palette); + if (num_trans) { - copy_trans =3D new png_byte[num_trans]; - for (int i=3D0; isig_bit.alpha =3D 8; } =20 // Swap ARGB to RGBA (normal PNG format) before saving on @@ -868,11 +861,6 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeI= mage(const QImage& image_in, png_write_end(png_ptr, info_ptr); frames_written++; =20 - if (palette) - delete [] palette; - if (copy_trans) - delete [] copy_trans; - png_destroy_write_struct(&png_ptr, &info_ptr); =20 return true; @@ -958,7 +946,8 @@ QVariant QPngHandler::option(ImageOption option) cons= t else if (option =3D=3D Description) return d->description; else if (option =3D=3D Size) - return QSize(d->info_ptr->width, d->info_ptr->height); + return QSize(png_get_image_width(d->png_ptr, d->info_ptr), + png_get_image_height(d->png_ptr, d->info_ptr)); else if (option =3D=3D ImageFormat) return d->readImageFormat(); return 0; --=20 1.6.1