Fedora17: fix QT3 compîlation with libpng 1.5

pull/3/head
Francois Andriot 13 years ago
parent 28ef328815
commit d1ebf8d7fb

@ -0,0 +1,276 @@
commit e278b858739babff5cc19ca81a661e1256d162e7
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date: 1326063972 -0600
Fix Qt3 builds with libpng15
This partially closes Bug 683
diff --git a/src/kernel/qpngio.cpp b/src/kernel/qpngio.cpp
index 25ce927..58e6e7e 100644
--- a/src/kernel/qpngio.cpp
+++ b/src/kernel/qpngio.cpp
@@ -46,6 +46,9 @@
#include "qiodevice.h"
#include <png.h>
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+#include <zlib.h>
+#endif /* LIBPNG 1.5 */
#ifdef Q_OS_TEMP
@@ -126,9 +129,29 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float scr
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
0, 0, 0);
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ png_colorp info_ptr_palette = NULL;
+ int info_ptr_num_palette = 0;
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {
+ png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &info_ptr_num_palette);
+ }
+
+ png_bytep info_ptr_trans_alpha = NULL;
+ int info_ptr_num_trans = 0;
+ png_color_16p info_ptr_trans_color = NULL;
+
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+ png_get_tRNS(png_ptr, info_ptr, &info_ptr_trans_alpha, &info_ptr_num_trans, &info_ptr_trans_color);
+ }
+#endif /* LIBPNG 1.5 */
+
if ( color_type == PNG_COLOR_TYPE_GRAY ) {
// Black & White or 8-bit grayscale
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if ( bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1 ) {
+#else /* LIBPNG 1.5 */
if ( bit_depth == 1 && info_ptr->channels == 1 ) {
+#endif /* LIBPNG 1.5 */
png_set_invert_mono( png_ptr );
png_read_update_info( png_ptr, info_ptr );
if (!image.create( width, height, 1, 2, QImage::BigEndian ))
@@ -162,7 +185,9 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float scr
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==1 && PNG_LIBPNG_VER_MINOR>=4 )
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ const int g = info_ptr_trans_color->gray;
+#elif ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
const int g = info_ptr->trans_color.gray;
#else
const int g = info_ptr->trans_values.gray;
@@ -175,7 +200,11 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float scr
}
} else if ( color_type == PNG_COLOR_TYPE_PALETTE
&& png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ && info_ptr_num_palette <= 256 )
+#else /* LIBPNG 1.5 */
&& info_ptr->num_palette <= 256 )
+#endif /* LIBPNG 1.5 */
{
// 1-bit and 8-bit color
if ( bit_depth != 1 )
@@ -183,18 +212,33 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float scr
png_read_update_info( png_ptr, info_ptr );
png_get_IHDR(png_ptr, info_ptr,
&width, &height, &bit_depth, &color_type, 0, 0, 0);
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if (!image.create(width, height, bit_depth, info_ptr_num_palette,
+#else /* LIBPNG 1.5 */
if (!image.create(width, height, bit_depth, info_ptr->num_palette,
+#endif /* LIBPNG 1.5 */
QImage::BigEndian))
return;
int i = 0;
if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
image.setAlphaBuffer( TRUE );
+
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ while ( i < info_ptr_num_trans ) {
+ image.setColor(i, qRgba(
+ info_ptr_palette[i].red,
+ info_ptr_palette[i].green,
+ info_ptr_palette[i].blue,
+#else /* LIBPNG 1.5 */
while ( i < info_ptr->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==1 && PNG_LIBPNG_VER_MINOR>=4 )
+#endif /* LIBPNG 1.5 */
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ info_ptr_trans_alpha[i]
+#elif ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
info_ptr->trans_alpha[i]
#else
info_ptr->trans[i]
@@ -204,11 +248,19 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float scr
i++;
}
}
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ while ( i < info_ptr_num_palette ) {
+ image.setColor(i, qRgba(
+ info_ptr_palette[i].red,
+ info_ptr_palette[i].green,
+ info_ptr_palette[i].blue,
+#else /* LIBPNG 1.5 */
while ( i < info_ptr->num_palette ) {
image.setColor(i, qRgba(
info_ptr->palette[i].red,
info_ptr->palette[i].green,
info_ptr->palette[i].blue,
+#endif /* LIBPNG 1.5 */
0xff
)
);
@@ -295,7 +347,11 @@ void read_png_image(QImageIO* iio)
return;
}
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if (setjmp(png_jmpbuf(png_ptr))) {
+#else /* LIBPNG 1.5 */
if (setjmp(png_ptr->jmpbuf)) {
+#endif /* LIBPNG 1.5 */
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
iio->setStatus(-4);
return;
@@ -486,7 +542,11 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
return FALSE;
}
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if (setjmp(png_jmpbuf(png_ptr))) {
+#else /* LIBPNG 1.5 */
if (setjmp(png_ptr->jmpbuf)) {
+#endif /* LIBPNG 1.5 */
png_destroy_write_struct(&png_ptr, &info_ptr);
return FALSE;
}
@@ -508,10 +568,18 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn);
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+#warning XXXtnn not too sure about this
+/*
+according to png.h, channels is only used on read, not writes, so we
+should be able to comment this out.
+*/
+#else /* LIBPNG 1.5 */
info_ptr->channels =
(image.depth() == 32)
? (image.hasAlphaBuffer() ? 4 : 3)
: 1;
+#endif /* LIBPNG 1.5 */
png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
image.depth() == 1 ? 1 : 8 /* per channel */,
@@ -521,11 +589,18 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
: PNG_COLOR_TYPE_RGB
: PNG_COLOR_TYPE_PALETTE, 0, 0, 0);
-
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ png_color_8 sig_bit;
+ sig_bit.red = 8;
+ sig_bit.green = 8;
+ sig_bit.blue = 8;
+ png_set_sBIT(png_ptr, info_ptr, &sig_bit);
+#else /* LIBPNG 1.5 */
//png_set_sBIT(png_ptr, info_ptr, 8);
info_ptr->sig_bit.red = 8;
info_ptr->sig_bit.green = 8;
info_ptr->sig_bit.blue = 8;
+#endif /* LIBPNG 1.5 */
if (image.depth() == 1 && image.bitOrder() == QImage::LittleEndian)
png_set_packswap(png_ptr);
@@ -539,11 +614,22 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
int* trans = new int[num_palette];
int num_trans = 0;
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ png_colorp info_ptr_palette = NULL;
+ int tmp;
+ png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &tmp);
+#endif /* LIBPNG 1.5 */
for (int i=0; i<num_palette; i++) {
QRgb rgb=image.color(i);
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ info_ptr_palette[i].red = qRed(rgb);
+ info_ptr_palette[i].green = qGreen(rgb);
+ info_ptr_palette[i].blue = qBlue(rgb);
+#else /* LIBPNG 1.5 */
info_ptr->palette[i].red = qRed(rgb);
info_ptr->palette[i].green = qGreen(rgb);
info_ptr->palette[i].blue = qBlue(rgb);
+#endif /* LIBPNG 1.5 */
if (image.hasAlphaBuffer()) {
trans[i] = rgb >> 24;
if (trans[i] < 255) {
@@ -551,6 +637,9 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
}
}
}
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ png_set_PLTE(png_ptr, info_ptr, info_ptr_palette, num_palette);
+#endif /* LIBPNG 1.5 */
if (num_trans) {
copy_trans = new png_byte[num_trans];
for (int i=0; i<num_trans; i++)
@@ -561,7 +650,14 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in, int off_x_
}
if ( image.hasAlphaBuffer() ) {
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ png_color_8p sig_bit;
+ png_get_sBIT(png_ptr, info_ptr, &sig_bit);
+ sig_bit->alpha = 8;
+ png_set_sBIT(png_ptr, info_ptr, sig_bit);
+#else /* LIBPNG 1.5 */
info_ptr->sig_bit.alpha = 8;
+#endif /* LIBPNG 1.5 */
}
// Swap ARGB to RGBA (normal PNG format) before saving on
@@ -1047,7 +1143,11 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* cons,
return -1;
}
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if (setjmp(png_jmpbuf(png_ptr))) {
+#else /* LIBPNG 1.5 */
if (setjmp((png_ptr)->jmpbuf)) {
+#endif /* LIBPNG 1.5 */
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
image = 0;
return -1;
@@ -1074,7 +1174,11 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* cons,
if ( !png_ptr ) return 0;
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ if (setjmp(png_jmpbuf(png_ptr))) {
+#else /* LIBPNG 1.5 */
if (setjmp(png_ptr->jmpbuf)) {
+#endif /* LIBPNG 1.5 */
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
image = 0;
state = MovieStart;
@@ -1134,7 +1238,11 @@ void QPNGFormat::end(png_structp png, png_infop info)
consumer->frameDone(QPoint(offx,offy),r);
consumer->end();
state = FrameStart;
+#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
+ unused_data = png_process_data_pause(png, 0);
+#else /* LIBPNG 1.5 */
unused_data = (int)png->buffer_size; // Since libpng doesn't tell us
+#endif /* LIBPNG 1.5 */
}
#ifdef PNG_USER_CHUNKS_SUPPORTED

@ -20,15 +20,15 @@
Name: qt3
Version: %{?version}
Release: 3%{?dist}
Release: 6%{?dist}
Summary: The shared library for the Qt 3 GUI toolkit
License: QPL or GPLv2 or GPLv3
Group: System Environment/Libraries
URL: http://www.trinitydesktop.org/
Obsoletes: qt < 1:%{version}-%{release}
Provides: qt = 1:%{version}-%{release}
Obsoletes: %{name} < %{version}-%{release}
Provides: %{name} = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -89,6 +89,9 @@ Patch200: qt-x11-free-3.3.4-fullscreen.patch
# TDE 3.5.13 patches
Patch300: qt3-3.3.8.d-updates_zh-tw_translations.patch
## [qt3] Fix Qt3 builds with libpng15. [Bug #683]
Patch301: 1326063972:e278b858739babff5cc19ca81a661e1256d162e7.diff
%define qt_dirname qt-3.3
%define qtdir %{_libdir}/%{qt_dirname}
%define qt_docdir %{_docdir}/qt-devel-%{version}
@ -155,14 +158,15 @@ BuildRequires: postgresql-devel
BuildRequires: unixODBC-devel
BuildRequires: sqlite-devel
BuildRequires: gcc-c++
BuildRequires: make
%package config
Summary: Graphical configuration tool for programs using Qt 3
Group: User Interface/Desktops
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-config < 1:%{version}-%{release}
Provides: qt-config = 1:%{version}-%{release}
Obsoletes: %{name}-config < %{version}-%{release}
Provides: %{name}-config = %{version}-%{release}
%package devel
@ -188,8 +192,8 @@ Requires: libmng-devel
Requires: mesa-libGL-devel
Requires: mesa-libGLU-devel
Obsoletes: qt-devel < 1:%{version}-%{release}
Provides: qt-devel = 1:%{version}-%{release}
Obsoletes: %{name}-devel < %{version}-%{release}
Provides: %{name}-devel = %{version}-%{release}
%package devel-docs
@ -197,8 +201,8 @@ Summary: Documentation for the Qt 3 GUI toolkit
Group: Development/Libraries
Requires: %{name}-devel = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-devel-docs < 1:%{version}-%{release}
Provides: qt-devel-docs = 1:%{version}-%{release}
Obsoletes: %{name}-devel-docs < %{version}-%{release}
Provides: %{name}-devel-docs = %{version}-%{release}
%package ODBC
@ -206,8 +210,8 @@ Summary: ODBC drivers for Qt 3's SQL classes
Group: System Environment/Libraries
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-ODBC < 1:%{version}-%{release}
Provides: qt-ODBC = 1:%{version}-%{release}
Obsoletes: %{name}-ODBC < %{version}-%{release}
Provides: %{name}-ODBC = %{version}-%{release}
%package MySQL
@ -215,8 +219,8 @@ Summary: MySQL drivers for Qt 3's SQL classes
Group: System Environment/Libraries
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-MySQL < 1:%{version}-%{release}
Provides: qt-MySQL = 1:%{version}-%{release}
Obsoletes: %{name}-MySQL < %{version}-%{release}
Provides: %{name}-MySQL = %{version}-%{release}
%package PostgreSQL
@ -224,8 +228,8 @@ Summary: PostgreSQL drivers for Qt 3's SQL classes
Group: System Environment/Libraries
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-PostgreSQL < 1:%{version}-%{release}
Provides: qt-PostgreSQL = 1:%{version}-%{release}
Obsoletes: %{name}-PostgreSQL < %{version}-%{release}
Provides: %{name}-PostgreSQL = %{version}-%{release}
%package sqlite
@ -233,8 +237,8 @@ Summary: sqlite drivers for Qt 3's SQL classes
Group: System Environment/Libraries
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-sqlite < 1:%{version}-%{release}
Provides: qt-sqlite = 1:%{version}-%{release}
Obsoletes: %{name}-sqlite < %{version}-%{release}
Provides: %{name}-sqlite = %{version}-%{release}
%package designer
@ -242,8 +246,8 @@ Summary: Interface designer (IDE) for the Qt 3 toolkit
Group: Development/Tools
Requires: %{name}-devel = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: qt-designer < 1:%{version}-%{release}
Provides: qt-designer = 1:%{version}-%{release}
Obsoletes: %{name}-designer < %{version}-%{release}
Provides: %{name}-designer = %{version}-%{release}
%description
@ -357,6 +361,7 @@ for the Qt 3 toolkit.
# TDE 3.5.13 patches
%patch300 -p1
%patch301 -p1
# convert to UTF-8
iconv -f iso-8859-1 -t utf-8 < doc/man/man3/qdial.3qt > doc/man/man3/qdial.3qt_
@ -709,6 +714,15 @@ rm -rf %{buildroot}
%changelog
* Tue Apr 24 2012 Francois Andriot <francois.andriot@free.fr> - 3.3.8.d-6
- Fix Qt3 builds with libpng15. [Bug #683]
* Sat Apr 21 2012 Francois Andriot <francois.andriot@free.fr> - 3.3.8.d-5
- Fix 'Provides' AGAIN !! [Bug #823]
* Mon Apr 02 2012 Francois Andriot <francois.andriot@free.fr> - 3.3.8.d-4
- Fix 'Provides' [Bug #823]
* Sun Dec 18 2011 Francois Andriot <francois.andriot@free.fr> - 3.3.8.d-3
- Updates zh_TW translations, thanks to Wei-Lun Chao .

Loading…
Cancel
Save