diff options
author | 2005-04-20 22:07:12 +0000 | |
---|---|---|
committer | 2005-04-20 22:07:12 +0000 | |
commit | 546b834dacb6488aa38a73ce9c5829264297e30e (patch) | |
tree | 9785621a829b8bacf14fa3572e34d62daf1d398e | |
parent | Stable on alpha + ia64, requested by seemant. (diff) | |
download | gentoo-2-546b834dacb6488aa38a73ce9c5829264297e30e.tar.gz gentoo-2-546b834dacb6488aa38a73ce9c5829264297e30e.tar.bz2 gentoo-2-546b834dacb6488aa38a73ce9c5829264297e30e.zip |
PCX Image Buffer Overflow Vulnerability
(Portage version: 2.0.51.19)
-rw-r--r-- | kde-base/kdelibs/ChangeLog | 15 | ||||
-rw-r--r-- | kde-base/kdelibs/Manifest | 61 | ||||
-rw-r--r-- | kde-base/kdelibs/files/digest-kdelibs-3.2.3-r9 | 1 | ||||
-rw-r--r-- | kde-base/kdelibs/files/digest-kdelibs-3.3.2-r8 | 1 | ||||
-rw-r--r-- | kde-base/kdelibs/files/digest-kdelibs-3.4.0-r1 | 1 | ||||
-rw-r--r-- | kde-base/kdelibs/files/post-3.2.3-kdelibs-idn.patch | 89 | ||||
-rw-r--r-- | kde-base/kdelibs/files/post-3.2.3-kdelibs-kimgio.diff | 1404 | ||||
-rw-r--r-- | kde-base/kdelibs/files/post-3.3.2-kdelibs-idn-2.patch | 127 | ||||
-rw-r--r-- | kde-base/kdelibs/files/post-3.3.2-kdelibs-kimgio.diff | 1932 | ||||
-rw-r--r-- | kde-base/kdelibs/files/post-3.4.0-kdelibs-kimgio.diff | 1017 | ||||
-rw-r--r-- | kde-base/kdelibs/kdelibs-3.2.3-r9.ebuild | 105 | ||||
-rw-r--r-- | kde-base/kdelibs/kdelibs-3.3.2-r8.ebuild | 130 | ||||
-rw-r--r-- | kde-base/kdelibs/kdelibs-3.4.0-r1.ebuild | 105 |
13 files changed, 4962 insertions, 26 deletions
diff --git a/kde-base/kdelibs/ChangeLog b/kde-base/kdelibs/ChangeLog index c1f05b7b1c9d..2cf01bb48685 100644 --- a/kde-base/kdelibs/ChangeLog +++ b/kde-base/kdelibs/ChangeLog @@ -1,6 +1,19 @@ # ChangeLog for kde-base/kdelibs # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/kde-base/kdelibs/ChangeLog,v 1.227 2005/03/21 08:29:54 gmsoft Exp $ +# $Header: /var/cvsroot/gentoo-x86/kde-base/kdelibs/ChangeLog,v 1.228 2005/04/20 22:07:11 carlo Exp $ + +*kdelibs-3.4.0-r1 (20 Apr 2005) +*kdelibs-3.3.2-r8 (20 Apr 2005) +*kdelibs-3.2.3-r9 (20 Apr 2005) + + 20 Apr 2005; Carsten Lohrke <carlo@gentoo.org> + +files/post-3.2.3-kdelibs-idn.patch, + +files/post-3.2.3-kdelibs-kimgio.diff, + +files/post-3.3.2-kdelibs-idn-2.patch, + +files/post-3.3.2-kdelibs-kimgio.diff, + +files/post-3.4.0-kdelibs-kimgio.diff, +kdelibs-3.2.3-r9.ebuild, + +kdelibs-3.3.2-r8.ebuild, +kdelibs-3.4.0-r1.ebuild: + PCX Image Buffer Overflow Vulnerability, #88862 21 Mar 2005; Guy Martin <gmsoft@gentoo.org> kdelibs-3.2.3-r7.ebuild: Stable on hppa. diff --git a/kde-base/kdelibs/Manifest b/kde-base/kdelibs/Manifest index ad7d230f7b12..76ceeb75d80d 100644 --- a/kde-base/kdelibs/Manifest +++ b/kde-base/kdelibs/Manifest @@ -1,35 +1,46 @@ -MD5 acc03a4b12bb0433a57e95bd253b9501 metadata.xml 156 -MD5 eb2891eff874523d2dc5dc47507cbe7d kdelibs-3.3.2-r5.ebuild 3344 -MD5 642ea25c3926d67609ba51eb5730114f kdelibs-3.2.3-r5.ebuild 2940 +MD5 8c3940db01bff3514095956bd535442e kdelibs-3.3.2-r7.ebuild 3472 +MD5 813e4e255e83805ce8e5469228a08cea kdelibs-3.3.2-r2.ebuild 3153 MD5 eb51ca0977c7075016ddebe76e06833d kdelibs-3.2.3-r8.ebuild 3218 -MD5 076c081cd2f681cbda71ed15fc702b7d ChangeLog 36236 +MD5 39a461120104a25b8683a81c9f8010c0 kdelibs-3.4.0-r1.ebuild 3082 +MD5 642ea25c3926d67609ba51eb5730114f kdelibs-3.2.3-r5.ebuild 2940 MD5 d2b4b1a7bcb1bc7191e59d82a37a3bdc kdelibs-3.4.0.ebuild 2960 -MD5 813e4e255e83805ce8e5469228a08cea kdelibs-3.3.2-r2.ebuild 3153 -MD5 8c3940db01bff3514095956bd535442e kdelibs-3.3.2-r7.ebuild 3472 MD5 5a3d1a6d316ead8f2cb08751b71b9aba kdelibs-3.2.3-r7.ebuild 3002 -MD5 40783b984dcb127c8852246f7eb0a1e8 files/kdelibs-3.3.2-ppc64.patch 957 -MD5 296419fbb169c4d87ace85d1e1645652 files/kdelibs-3.4.0-form-freeze.patch 660 -MD5 119cc73926dceafff9107b5f916277ee files/post-3.2.3-kdelibs-htmlframes.patch 15435 -MD5 7e082af5fd71b9b01d01a86f31646499 files/post-3.3.2-kdelibs-htmlframes2.patch 989 -MD5 0948701bffb082c65784dc8a2b648ef0 files/post-3.2.3-kdelibs-dcop.patch 1901 -MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r7 68 +MD5 3c4594ea13a62e57abfc7bb57b62b540 kdelibs-3.3.2-r8.ebuild 3676 +MD5 5e73ce2fa51a62654f06e87d9ce7a834 kdelibs-3.2.3-r9.ebuild 3209 +MD5 94b6f795d9f61d9abed7cf5a2ae90d3f ChangeLog 36716 +MD5 acc03a4b12bb0433a57e95bd253b9501 metadata.xml 156 +MD5 eb2891eff874523d2dc5dc47507cbe7d kdelibs-3.3.2-r5.ebuild 3344 +MD5 25ab050b323a8efb2049fd770f50058b files/kdelibs-3.3.2-anchor-fix.patch 5947 MD5 0046c691fa833b2ff8d7eac15312a68b files/post-3.2.3-kdelibs-dcopserver.patch 4751 -MD5 998641088387e630d4ab9e9013caa539 files/kdelibs-3.4.0-imagemap.patch 546 -MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r5 68 MD5 a639b7b592f005e911c454a0a8c9c542 files/post-3.2.3-kdelibs-kioslave.patch 549 -MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r7 68 -MD5 d3df6d042148fd884422822aaf4ffbab files/kdelibs-3.3.2-aspell-dir.patch 467 -MD5 a5d3cb18c9572d8ca3dd06cbe5d226f1 files/kde3-dcopidlng.patch 681 -MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r2 68 +MD5 b93484486086ff60f9633f48ed311877 files/post-3.2.3-kdelibs-kimgio.diff 39789 MD5 ca12b078c7288ce9b2653e639a5b3ee0 files/post-3.2.3-kdelibs-kcookiejar.patch 5384 -MD5 345ce2e01cfdfa4754c47894c0271dcc files/post-3.2.3-kdelibs-kstandarddirs.patch 1417 -MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r5 68 -MD5 25ab050b323a8efb2049fd770f50058b files/kdelibs-3.3.2-anchor-fix.patch 5947 -MD5 0ce7a1c41d2bc3c102c6c4d4a6ba8f0b files/post-3.2.3-kdelibs-kio.diff 1315 +MD5 998641088387e630d4ab9e9013caa539 files/kdelibs-3.4.0-imagemap.patch 546 +MD5 a5d3cb18c9572d8ca3dd06cbe5d226f1 files/kde3-dcopidlng.patch 681 +MD5 119cc73926dceafff9107b5f916277ee files/post-3.2.3-kdelibs-htmlframes.patch 15435 +MD5 296419fbb169c4d87ace85d1e1645652 files/kdelibs-3.4.0-form-freeze.patch 660 +MD5 7e082af5fd71b9b01d01a86f31646499 files/post-3.3.2-kdelibs-htmlframes2.patch 989 +MD5 5e9c627e4e9e367ce88ed62a0a9ac162 files/post-3.2.3-kdelibs-khtml.diff 2411 +MD5 0948701bffb082c65784dc8a2b648ef0 files/post-3.2.3-kdelibs-dcop.patch 1901 MD5 1b408d4b494b5328cd15768991836fd8 files/post-3.3.2-kdelibs-kio.diff 1442 MD5 1f98b72b586d9a988c47dfce380dd8b6 files/post-3.2.3-kdelibs-htmlframes2.patch 975 -MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r8 68 -MD5 5e9c627e4e9e367ce88ed62a0a9ac162 files/post-3.2.3-kdelibs-khtml.diff 2411 +MD5 661f99a406078c89ff9cae9fd67fd28a files/digest-kdelibs-3.4.0 68 +MD5 345ce2e01cfdfa4754c47894c0271dcc files/post-3.2.3-kdelibs-kstandarddirs.patch 1417 MD5 fe67157b26a8cdf5bcfa1898cdf3b154 files/post-3.3.2-kdelibs-kioslave.patch 663 +MD5 40783b984dcb127c8852246f7eb0a1e8 files/kdelibs-3.3.2-ppc64.patch 957 MD5 7309e259ae1f29be08bbb70e580da3fb files/post-3.3.2-kdelibs-dcop.patch 1903 -MD5 661f99a406078c89ff9cae9fd67fd28a files/digest-kdelibs-3.4.0 68 +MD5 d3df6d042148fd884422822aaf4ffbab files/kdelibs-3.3.2-aspell-dir.patch 467 +MD5 0ce7a1c41d2bc3c102c6c4d4a6ba8f0b files/post-3.2.3-kdelibs-kio.diff 1315 +MD5 8366d0e5c8101c315a0bdafac54536d6 files/post-3.3.2-kdelibs-kimgio.diff 53551 +MD5 b92182b7734e4ff145a08d9755448ec7 files/post-3.3.2-kdelibs-idn-2.patch 4212 +MD5 b174d4e6ed2d0fd78fa43a40654f9ea4 files/post-3.2.3-kdelibs-idn.patch 2337 +MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r5 68 +MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r7 68 +MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r8 68 +MD5 57b3bdaa9934d84f320c1aa40a56afe4 files/digest-kdelibs-3.2.3-r9 68 +MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r2 68 +MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r5 68 +MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r7 68 +MD5 dd2a593a052e2ea070d310e38297bec0 files/digest-kdelibs-3.3.2-r8 68 +MD5 78473d4dad612e6617eb6652eec2ab80 files/post-3.4.0-kdelibs-kimgio.diff 30316 +MD5 661f99a406078c89ff9cae9fd67fd28a files/digest-kdelibs-3.4.0-r1 68 diff --git a/kde-base/kdelibs/files/digest-kdelibs-3.2.3-r9 b/kde-base/kdelibs/files/digest-kdelibs-3.2.3-r9 new file mode 100644 index 000000000000..ab94bd8ba7fd --- /dev/null +++ b/kde-base/kdelibs/files/digest-kdelibs-3.2.3-r9 @@ -0,0 +1 @@ +MD5 d9d1c4bd2016a96f156b491ca908dc16 kdelibs-3.2.3.tar.bz2 12737024 diff --git a/kde-base/kdelibs/files/digest-kdelibs-3.3.2-r8 b/kde-base/kdelibs/files/digest-kdelibs-3.3.2-r8 new file mode 100644 index 000000000000..bc59a2da5ef1 --- /dev/null +++ b/kde-base/kdelibs/files/digest-kdelibs-3.3.2-r8 @@ -0,0 +1 @@ +MD5 0473fb4c6c2cd2bc0f267cfa201f3fd8 kdelibs-3.3.2.tar.bz2 15623180 diff --git a/kde-base/kdelibs/files/digest-kdelibs-3.4.0-r1 b/kde-base/kdelibs/files/digest-kdelibs-3.4.0-r1 new file mode 100644 index 000000000000..ec961c24b941 --- /dev/null +++ b/kde-base/kdelibs/files/digest-kdelibs-3.4.0-r1 @@ -0,0 +1 @@ +MD5 e5961a78b44a3005a7af6ada249e5888 kdelibs-3.4.0.tar.bz2 16861967 diff --git a/kde-base/kdelibs/files/post-3.2.3-kdelibs-idn.patch b/kde-base/kdelibs/files/post-3.2.3-kdelibs-idn.patch new file mode 100644 index 000000000000..d5781b5dc7ff --- /dev/null +++ b/kde-base/kdelibs/files/post-3.2.3-kdelibs-idn.patch @@ -0,0 +1,89 @@ +=================================================================== +RCS file: /home/kde/kdelibs/kdecore/kidna.cpp,v +retrieving revision 1.9.4.1 +retrieving revision 1.9.4.2 +diff -u -r1.9.4.1 -r1.9.4.2 +--- kdecore/kidna.cpp 2004/02/04 11:43:34 1.9.4.1 ++++ kdecore/kidna.cpp 2005/03/03 13:19:45 1.9.4.2 +@@ -21,6 +21,7 @@ + + #include "kidna.h" + ++#include <qstringlist.h> + #include <kdebug.h> + + #include "ltdl.h" +@@ -65,6 +66,22 @@ + KIDNA_lib_load_failed = false; // Succes + } + ++static QStringList *KIDNA_idnDomains = 0; ++ ++static bool idnSupportForHost(const QString &host) ++{ ++ if (!KIDNA_idnDomains) ++ { ++ const char *kde_use_idn = getenv("KDE_USE_IDN"); ++ if (!kde_use_idn) ++ kde_use_idn = "at:ch:cn:de:dk:kr:jp:li:no:se:tw"; ++ KIDNA_idnDomains = new QStringList(QStringList::split(':', QString::fromLatin1(kde_use_idn).lower())); ++ } ++ ++ QString tld = host.mid(host.findRev('.')+1).lower(); ++ return KIDNA_idnDomains->contains(tld); ++} ++ + QCString KIDNA::toAsciiCString(const QString &idna) + { + int l = idna.length(); +@@ -86,7 +103,7 @@ + KIDNA_load_lib(); + } + +- if (KIDNA_lib_load_failed) ++ if (KIDNA_lib_load_failed || !idnSupportForHost(idna)) + { + return 0; // Can't convert + } +@@ -132,7 +149,7 @@ + KIDNA_load_lib(); + } + +- if (KIDNA_lib_load_failed) ++ if (KIDNA_lib_load_failed || !idnSupportForHost(idna)) + { + return QString::null; // Can't convert + } +@@ -164,7 +181,7 @@ + KIDNA_load_lib(); + } + +- if (KIDNA_lib_load_failed) ++ if (KIDNA_lib_load_failed || !idnSupportForHost(idna)) + { + return idna.lower(); // Return as is + } +=================================================================== +RCS file: /home/kde/kdelibs/kio/kssl/ksslpeerinfo.cc,v +retrieving revision 1.44 +retrieving revision 1.44.2.1 +diff -u -r1.44 -r1.44.2.1 +--- kio/kssl/ksslpeerinfo.cc 2003/05/29 16:50:21 1.44 ++++ kio/kssl/ksslpeerinfo.cc 2005/03/04 12:13:28 1.44.2.1 +@@ -30,6 +30,7 @@ + #include <ksockaddr.h> + #include <kextsock.h> + #include <netsupp.h> ++#include "kidna.h" + + #include "ksslx509map.h" + +@@ -59,7 +60,7 @@ + while(d->peerHost.endsWith(".")) + d->peerHost.truncate(d->peerHost.length()-1); + +- d->peerHost = d->peerHost.lower(); ++ d->peerHost = KIDNA::toAscii(d->peerHost); + } + + bool KSSLPeerInfo::certMatchesAddress() { diff --git a/kde-base/kdelibs/files/post-3.2.3-kdelibs-kimgio.diff b/kde-base/kdelibs/files/post-3.2.3-kdelibs-kimgio.diff new file mode 100644 index 000000000000..b7fb6d8790fd --- /dev/null +++ b/kde-base/kdelibs/files/post-3.2.3-kdelibs-kimgio.diff @@ -0,0 +1,1404 @@ +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/eps.cpp kdelibs-3.2.5/work/kdelibs/kimgio/eps.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/eps.cpp 2003-09-21 10:39:17.000000000 +0200 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/eps.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -121,7 +121,7 @@ static bool bbox ( QIODevice *io, int *x + return ret; + } + +-void kimgio_eps_read (QImageIO *image) ++void kimgio_eps_read (QImageIO *image) + { + kdDebug(399) << "kimgio EPS: starting..." << endl; + +@@ -245,39 +245,34 @@ void kimgio_eps_read (QImageIO *image) + } + + // Sven Wiegand <SWiegand@tfh-berlin.de> -- eps output filter (from KSnapshot) +-void kimgio_eps_write( QImageIO *imageio ) ++void kimgio_eps_write( QImageIO *imageio ) + { +- QPrinter psOut; ++ QPrinter psOut(QPrinter::PrinterResolution); + QPainter p; + + // making some definitions (papersize, output to file, filename): + psOut.setCreator( "KDE " KDE_VERSION_STRING ); + psOut.setOutputToFile( true ); + +- KTempFile tmpFile; ++ // Extension must be .eps so that Qt generates EPS file ++ KTempFile tmpFile(QString::null, ".eps"); + tmpFile.setAutoDelete(true); + if ( tmpFile.status() != 0) + return; + tmpFile.close(); // Close the file, we just want the filename + + psOut.setOutputFileName(tmpFile.name()); ++ psOut.setFullPage(true); + + // painting the pixmap to the "printer" which is a file + p.begin( &psOut ); +- +- p.translate( -36, 820 - imageio->image().height() ); +- ++ // Qt uses the clip rect for the bounding box ++ p.setClipRect( 0, 0, imageio->image().width(), imageio->image().height(), QPainter::CoordPainter); + p.drawImage( QPoint( 0, 0 ), imageio->image() ); + p.end(); + +- // write BoundingBox to File ++ // Copy file to imageio struct + QFile inFile(tmpFile.name()); +- QString szBoxInfo; +- +- szBoxInfo.sprintf("%%%%BoundingBox: 0 0 %d %d\n", +- imageio->image().width(), +- imageio->image().height()); +- + inFile.open( IO_ReadOnly ); + + QTextStream in( &inFile ); +@@ -287,7 +282,6 @@ void kimgio_eps_write( QImageIO *imageio + + QString szInLine = in.readLine(); + out << szInLine << '\n'; +- out << szBoxInfo; + + while( !in.atEnd() ){ + szInLine = in.readLine(); +@@ -298,4 +292,3 @@ void kimgio_eps_write( QImageIO *imageio + + imageio->setStatus(0); + } +- +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/g3r.cpp kdelibs-3.2.5/work/kdelibs/kimgio/g3r.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/g3r.cpp 2000-07-03 18:37:32.000000000 +0200 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/g3r.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -11,8 +11,9 @@ + + #include "g3r.h" + +-void kimgio_g3_read( QImageIO *io ) ++void kimgio_g3_read( QImageIO *io ) + { ++ // This won't work if io is not a QFile ! + TIFF *tiff = TIFFOpen(QFile::encodeName(io->fileName()), "r"); + if (!tiff) + return; +@@ -20,13 +21,14 @@ void kimgio_g3_read( QImageIO *io ) + uint32 width, height; + tsize_t scanlength; + +- TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ); +- TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ); ++ if( TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ) != 1 ++ || TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ) != 1 ) ++ return; + scanlength = TIFFScanlineSize(tiff); + + QImage image(width, height, 1, 0, QImage::BigEndian); + +- if (scanlength != image.bytesPerLine()) ++ if (image.isNull() || scanlength != image.bytesPerLine()) + { + TIFFClose(tiff); + return; +@@ -42,7 +44,7 @@ void kimgio_g3_read( QImageIO *io ) + } + + +-void kimgio_g3_write(QImageIO *) ++void kimgio_g3_write(QImageIO *) + { + // TODO: stub + } +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/ico.cpp kdelibs-3.2.5/work/kdelibs/kimgio/ico.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/ico.cpp 2003-09-07 14:17:55.000000000 +0200 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/ico.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -113,6 +115,8 @@ namespace + // closest size match precedes everything else + if ( std::abs( int( lhs.width - size ) ) < + std::abs( int( rhs.width - size ) ) ) return true; ++ else if ( std::abs( int( lhs.width - size ) ) > ++ std::abs( int( rhs.width - size ) ) ) return false; + else if ( colors == 0 ) + { + // high/true color requested +@@ -137,24 +141,38 @@ namespace + { + BMP_INFOHDR header; + stream >> header; +- if ( header.biSize != BMP_INFOHDR::Size || ++ if ( stream.atEnd() || header.biSize != BMP_INFOHDR::Size || + header.biSize > rec.size || + header.biCompression != BMP_INFOHDR::RGB || + ( header.biBitCount != 1 && header.biBitCount != 4 && + header.biBitCount != 8 && header.biBitCount != 24 && + header.biBitCount != 32 ) ) return false; + +- unsigned colors = header.biBitCount >= 24 ? +- 0 : header.biClrUsed ? +- header.biClrUsed : 1 << header.biBitCount; ++ unsigned paletteSize, paletteEntries; ++ ++ if (header.biBitCount > 8) ++ { ++ paletteEntries = 0; ++ paletteSize = 0; ++ } ++ else ++ { ++ paletteSize = (1 << header.biBitCount); ++ paletteEntries = paletteSize; ++ if (header.biClrUsed && header.biClrUsed < paletteSize) ++ paletteEntries = header.biClrUsed; ++ } ++ + // Always create a 32-bit image to get the mask right ++ // Note: this is safe as rec.width, rec.height are bytes + icon.create( rec.width, rec.height, 32 ); + if ( icon.isNull() ) return false; + icon.setAlphaBuffer( true ); + +- QMemArray< QRgb > colorTable( 1 << header.biBitCount ); ++ QMemArray< QRgb > colorTable( paletteSize ); ++ + colorTable.fill( QRgb( 0 ) ); +- for ( unsigned i = 0; i < colors; ++i ) ++ for ( unsigned i = 0; i < paletteEntries; ++i ) + { + unsigned char rgb[ 4 ]; + stream.readRawBytes( reinterpret_cast< char* >( &rgb ), +@@ -163,9 +181,10 @@ namespace + } + + unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4; ++ + unsigned char* buf = new unsigned char[ bpl ]; + unsigned char** lines = icon.jumpTable(); +- for ( unsigned y = rec.height; y--; ) ++ for ( unsigned y = rec.height; !stream.atEnd() && y--; ) + { + stream.readRawBytes( reinterpret_cast< char* >( buf ), bpl ); + unsigned char* pixel = buf; +@@ -230,7 +249,7 @@ extern "C" void kimgio_ico_read( QImageI + stream.setByteOrder( QDataStream::LittleEndian ); + IcoHeader header; + stream >> header; +- if ( !header.count || ++ if ( stream.atEnd() || !header.count || + ( header.type != IcoHeader::Icon && header.type != IcoHeader::Cursor) ) + return; + +@@ -265,12 +284,14 @@ extern "C" void kimgio_ico_read( QImageI + stream >> rec; + icons.push_back( rec ); + } +- IconList::const_iterator selected = +- requestedIndex >= 0 ? +- std::min( icons.begin() + requestedIndex, icons.end() ) : +- std::min_element( icons.begin(), icons.end(), ++ IconList::const_iterator selected; ++ if (requestedIndex >= 0) { ++ selected = std::min( icons.begin() + requestedIndex, icons.end() ); ++ } else { ++ selected = std::min_element( icons.begin(), icons.end(), + LessDifference( requestedSize, requestedColors ) ); +- if ( selected == icons.end() || ++ } ++ if ( stream.atEnd() || selected == icons.end() || + offset + selected->offset > io->ioDevice()->size() ) + return; + +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/jp2.cpp kdelibs-3.2.5/work/kdelibs/kimgio/jp2.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/jp2.cpp 2003-10-26 11:54:06.000000000 +0100 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/jp2.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -157,8 +157,9 @@ namespace { + void + draw_view_gray( gs_t& gs, QImage& qti ) + { +- qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), +- 8, 256 ); ++ if( !qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), ++ 8, 256 )) ++ return; + for( int i = 0; i < 256; ++i ) + qti.setColor( i, qRgb( i, i, i ) ); + +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/pcx.cpp kdelibs-3.2.5/work/kdelibs/kimgio/pcx.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/pcx.cpp 2003-10-26 11:54:06.000000000 +0100 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/pcx.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -1,5 +1,5 @@ + /* This file is part of the KDE project +- Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> ++ Copyright (C) 2002-2005 Nadeem Hasan <nhasan@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public +@@ -44,6 +44,11 @@ static QDataStream &operator>>( QDataStr + s >> ph.HScreenSize; + s >> ph.VScreenSize; + ++ // Skip the rest of the header ++ Q_UINT8 byte; ++ while ( s.device()->at() < 128 ) ++ s >> byte; ++ + return s; + } + +@@ -85,25 +90,22 @@ static QDataStream &operator<<( QDataStr + return s; + } + +-static PCXHEADER header; +-static QImage img; +-static Q_UINT16 w, h; +- +-void PCXHEADER::reset() ++PCXHEADER::PCXHEADER() + { ++ // Initialize all data to zero + QByteArray dummy( 128 ); + dummy.fill( 0 ); + QDataStream s( dummy, IO_ReadOnly ); + s >> *this; + } + +-static void readLine( QDataStream &s, QByteArray &buf ) ++static void readLine( QDataStream &s, QByteArray &buf, const PCXHEADER &header ) + { + Q_UINT32 i=0; + Q_UINT32 size = buf.size(); + Q_UINT8 byte, count; + +- if ( header.Encoding == 1 ) ++ if ( header.isCompressed() ) + { + // Uncompress the image data + while ( i < size ) +@@ -130,13 +132,14 @@ static void readLine( QDataStream &s, QB + } + } + +-static void readImage1( QDataStream &s ) ++static void readImage1( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 1, 2, QImage::BigEndian ); ++ if(!img.create( header.width(), header.height(), 1, 2, QImage::BigEndian )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -144,10 +147,11 @@ static void readImage1( QDataStream &s ) + return; + } + +- readLine( s, buf ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *( img.scanLine( y )+x ) = buf[ x ]; ++ readLine( s, buf, header ); ++ uchar *p = img.scanLine( y ); ++ unsigned int bpl = QMIN((header.width()+7)/8, header.BytesPerLine); ++ for ( unsigned int x=0; x< bpl; ++x ) ++ p[ x ] = buf[x]; + } + + // Set the color palette +@@ -155,14 +159,15 @@ static void readImage1( QDataStream &s ) + img.setColor( 1, qRgb( 255, 255, 255 ) ); + } + +-static void readImage4( QDataStream &s ) ++static void readImage4( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine*4 ); +- QByteArray pixbuf( w ); ++ QByteArray pixbuf( header.width() ); + +- img.create( w, h, 8, 16, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 16 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -171,20 +176,19 @@ static void readImage4( QDataStream &s ) + } + + pixbuf.fill( 0 ); +- readLine( s, buf ); ++ readLine( s, buf, header ); + + for ( int i=0; i<4; i++ ) + { + Q_UINT32 offset = i*header.BytesPerLine; +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + if ( buf[ offset + ( x/8 ) ] & ( 128 >> ( x%8 ) ) ) + pixbuf[ x ] += ( 1 << i ); + } + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<w; ++x ) +- *p++ = pixbuf[ x ]; ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = pixbuf[ x ]; + } + + // Read the palette +@@ -192,13 +196,14 @@ static void readImage4( QDataStream &s ) + img.setColor( i, header.ColorMap.color( i ) ); + } + +-static void readImage8( QDataStream &s ) ++static void readImage8( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 8, 256, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 256 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -206,19 +211,19 @@ static void readImage8( QDataStream &s ) + return; + } + +- readLine( s, buf ); ++ readLine( s, buf, header ); + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = buf[ x ]; ++ unsigned int bpl = QMIN(header.BytesPerLine, header.width()); ++ for ( unsigned int x=0; x<bpl; ++x ) ++ p[ x ] = buf[ x ]; + } + + Q_UINT8 flag; + s >> flag; +- kdDebug() << "Flag: " << flag << endl; ++ kdDebug( 399 ) << "Palette Flag: " << flag << endl; + +- if ( flag == 12 && header.Version == 5 ) ++ if ( flag == 12 && ( header.Version == 5 || header.Version == 2 ) ) + { + // Read the palette + Q_UINT8 r, g, b; +@@ -230,15 +235,16 @@ static void readImage8( QDataStream &s ) + } + } + +-static void readImage24( QDataStream &s ) ++static void readImage24( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray r_buf( header.BytesPerLine ); + QByteArray g_buf( header.BytesPerLine ); + QByteArray b_buf( header.BytesPerLine ); + +- img.create( w, h, 32 ); ++ if(!img.create( header.width(), header.height(), 32 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -246,18 +252,17 @@ static void readImage24( QDataStream &s + return; + } + +- readLine( s, r_buf ); +- readLine( s, g_buf ); +- readLine( s, b_buf ); ++ readLine( s, r_buf, header ); ++ readLine( s, g_buf, header ); ++ readLine( s, b_buf, header ); + + uint *p = ( uint * )img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); + } + } + +-void kimgio_pcx_read( QImageIO *io ) ++void kimgio_pcx_read( QImageIO *io ) + { + QDataStream s( io->ioDevice() ); + s.setByteOrder( QDataStream::LittleEndian ); +@@ -268,6 +273,8 @@ void kimgio_pcx_read( QImageIO *io ) + return; + } + ++ PCXHEADER header; ++ + s >> header; + + if ( header.Manufacturer != 10 || s.atEnd()) +@@ -276,10 +283,8 @@ void kimgio_pcx_read( QImageIO *io ) + return; + } + +- w = ( header.XMax-header.XMin ) + 1; +- h = ( header.YMax-header.YMin ) + 1; +- +- img.reset(); ++ int w = header.width(); ++ int h = header.height(); + + kdDebug( 399 ) << "Manufacturer: " << header.Manufacturer << endl; + kdDebug( 399 ) << "Version: " << header.Version << endl; +@@ -292,26 +297,23 @@ void kimgio_pcx_read( QImageIO *io ) + kdDebug( 399 ) << "BytesPerLine: " << header.BytesPerLine << endl; + kdDebug( 399 ) << "NPlanes: " << header.NPlanes << endl; + +- // Skip the rest of the header +- Q_UINT8 byte; +- while ( s.device()->at() < 128 ) +- s >> byte; ++ QImage img; + + if ( header.Bpp == 1 && header.NPlanes == 1 ) + { +- readImage1( s ); ++ readImage1( img, s, header ); + } + else if ( header.Bpp == 1 && header.NPlanes == 4 ) + { +- readImage4( s ); ++ readImage4( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 1 ) + { +- readImage8( s ); ++ readImage8( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 3 ) + { +- readImage24( s ); ++ readImage24( img, s, header ); + } + + kdDebug( 399 ) << "Image Bytes: " << img.numBytes() << endl; +@@ -359,7 +361,7 @@ static void writeLine( QDataStream &s, Q + } + } + +-static void writeImage1( QDataStream &s ) ++static void writeImage1( QImage &img, QDataStream &s, PCXHEADER &header ) + { + img = img.convertBitOrder( QImage::BigEndian ); + +@@ -367,29 +369,27 @@ static void writeImage1( QDataStream &s + header.NPlanes = 1; + header.BytesPerLine = img.bytesPerLine(); + +- header.ColorMap.setColor( 0, qRgb( 0, 0, 0 ) ); +- header.ColorMap.setColor( 1, qRgb( 255, 255, 255 ) ); +- + s << header; + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + ++ // Invert as QImage uses reverse palette for monochrome images? + for ( int i=0; i<header.BytesPerLine; ++i ) +- buf[ i ] = p[ i ]; ++ buf[ i ] = ~p[ i ]; + + writeLine( s, buf ); + } + } + +-static void writeImage4( QDataStream &s ) ++static void writeImage4( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 1; + header.NPlanes = 4; +- header.BytesPerLine = w/8; ++ header.BytesPerLine = header.width()/8; + + for ( int i=0; i<16; ++i ) + header.ColorMap.setColor( i, img.color( i ) ); +@@ -401,14 +401,14 @@ static void writeImage4( QDataStream &s + for ( int i=0; i<4; ++i ) + buf[ i ].resize( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + + for ( int i=0; i<4; ++i ) + buf[ i ].fill( 0 ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + for ( int i=0; i<4; ++i ) + if ( *( p+x ) & ( 1 << i ) ) +@@ -420,7 +420,7 @@ static void writeImage4( QDataStream &s + } + } + +-static void writeImage8( QDataStream &s ) ++static void writeImage8( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 1; +@@ -430,7 +430,7 @@ static void writeImage8( QDataStream &s + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + +@@ -449,23 +449,23 @@ static void writeImage8( QDataStream &s + s << RGB( img.color( i ) ); + } + +-static void writeImage24( QDataStream &s ) ++static void writeImage24( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 3; +- header.BytesPerLine = w; ++ header.BytesPerLine = header.width(); + + s << header; + +- QByteArray r_buf( w ); +- QByteArray g_buf( w ); +- QByteArray b_buf( w ); ++ QByteArray r_buf( header.width() ); ++ QByteArray g_buf( header.width() ); ++ QByteArray b_buf( header.width() ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + uint *p = ( uint * )img.scanLine( y ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + QRgb rgb = *p++; + r_buf[ x ] = qRed( rgb ); +@@ -479,15 +479,15 @@ static void writeImage24( QDataStream &s + } + } + +-void kimgio_pcx_write( QImageIO *io ) ++void kimgio_pcx_write( QImageIO *io ) + { + QDataStream s( io->ioDevice() ); + s.setByteOrder( QDataStream::LittleEndian ); + +- img = io->image(); ++ QImage img = io->image(); + +- w = img.width(); +- h = img.height(); ++ int w = img.width(); ++ int h = img.height(); + + kdDebug( 399 ) << "Width: " << w << endl; + kdDebug( 399 ) << "Height: " << h << endl; +@@ -495,6 +495,8 @@ void kimgio_pcx_write( QImageIO *io ) + kdDebug( 399 ) << "BytesPerLine: " << img.bytesPerLine() << endl; + kdDebug( 399 ) << "Num Colors: " << img.numColors() << endl; + ++ PCXHEADER header; ++ + header.Manufacturer = 10; + header.Version = 5; + header.Encoding = 1; +@@ -509,19 +511,19 @@ void kimgio_pcx_write( QImageIO *io ) + + if ( img.depth() == 1 ) + { +- writeImage1( s ); ++ writeImage1( img, s, header ); + } + else if ( img.depth() == 8 && img.numColors() <= 16 ) + { +- writeImage4( s ); ++ writeImage4( img, s, header ); + } + else if ( img.depth() == 8 ) + { +- writeImage8( s ); ++ writeImage8( img, s, header ); + } + else if ( img.depth() == 32 ) + { +- writeImage24( s ); ++ writeImage24( img, s, header ); + } + + io->setStatus( 0 ); +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/pcx.h kdelibs-3.2.5/work/kdelibs/kimgio/pcx.h +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/pcx.h 2003-01-04 01:48:25.000000000 +0100 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/pcx.h 2005-04-20 14:07:22.000000000 +0200 +@@ -49,7 +49,7 @@ class Palette + rgb[ i ] = RGB( color ); + } + +- QRgb color( int i ) ++ QRgb color( int i ) const + { + return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); + } +@@ -60,12 +60,11 @@ class Palette + class PCXHEADER + { + public: +- PCXHEADER() +- { +- reset(); +- } ++ PCXHEADER(); + +- void reset(); ++ inline int width() const { return ( XMax-XMin ) + 1; } ++ inline int height() const { return ( YMax-YMin ) + 1; } ++ inline bool isCompressed() const { return ( Encoding==1 ); } + + Q_UINT8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx + Q_UINT8 Version; // Version information· +@@ -99,7 +98,7 @@ class PCXHEADER + // found only in PB IV/IV Plus + Q_UINT16 VScreenSize; // Vertical screen size in pixels. New field + // found only in PB IV/IV Plus +-}; ++} KDE_PACKED; + + #endif // PCX_H + +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/tga.cpp kdelibs-3.2.5/work/kdelibs/kimgio/tga.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/tga.cpp 2003-03-02 13:59:11.000000000 +0100 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/tga.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -1,5 +1,6 @@ + /* This file is part of the KDE project + Copyright (C) 2003 Dominik Seichter <domseichter@web.de> ++ Copyright (C) 2004 Ignacio Castaño <castano@ludicon.com> + + This program is free software; you can redistribute it and/or + modify it under the terms of the Lesser GNU General Public +@@ -9,238 +10,376 @@ + + /* this code supports: + * reading: +- * run length encoded true color tga files +- * uncompressed true color tga files ++ * uncompressed and run length encoded indexed, grey and color tga files. ++ * image types 1, 2, 3, 9, 10 and 11. ++ * only RGB color maps with no more than 256 colors. ++ * pixel formats 8, 15, 24 and 32. + * writing: + * uncompressed true color tga files + */ + + #include "tga.h" + ++#include <assert.h> ++ + #include <qimage.h> + #include <qdatastream.h> + +-/* +- * uncompressed TGA magic header +- */ +-unsigned char targaMagic[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++#include <kdebug.h> + +-/* +- * compressed TGA magic header +- */ +-unsigned char compMagic[12] = { 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++typedef Q_UINT32 uint; ++typedef Q_UINT16 ushort; ++typedef Q_UINT8 uchar; ++ ++namespace { // Private. ++ ++ // Header format of saved files. ++ uchar targaMagic[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++ ++ enum TGAType { ++ TGA_TYPE_INDEXED = 1, ++ TGA_TYPE_RGB = 2, ++ TGA_TYPE_GREY = 3, ++ TGA_TYPE_RLE_INDEXED = 9, ++ TGA_TYPE_RLE_RGB = 10, ++ TGA_TYPE_RLE_GREY = 11 ++ }; ++ ++#define TGA_INTERLEAVE_MASK 0xc0 ++#define TGA_INTERLEAVE_NONE 0x00 ++#define TGA_INTERLEAVE_2WAY 0x40 ++#define TGA_INTERLEAVE_4WAY 0x80 ++ ++#define TGA_ORIGIN_MASK 0x30 ++#define TGA_ORIGIN_LEFT 0x00 ++#define TGA_ORIGIN_RIGHT 0x10 ++#define TGA_ORIGIN_LOWER 0x00 ++#define TGA_ORIGIN_UPPER 0x20 ++ ++ /** Tga Header. */ ++ struct TgaHeader { ++ uchar id_length; ++ uchar colormap_type; ++ uchar image_type; ++ ushort colormap_index; ++ ushort colormap_length; ++ uchar colormap_size; ++ ushort x_origin; ++ ushort y_origin; ++ ushort width; ++ ushort height; ++ uchar pixel_size; ++ uchar flags; + +-/* +- * the origin of the image (default is TOP_LEFT) +- */ +-enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; ++ enum { SIZE = 18 }; // const static int SIZE = 18; ++ }; + +-/* +- * Read one pixel and return its color +- */ +-int getData( QDataStream* s, int bpp ) +-{ +- unsigned char* data = new unsigned char[bpp]; ++ static QDataStream & operator>> ( QDataStream & s, TgaHeader & head ) ++ { ++ s >> head.id_length; ++ s >> head.colormap_type; ++ s >> head.image_type; ++ s >> head.colormap_index; ++ s >> head.colormap_length; ++ s >> head.colormap_size; ++ s >> head.x_origin; ++ s >> head.y_origin; ++ s >> head.width; ++ s >> head.height; ++ s >> head.pixel_size; ++ s >> head.flags; ++ return s; ++ } + +- for( int d = 0; d < bpp; d++ ) +- *s >> data[d]; ++ static bool IsSupported( const TgaHeader & head ) ++ { ++ if( head.image_type != TGA_TYPE_INDEXED && ++ head.image_type != TGA_TYPE_RGB && ++ head.image_type != TGA_TYPE_GREY && ++ head.image_type != TGA_TYPE_RLE_INDEXED && ++ head.image_type != TGA_TYPE_RLE_RGB && ++ head.image_type != TGA_TYPE_RLE_GREY ) ++ { ++ return false; ++ } ++ if( head.image_type == TGA_TYPE_INDEXED || ++ head.image_type == TGA_TYPE_RLE_INDEXED ) ++ { ++ if( head.colormap_length > 256 || head.colormap_size != 24 ) ++ { ++ return false; ++ } ++ } ++ if( head.width == 0 || head.height == 0 ) ++ { ++ return false; ++ } ++ if( head.pixel_size != 8 && head.pixel_size != 16 && ++ head.pixel_size != 24 && head.pixel_size != 32 ) ++ { ++ return false; ++ } ++ return true; ++ } + +- int color = 0; +- if( bpp == 4 ) +- color = qRgba( data[0], data[1], data[2], data[3] ); +- else +- color = qRgb( data[0], data[1], data[2] ); ++ struct Color555 { ++ ushort b : 5; ++ ushort g : 5; ++ ushort r : 5; ++ }; + +- delete [] data; +- return color; +-} ++ static bool HasAlpha( const TgaHeader & tga ) ++ { ++ return tga.pixel_size == 32; ++ } + +-/* +- * checks wether y is inside of the image +- * when origin is of mode m +- */ +-bool checky( int y, int h, int m ) +-{ +- if( m == TOP_LEFT ) +- return (y < h); +- else if( m == BOTTOM_LEFT || m == BOTTOM_RIGHT ) +- return ( y >= 0 ); ++ struct TgaHeaderInfo { ++ bool rle; ++ bool pal; ++ bool rgb; ++ bool grey; ++ bool supported; + +- return false; +-} ++ TgaHeaderInfo( const TgaHeader & tga ) : rle(false), pal(false), rgb(false), grey(false), supported(true) ++ { ++ switch( tga.image_type ) { ++ case TGA_TYPE_RLE_INDEXED: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_INDEXED: ++ if( tga.colormap_type!=1 || tga.colormap_size!=24 || tga.colormap_length>256 ) { ++ supported = false; ++ } ++ pal = true; ++ break; + +- /* +- * checks wether x is inside of the image +- * when origin is of mode m +- */ +- bool checkx( int x, int w, int m ) ++ case TGA_TYPE_RLE_RGB: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_RGB: ++ rgb = true; ++ break; ++ ++ case TGA_TYPE_RLE_GREY: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_GREY: ++ grey = true; ++ break; ++ ++ default: ++ // Error, unknown image type. ++ supported = false; ++ } ++ } ++ }; ++ ++ ++ ++ static bool LoadTGA( QDataStream & s, const TgaHeader & tga, QImage &img ) + { +- if( m == TOP_LEFT || m == BOTTOM_LEFT ) +- return (x < w); +- else if( m == BOTTOM_RIGHT ) +- return ( x >= 0 ); ++ // Create image. ++ if( !img.create( tga.width, tga.height, 32 )) { ++ return false; ++ } + ++ TgaHeaderInfo info(tga); ++ if( !info.supported ) { ++ // File not supported. ++ kdDebug(399) << "This TGA file is not supported." << endl; + return false; + } + +- void kimgio_tga_read( QImageIO *io ) +- { +- unsigned char header[6]; +- bool compressed = false; ++ // Enable alpha buffer for transparent images. ++ if( HasAlpha( tga ) ) { ++ img.setAlphaBuffer( true ); ++ } + +- QDataStream s( io->ioDevice() ); +- s.setByteOrder( QDataStream::LittleEndian ); ++ uint pixel_size = (tga.pixel_size/8); ++ uint size = tga.width * tga.height * pixel_size; + +- /* +- * check whether it is a targa file or not +- */ +- for( int i = 0; i < 12; i++ ) { +- unsigned char a; +- s >> a; +- if( a != targaMagic[i] && a!= compMagic[i]) { +- io->setImage( 0 ); +- io->setStatus( -1 ); +- return; ++ ++ // Read palette. ++ char palette[768]; ++ if( info.pal ) { ++ // @todo Support palettes in other formats! ++ s.readRawBytes( palette, 3 * tga.colormap_length ); + } + +- // check if it is a compressed targa file +- if( i == 2 && a == compMagic[i] ) +- compressed = true; +- } +- +- for( int i = 0; i < 6; i++ ) +- s >> header[i]; +- +- int width = header[1] * 256 + header[0]; +- int height = header[3] * 256 + header[2]; +- int bpp = header[4]; +- int bit = header[5]; +- int bytesPerPixel = bpp / 8; +- +- /* Bit values: +- * bit 0-3: number of alpha bits per fixel +- * bit 4-5: origin of image: +- * - 0 0 bottom left +- * - 1 0 bottom right +- * - 0 1 top left // that's what we write +- * - 1 1 top right +- */ ++ // Allocate image. ++ uchar * const image = new uchar[size]; + +- int mode; +- if( (bit | 0) == 0 ) +- mode = BOTTOM_LEFT; +- else if( (bit & 8) == 8 ) +- /* +- * should be BOTTOM_RIGHT, +- * but GIMP writes them this way. +- */ +- mode = BOTTOM_LEFT; +- else if( (bit & 32) == 32 ) +- mode = TOP_LEFT; +- else +- mode = TOP_LEFT; ++ if( info.rle ) { ++ // Decode image. ++ char * dst = (char *)image; ++ int num = size; ++ ++ while (num > 0) { ++ // Get packet header. ++ uchar c; ++ s >> c; ++ ++ uint count = (c & 0x7f) + 1; ++ num -= count * pixel_size; ++ ++ if (c & 0x80) { ++ // RLE pixels. ++ assert(pixel_size <= 8); ++ char pixel[8]; ++ s.readRawBytes( pixel, pixel_size ); ++ do { ++ memcpy(dst, pixel, pixel_size); ++ dst += pixel_size; ++ } while (--count); ++ } ++ else { ++ // Raw pixels. ++ count *= pixel_size; ++ s.readRawBytes( dst, count ); ++ dst += count; ++ } ++ } ++ } ++ else { ++ // Read raw image. ++ s.readRawBytes( (char *)image, size ); ++ } ++ ++ // Convert image to internal format. ++ int y_start, y_step, y_end; ++ if( tga.flags & TGA_ORIGIN_UPPER ) { ++ y_start = 0; ++ y_step = 1; ++ y_end = tga.height - 1; ++ } ++ else { ++ y_start = tga.height - 1; ++ y_step = -1; ++ y_end = 0; ++ } ++ ++ uchar * src = image; + +- if( bytesPerPixel != 3 && bytesPerPixel != 4 ) { ++ for( int y = y_start; y != y_end; y += y_step ) { ++ QRgb * scanline = (QRgb *) img.scanLine( y ); ++ ++ if( info.pal ) { ++ // Paletted. ++ for( int x = 0; x < tga.width; x++ ) { ++ uchar idx = *src++; ++ scanline[x] = qRgb( palette[3*idx+2], palette[3*idx+1], palette[3*idx+0] ); ++ } ++ } ++ else if( info.grey ) { ++ // Greyscale. ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgb( *src, *src, *src ); ++ src++; ++ } ++ } ++ else { ++ // True Color. ++ if( tga.pixel_size == 16 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ Color555 c = *reinterpret_cast<Color555 *>(src); ++ scanline[x] = qRgb( (c.r << 3) | (c.r >> 2), (c.g << 3) | (c.g >> 2), (c.b << 3) | (c.b >> 2) ); ++ src += 2; ++ } ++ } ++ else if( tga.pixel_size == 24 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgb( src[2], src[1], src[0] ); ++ src += 3; ++ } ++ } ++ else if( tga.pixel_size == 32 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgba( src[2], src[1], src[0], src[3] ); ++ src += 4; ++ } ++ } ++ } ++ } ++ ++ // Free image. ++ delete [] image; ++ ++ return true; ++ } ++ ++} // namespace ++ ++ ++void kimgio_tga_read( QImageIO *io ) ++{ ++ //kdDebug(399) << "Loading TGA file!" << endl; ++ ++ QDataStream s( io->ioDevice() ); ++ s.setByteOrder( QDataStream::LittleEndian ); ++ ++ ++ // Read image header. ++ TgaHeader tga; ++ s >> tga; ++ s.device()->at( TgaHeader::SIZE + tga.id_length ); ++ ++ // Check image file format. ++ if( s.atEnd() ) { ++ kdDebug(399) << "This TGA file is not valid." << endl; + io->setImage( 0 ); + io->setStatus( -1 ); + return; + } + +- QImage img; +- if( !img.create( width, height, (bpp == 24 ? 32 : bpp) )) { ++ // Check supported file types. ++ if( !IsSupported(tga) ) { ++ kdDebug(399) << "This TGA file is not supported." << endl; + io->setImage( 0 ); + io->setStatus( -1 ); + return; + } + +- /* +- * Enable alpha buffer for transparent images +- */ +- if( img.depth() == 32 ) +- img.setAlphaBuffer( true ); + ++ QImage img; ++ bool result = LoadTGA(s, tga, img); + +- int x = 0; +- int y = 0; +- int addy = 1; +- int addx = 1; +- if( mode == BOTTOM_LEFT || mode == BOTTOM_RIGHT ) { +- y = height - 1; +- addy = -1; +- } +- +- if( mode == BOTTOM_RIGHT || mode == TOP_RIGHT ) { +- x = width - 1; +- addx = -1; +- } +- +- /* +- * we have to restore the value of x after each loop +- */ +- int oldx = x; +- if( !compressed ) { +- for( ; checky( y, height, mode ); y += addy ) +- for( x = oldx; checkx( x, width, mode ); x += addx ) { +- img.setPixel( x, y, getData( &s, bytesPerPixel ) ); +- } +- } else { +- unsigned char cur; +- while( checky( y, height, mode ) ) { +- while( checkx( x, width, mode ) ) { +- s >> cur; +- if( (cur & 128) == 128 ) { +- // found a RLE chunk +- int length = (cur & 127) + 1; +- int color = getData( &s, bytesPerPixel ); +- for( int i = 0; i < length; i++ ) { +- img.setPixel( x, y, color ); +- x += addx; +- } +- } else { +- int length = (cur & 127) + 1; +- for( int i = 0; i < length; i++ ) { +- img.setPixel( x, y, getData( &s, bytesPerPixel ) ); +- x += addx; +- } +- } +- } +- y += addy; +- x = oldx; +- } ++ if( result == false ) { ++ kdDebug(399) << "Error loading TGA file." << endl; ++ io->setImage( 0 ); ++ io->setStatus( -1 ); ++ return; + } + +- img = img.swapRGB(); + + io->setImage( img ); + io->setStatus( 0 ); + } + + +-void kimgio_tga_write( QImageIO *io ) ++void kimgio_tga_write( QImageIO *io ) + { + QDataStream s( io->ioDevice() ); + s.setByteOrder( QDataStream::LittleEndian ); + +- QImage img = io->image().swapRGB(); ++ const QImage img = io->image(); ++ const bool hasAlpha = img.hasAlphaBuffer(); + for( int i = 0; i < 12; i++ ) + s << targaMagic[i]; + + // write header +- s << (unsigned char)0; +- s << (unsigned char)(img.width() / 256); // width +- s << (unsigned char)0; +- s << (unsigned char)(img.height() / 256); // height +- s << (unsigned char)img.depth(); // depth +- s << (unsigned char)36; ++ s << Q_UINT16( img.width() ); // width ++ s << Q_UINT16( img.height() ); // height ++ s << Q_UINT8( hasAlpha ? 32 : 24 ); // depth (24 bit RGB + 8 bit alpha) ++ s << Q_UINT8( hasAlpha ? 0x24 : 0x20 ); // top left image (0x20) + 8 bit alpha (0x4) + + for( int y = 0; y < img.height(); y++ ) + for( int x = 0; x < img.width(); x++ ) { +- int color = img.pixel( x, y ); +- s << (unsigned char)qRed( color ); +- s << (unsigned char)qGreen( color ); +- s << (unsigned char)qBlue( color ); +- if( img.depth() == 32 ) +- s << (unsigned char)qAlpha( color ); ++ const QRgb color = img.pixel( x, y ); ++ s << Q_UINT8( qBlue( color ) ); ++ s << Q_UINT8( qGreen( color ) ); ++ s << Q_UINT8( qRed( color ) ); ++ if( hasAlpha ) ++ s << Q_UINT8( qAlpha( color ) ); + } + + io->setStatus( 0 ); +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/tiffr.cpp kdelibs-3.2.5/work/kdelibs/kimgio/tiffr.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/tiffr.cpp 2002-09-30 09:23:07.000000000 +0200 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/tiffr.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -8,6 +8,7 @@ + + #include <qimage.h> + #include <qfile.h> ++ + + #include <assert.h> + +@@ -59,7 +60,7 @@ static void tiff_unmap( thandle_t, tdata + { + } + +-void kimgio_tiff_read( QImageIO *io ) ++void kimgio_tiff_read( QImageIO *io ) + { + TIFF *tiff; + uint32 width, height; +@@ -78,10 +79,15 @@ void kimgio_tiff_read( QImageIO *io ) + } + + // create image with loaded dimensions +- TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ); +- TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ); ++ if( TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ) != 1 ++ || TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ) != 1 ) ++ return; + + QImage image( width, height, 32 ); ++ if( image.isNull()) { ++ TIFFClose( tiff ); ++ return; ++ } + data = (uint32 *)image.bits(); + + //Sven: changed to %ld for 64bit machines +@@ -137,7 +143,7 @@ void kimgio_tiff_read( QImageIO *io ) + io->setStatus ( 0 ); + } + +-void kimgio_tiff_write( QImageIO * ) ++void kimgio_tiff_write( QImageIO * ) + { + // TODO: stub + } +diff -u -p -b kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/xview.cpp kdelibs-3.2.5/work/kdelibs/kimgio/xview.cpp +--- kdelibs-3.2.3-r9/work/kdelibs-3.2.3/kimgio/xview.cpp 2003-09-07 14:17:55.000000000 +0200 ++++ kdelibs-3.2.5/work/kdelibs/kimgio/xview.cpp 2005-04-20 14:07:22.000000000 +0200 +@@ -7,13 +7,19 @@ + + #include <stdio.h> + #include <string.h> ++#include <stdlib.h> + #include <qimage.h> + ++ ++ + #include "xview.h" + + #define BUFSIZE 1024 + +-void kimgio_xv_read( QImageIO *_imageio ) ++static const int b_255_3[]= {0,85,170,255}, // index*255/3 ++ rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 ++ ++void kimgio_xv_read( QImageIO *_imageio ) + { + int x=-1; + int y=-1; +@@ -48,10 +54,14 @@ void kimgio_xv_read( QImageIO *_imageio + sscanf(str, "%d %d %d", &x, &y, &maxval); + + if (maxval != 255) return; ++ int blocksize = x*y; ++ if(x < 0 || y < 0 || blocksize < x || blocksize < y) ++ return; + + // now follows a binary block of x*y bytes. +- int blocksize = x*y; +- char *block = new char[ blocksize ]; ++ char *block = (char*) malloc(blocksize); ++ if(!block) ++ return; + + if (iodev->readBlock(block, blocksize) != blocksize ) + { +@@ -60,6 +70,10 @@ void kimgio_xv_read( QImageIO *_imageio + + // Create the image + QImage image( x, y, 8, maxval + 1, QImage::BigEndian ); ++ if( image.isNull()) { ++ free(block); ++ return; ++ } + + // how do the color handling? they are absolute 24bpp + // or at least can be calculated as such. +@@ -67,29 +81,9 @@ void kimgio_xv_read( QImageIO *_imageio + + for ( int j = 0; j < 256; j++ ) + { +-// ----------- OLIVER EIDEN +-// That is the old-code ! +-/* r = ((int) ((j >> 5) & 0x07)) << 5; +- g = ((int) ((j >> 2) & 0x07)) << 5; +- b = ((int) ((j >> 0) & 0x03)) << 6;*/ +- +- +-// That is the code-how xv, decode 3-3-2 pixmaps, it is slighly different, +-// but yields much better visuals results +-/* r = (((int) ((j >> 5) & 0x07)) *255) / 7; +- g = (((int) ((j >> 2) & 0x07)) *255) / 7; +- b = (((int) ((j >> 0) & 0x03)) *255) / 3;*/ +- +-// This is the same as xv, with multiplications/divisions replaced by indexing +- +-// Look-up table to avoid multiplications and divisons +- static int b_255_3[]= {0,85,170,255}, // index*255/3 +- rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 +- + r = rg_255_7[((j >> 5) & 0x07)]; + g = rg_255_7[((j >> 2) & 0x07)]; + b = b_255_3[((j >> 0) & 0x03)]; +-// --------------- + image.setColor( j, qRgb( r, g, b ) ); + } + +@@ -102,11 +96,11 @@ void kimgio_xv_read( QImageIO *_imageio + _imageio->setImage( image ); + _imageio->setStatus( 0 ); + +- delete [] block; ++ free(block); + return; + } + +-void kimgio_xv_write( QImageIO *imageio ) ++void kimgio_xv_write( QImageIO *imageio ) + { + QIODevice& f = *( imageio->ioDevice() ); + diff --git a/kde-base/kdelibs/files/post-3.3.2-kdelibs-idn-2.patch b/kde-base/kdelibs/files/post-3.3.2-kdelibs-idn-2.patch new file mode 100644 index 000000000000..42211155d16e --- /dev/null +++ b/kde-base/kdelibs/files/post-3.3.2-kdelibs-idn-2.patch @@ -0,0 +1,127 @@ +Index: kresolver.cpp +=================================================================== +RCS file: /home/kde/kdelibs/kdecore/network/kresolver.cpp,v +retrieving revision 1.32.2.8 +retrieving revision 1.32.2.11 +diff -u -p -r1.32.2.8 -r1.32.2.11 +--- kdecore/network/kresolver.cpp 13 Jan 2005 19:10:37 -0000 1.32.2.8 ++++ kdecore/network/kresolver.cpp 16 Mar 2005 04:03:06 -0000 1.32.2.11 +@@ -32,6 +32,7 @@ + #include <time.h> + #include <arpa/inet.h> + #include <netinet/in.h> ++#include <stdlib.h> + + // Qt includes + #include <qapplication.h> +@@ -277,6 +278,9 @@ void KResolverResults::virtual_hook( int + /////////////////////// + // class KResolver + ++QStringList *KResolver::idnDomains = 0; ++ ++ + // default constructor + KResolver::KResolver(QObject *parent, const char *name) + : QObject(parent, name), d(new KResolverPrivate(this)) +@@ -864,10 +868,21 @@ QStrList KResolver::serviceName(int port + static QStringList splitLabels(const QString& unicodeDomain); + static QCString ToASCII(const QString& label); + static QString ToUnicode(const QString& label); +- ++ ++static QStringList *KResolver_initIdnDomains() ++{ ++ const char *kde_use_idn = getenv("KDE_USE_IDN"); ++ if (!kde_use_idn) ++ kde_use_idn = "at:ch:cn:de:dk:kr:jp:li:no:se:tw"; ++ return new QStringList(QStringList::split(':', QString::fromLatin1(kde_use_idn).lower())); ++} ++ + // implement the ToAscii function, as described by IDN documents + QCString KResolver::domainToAscii(const QString& unicodeDomain) + { ++ if (!idnDomains) ++ idnDomains = KResolver_initIdnDomains(); ++ + QCString retval; + // RFC 3490, section 4 describes the operation: + // 1) this is a query, so don't allow unassigned +@@ -876,6 +891,10 @@ QCString KResolver::domainToAscii(const + // separators. + QStringList input = splitLabels(unicodeDomain); + ++ // Do we allow IDN names for this TLD? ++ if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) ++ return unicodeDomain.lower().latin1(); // No IDN allowed for this TLD ++ + // 3) decide whether to enforce the STD3 rules for chars < 0x7F + // we don't enforce + +@@ -907,6 +926,8 @@ QString KResolver::domainToUnicode(const + { + if (asciiDomain.isEmpty()) + return asciiDomain; ++ if (!idnDomains) ++ idnDomains = KResolver_initIdnDomains(); + + QString retval; + +@@ -918,6 +939,10 @@ QString KResolver::domainToUnicode(const + // separators. + QStringList input = splitLabels(asciiDomain); + ++ // Do we allow IDN names for this TLD? ++ if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) ++ return asciiDomain.lower(); // No TLDs allowed ++ + // 3) decide whether to enforce the STD3 rules for chars < 0x7F + // we don't enforce + +Index: kresolver.h +=================================================================== +RCS file: /home/kde/kdelibs/kdecore/network/kresolver.h,v +retrieving revision 1.21 +retrieving revision 1.21.2.1 +diff -b -p -u -r1.21 -r1.21.2.1 +--- kdecore/network/kresolver.h 11 Jul 2004 18:46:00 -0000 1.21 ++++ kdecore/network/kresolver.h 3 Mar 2005 12:35:36 -0000 1.21.2.1 +@@ -926,6 +926,8 @@ private: + KResolverPrivate* d; + friend class KResolverResults; + friend class ::KNetwork::Internal::KResolverManager; ++ ++ static QStringList *idnDomains; + }; + + } // namespace KNetwork +Index: kio/kssl/ksslpeerinfo.cc +=================================================================== +RCS file: /home/kde/kdelibs/kio/kssl/ksslpeerinfo.cc,v +retrieving revision 1.44 +retrieving revision 1.44.6.2 +diff -u -p -r1.44 -r1.44.6.2 +--- kio/kssl/ksslpeerinfo.cc 29 May 2003 16:50:21 -0000 1.44 ++++ kio/kssl/ksslpeerinfo.cc 4 Mar 2005 12:16:17 -0000 1.44.6.2 +@@ -30,6 +30,9 @@ + #include <ksockaddr.h> + #include <kextsock.h> + #include <netsupp.h> ++#ifndef Q_WS_WIN //TODO kresolver not ported ++#include "network/kresolver.h" ++#endif + + #include "ksslx509map.h" + +@@ -59,7 +62,11 @@ void KSSLPeerInfo::setPeerHost(QString r + while(d->peerHost.endsWith(".")) + d->peerHost.truncate(d->peerHost.length()-1); + ++#ifdef Q_WS_WIN //TODO kresolver not ported + d->peerHost = d->peerHost.lower(); ++#else ++ d->peerHost = QString::fromLatin1(KNetwork::KResolver::domainToAscii(d->peerHost)); ++#endif + } + + bool KSSLPeerInfo::certMatchesAddress() { diff --git a/kde-base/kdelibs/files/post-3.3.2-kdelibs-kimgio.diff b/kde-base/kdelibs/files/post-3.3.2-kdelibs-kimgio.diff new file mode 100644 index 000000000000..1124725f9000 --- /dev/null +++ b/kde-base/kdelibs/files/post-3.3.2-kdelibs-kimgio.diff @@ -0,0 +1,1932 @@ +diff -u -3 -d -p -r1.4 -r1.4.2.1 +--- dds.cpp 2 Aug 2004 20:34:50 -0000 1.4 ++++ dds.cpp 19 Apr 2005 11:11:09 -0000 1.4.2.1 +@@ -26,6 +26,12 @@ + + #include <kdebug.h> + ++#include <math.h> // sqrtf ++ ++#ifndef __USE_ISOC99 ++#define sqrtf(x) ((float)sqrt(x)) ++#endif ++ + typedef Q_UINT32 uint; + typedef Q_UINT16 ushort; + typedef Q_UINT8 uchar; +@@ -44,34 +50,71 @@ namespace { // Private. + #define VERTICAL 2 + #define CUBE_LAYOUT HORIZONTAL + ++ struct Color8888 ++ { ++ uchar r, g, b, a; ++ }; + +- const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' '); +- const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'); +- const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'); +- const uint FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'); +- const uint FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'); +- const uint FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'); ++ union Color565 ++ { ++ struct { ++ ushort b : 5; ++ ushort g : 6; ++ ushort r : 5; ++ } c; ++ ushort u; ++ }; + +- const uint DDSD_CAPS = 0x00000001l; +- const uint DDSD_PIXELFORMAT = 0x00001000l; +- const uint DDSD_WIDTH = 0x00000004l; +- const uint DDSD_HEIGHT = 0x00000002l; +- const uint DDSD_PITCH = 0x00000008l; ++ union Color1555 { ++ struct { ++ ushort b : 5; ++ ushort g : 5; ++ ushort r : 5; ++ ushort a : 1; ++ } c; ++ ushort u; ++ }; + +- const uint DDSCAPS_TEXTURE = 0x00001000l; +- const uint DDSCAPS2_VOLUME = 0x00200000l; +- const uint DDSCAPS2_CUBEMAP = 0x00000200l; ++ union Color4444 { ++ struct { ++ ushort b : 4; ++ ushort g : 4; ++ ushort r : 4; ++ ushort a : 4; ++ } c; ++ ushort u; ++ }; + +- const uint DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400l; +- const uint DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800l; +- const uint DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000l; +- const uint DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000l; +- const uint DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000l; +- const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000l; + +- const uint DDPF_RGB = 0x00000040l; +- const uint DDPF_FOURCC = 0x00000004l; +- const uint DDPF_ALPHAPIXELS = 0x00000001l; ++ static const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' '); ++ static const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'); ++ static const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'); ++ static const uint FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'); ++ static const uint FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'); ++ static const uint FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'); ++ static const uint FOURCC_RXGB = MAKEFOURCC('R', 'X', 'G', 'B'); ++ static const uint FOURCC_ATI2 = MAKEFOURCC('A', 'T', 'I', '2'); ++ ++ static const uint DDSD_CAPS = 0x00000001l; ++ static const uint DDSD_PIXELFORMAT = 0x00001000l; ++ static const uint DDSD_WIDTH = 0x00000004l; ++ static const uint DDSD_HEIGHT = 0x00000002l; ++ static const uint DDSD_PITCH = 0x00000008l; ++ ++ static const uint DDSCAPS_TEXTURE = 0x00001000l; ++ static const uint DDSCAPS2_VOLUME = 0x00200000l; ++ static const uint DDSCAPS2_CUBEMAP = 0x00000200l; ++ ++ static const uint DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400l; ++ static const uint DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800l; ++ static const uint DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000l; ++ static const uint DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000l; ++ static const uint DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000l; ++ static const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000l; ++ ++ static const uint DDPF_RGB = 0x00000040l; ++ static const uint DDPF_FOURCC = 0x00000004l; ++ static const uint DDPF_ALPHAPIXELS = 0x00000001l; + + enum DDSType { + DDS_A8R8G8B8 = 0, +@@ -84,6 +127,8 @@ namespace { // Private. + DDS_DXT3 = 7, + DDS_DXT4 = 8, + DDS_DXT5 = 9, ++ DDS_RXGB = 10, ++ DDS_ATI2 = 11, + DDS_UNKNOWN + }; + +@@ -99,7 +144,7 @@ namespace { // Private. + uint amask; + }; + +- QDataStream & operator>> ( QDataStream & s, DDSPixelFormat & pf ) ++ static QDataStream & operator>> ( QDataStream & s, DDSPixelFormat & pf ) + { + s >> pf.size; + s >> pf.flags; +@@ -119,7 +164,7 @@ namespace { // Private. + uint caps4; + }; + +- QDataStream & operator>> ( QDataStream & s, DDSCaps & caps ) ++ static QDataStream & operator>> ( QDataStream & s, DDSCaps & caps ) + { + s >> caps.caps1; + s >> caps.caps2; +@@ -142,7 +187,7 @@ namespace { // Private. + uint notused; + }; + +- QDataStream & operator>> ( QDataStream & s, DDSHeader & header ) ++ static QDataStream & operator>> ( QDataStream & s, DDSHeader & header ) + { + s >> header.size; + s >> header.flags; +@@ -160,7 +205,7 @@ namespace { // Private. + return s; + } + +- bool IsValid( const DDSHeader & header ) ++ static bool IsValid( const DDSHeader & header ) + { + if( header.size != 124 ) { + return false; +@@ -180,7 +225,7 @@ namespace { // Private. + + + // Get supported type. We currently support 10 different types. +- DDSType GetType( const DDSHeader & header ) ++ static DDSType GetType( const DDSHeader & header ) + { + if( header.pf.flags & DDPF_RGB ) { + if( header.pf.flags & DDPF_ALPHAPIXELS ) { +@@ -212,27 +257,28 @@ namespace { // Private. + return DDS_DXT4; + case FOURCC_DXT5: + return DDS_DXT5; ++ case FOURCC_RXGB: ++ return DDS_RXGB; ++ case FOURCC_ATI2: ++ return DDS_ATI2; + } + } + return DDS_UNKNOWN; + } + + +- bool HasAlpha( const DDSHeader & header ) ++ static bool HasAlpha( const DDSHeader & header ) + { + return header.pf.flags & DDPF_ALPHAPIXELS; + } + +- bool IsCubeMap( const DDSHeader & header ) ++ static bool IsCubeMap( const DDSHeader & header ) + { + return header.caps.caps2 & DDSCAPS2_CUBEMAP; + } + +- bool IsSupported( const DDSHeader & header ) ++ static bool IsSupported( const DDSHeader & header ) + { +- /*if( IsCubeMap(header) ) { +- return false; +- }*/ + if( header.caps.caps2 & DDSCAPS2_VOLUME ) { + return false; + } +@@ -243,7 +289,7 @@ namespace { // Private. + } + + +- bool LoadA8R8G8B8( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadA8R8G8B8( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -260,7 +306,7 @@ namespace { // Private. + return true; + } + +- bool LoadR8G8B8( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadR8G8B8( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -277,7 +323,7 @@ namespace { // Private. + return true; + } + +- bool LoadA1R5G5B5( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadA1R5G5B5( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -285,13 +331,12 @@ namespace { // Private. + for( uint y = 0; y < h; y++ ) { + QRgb * scanline = (QRgb *) img.scanLine( y ); + for( uint x = 0; x < w; x++ ) { +- ushort u; +- s >> u; +- uchar r, g, b, a; +- a = (u & header.pf.amask) != 0 ? 0xFF : 0; +- r = ((u & header.pf.rmask) >> 10) << 3; +- g = ((u & header.pf.gmask) >> 5) << 3; +- b = (u & header.pf.bmask) << 3; ++ Color1555 color; ++ s >> color.u; ++ uchar a = (color.c.a != 0) ? 0xFF : 0; ++ uchar r = (color.c.r << 3) | (color.c.r >> 2); ++ uchar g = (color.c.g << 3) | (color.c.g >> 2); ++ uchar b = (color.c.b << 3) | (color.c.b >> 2); + scanline[x] = qRgba(r, g, b, a); + } + } +@@ -299,7 +344,7 @@ namespace { // Private. + return true; + } + +- bool LoadA4R4G4B4( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadA4R4G4B4( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -307,13 +352,12 @@ namespace { // Private. + for( uint y = 0; y < h; y++ ) { + QRgb * scanline = (QRgb *) img.scanLine( y ); + for( uint x = 0; x < w; x++ ) { +- unsigned short u; +- s >> u; +- uchar r, g, b, a; +- a = ((u & header.pf.amask) >> 12) << 4; +- r = ((u & header.pf.rmask) >> 8) << 4; +- g = ((u & header.pf.gmask) >> 4) << 4; +- b = (u & header.pf.bmask) << 4; ++ Color4444 color; ++ s >> color.u; ++ uchar a = (color.c.a << 4) | color.c.a; ++ uchar r = (color.c.r << 4) | color.c.r; ++ uchar g = (color.c.g << 4) | color.c.g; ++ uchar b = (color.c.b << 4) | color.c.b; + scanline[x] = qRgba(r, g, b, a); + } + } +@@ -321,7 +365,7 @@ namespace { // Private. + return true; + } + +- bool LoadR5G6B5( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadR5G6B5( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -329,12 +373,11 @@ namespace { // Private. + for( uint y = 0; y < h; y++ ) { + QRgb * scanline = (QRgb *) img.scanLine( y ); + for( uint x = 0; x < w; x++ ) { +- unsigned short u; +- s >> u; +- uchar r, g, b; +- r = ((u & header.pf.rmask) >> 11) << 3; +- g = ((u & header.pf.gmask) >> 5) << 2; +- b = (u & header.pf.bmask) << 3; ++ Color565 color; ++ s >> color.u; ++ uchar r = (color.c.r << 3) | (color.c.r >> 2); ++ uchar g = (color.c.g << 2) | (color.c.g >> 4); ++ uchar b = (color.c.b << 3) | (color.c.b >> 2); + scanline[x] = qRgb(r, g, b); + } + } +@@ -342,22 +385,7 @@ namespace { // Private. + return true; + } + +- struct Color8888 +- { +- uchar r, g, b, a; +- }; +- +- union Color565 +- { +- struct { +- ushort b : 5; +- ushort g : 6; +- ushort r : 5; +- } c; +- ushort u; +- }; +- +- QDataStream & operator>> ( QDataStream & s, Color565 & c ) ++ static QDataStream & operator>> ( QDataStream & s, Color565 & c ) + { + return s >> c.u; + } +@@ -400,17 +428,17 @@ namespace { // Private. + color_array[2].b = (color_array[0].b + color_array[1].b) / 2; + color_array[2].a = 0xFF; + +- // magenta to indicate transparent color. +- color_array[3].r = color_array[2].r; +- color_array[3].g = color_array[2].g; +- color_array[3].b = color_array[2].b; ++ // Set all components to 0 to match DXT specs. ++ color_array[3].r = 0x00; // color_array[2].r; ++ color_array[3].g = 0x00; // color_array[2].g; ++ color_array[3].b = 0x00; // color_array[2].b; + color_array[3].a = 0x00; + } + } + }; + + +- QDataStream & operator>> ( QDataStream & s, BlockDXT & c ) ++ static QDataStream & operator>> ( QDataStream & s, BlockDXT & c ) + { + return s >> c.col0 >> c.col1 >> c.row[0] >> c.row[1] >> c.row[2] >> c.row[3]; + } +@@ -419,7 +447,7 @@ namespace { // Private. + ushort row[4]; + }; + +- QDataStream & operator>> ( QDataStream & s, BlockDXTAlphaExplicit & c ) ++ static QDataStream & operator>> ( QDataStream & s, BlockDXTAlphaExplicit & c ) + { + return s >> c.row[0] >> c.row[1] >> c.row[2] >> c.row[3]; + } +@@ -485,13 +513,13 @@ namespace { // Private. + } + }; + +- QDataStream & operator>> ( QDataStream & s, BlockDXTAlphaLinear & c ) ++ static QDataStream & operator>> ( QDataStream & s, BlockDXTAlphaLinear & c ) + { + s >> c.alpha0 >> c.alpha1; + return s >> c.bits[0] >> c.bits[1] >> c.bits[2] >> c.bits[3] >> c.bits[4] >> c.bits[5]; + } + +- bool LoadDXT1( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadDXT1( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -530,7 +558,7 @@ namespace { // Private. + return true; + } + +- bool LoadDXT3( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadDXT3( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -575,14 +603,14 @@ namespace { // Private. + return true; + } + +- bool LoadDXT2( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadDXT2( QDataStream & s, const DDSHeader & header, QImage & img ) + { + if( !LoadDXT3(s, header, img) ) return false; + //UndoPremultiplyAlpha(img); + return true; + } + +- bool LoadDXT5( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadDXT5( QDataStream & s, const DDSHeader & header, QImage & img ) + { + const uint w = header.width; + const uint h = header.height; +@@ -630,19 +658,122 @@ namespace { // Private. + + return true; + } +- +- bool LoadDXT4( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadDXT4( QDataStream & s, const DDSHeader & header, QImage & img ) + { + if( !LoadDXT5(s, header, img) ) return false; + //UndoPremultiplyAlpha(img); + return true; + } + ++ static bool LoadRXGB( QDataStream & s, const DDSHeader & header, QImage & img ) ++ { ++ const uint w = header.width; ++ const uint h = header.height; ++ ++ BlockDXT block; ++ BlockDXTAlphaLinear alpha; ++ QRgb * scanline[4]; + +- typedef bool (* TextureLoader)( QDataStream & s, const DDSHeader & header, QImage img ); ++ for( uint y = 0; y < h; y += 4 ) { ++ for( uint j = 0; j < 4; j++ ) { ++ scanline[j] = (QRgb *) img.scanLine( y + j ); ++ } ++ for( uint x = 0; x < w; x += 4 ) { ++ ++ // Read 128bit color block. ++ s >> alpha; ++ s >> block; ++ ++ // Decode color block. ++ Color8888 color_array[4]; ++ block.GetColors(color_array); ++ ++ uchar alpha_array[8]; ++ alpha.GetAlphas(alpha_array); ++ ++ uchar bit_array[16]; ++ alpha.GetBits(bit_array); ++ ++ // bit masks = 00000011, 00001100, 00110000, 11000000 ++ const uint masks[4] = { 3, 3<<2, 3<<4, 3<<6 }; ++ const int shift[4] = { 0, 2, 4, 6 }; ++ ++ // Write color block. ++ for( uint j = 0; j < 4; j++ ) { ++ for( uint i = 0; i < 4; i++ ) { ++ if( img.valid( x+i, y+j ) ) { ++ uint idx = (block.row[j] & masks[i]) >> shift[i]; ++ color_array[idx].a = alpha_array[bit_array[j*4+i]]; ++ scanline[j][x+i] = qRgb(color_array[idx].a, color_array[idx].g, color_array[idx].b); ++ } ++ } ++ } ++ } ++ } ++ ++ return true; ++ } ++ ++ static bool LoadATI2( QDataStream & s, const DDSHeader & header, QImage & img ) ++ { ++ const uint w = header.width; ++ const uint h = header.height; ++ ++ BlockDXTAlphaLinear xblock; ++ BlockDXTAlphaLinear yblock; ++ QRgb * scanline[4]; ++ ++ for( uint y = 0; y < h; y += 4 ) { ++ for( uint j = 0; j < 4; j++ ) { ++ scanline[j] = (QRgb *) img.scanLine( y + j ); ++ } ++ for( uint x = 0; x < w; x += 4 ) { ++ ++ // Read 128bit color block. ++ s >> xblock; ++ s >> yblock; ++ ++ // Decode color block. ++ uchar xblock_array[8]; ++ xblock.GetAlphas(xblock_array); ++ ++ uchar xbit_array[16]; ++ xblock.GetBits(xbit_array); ++ ++ uchar yblock_array[8]; ++ yblock.GetAlphas(yblock_array); ++ ++ uchar ybit_array[16]; ++ yblock.GetBits(ybit_array); ++ ++ // Write color block. ++ for( uint j = 0; j < 4; j++ ) { ++ for( uint i = 0; i < 4; i++ ) { ++ if( img.valid( x+i, y+j ) ) { ++ const uchar nx = xblock_array[xbit_array[j*4+i]]; ++ const uchar ny = yblock_array[ybit_array[j*4+i]]; ++ ++ const float fx = float(nx) / 127.5f - 1.0f; ++ const float fy = float(ny) / 127.5f - 1.0f; ++ const float fz = sqrtf(1.0f - fx*fx - fy*fy); ++ const uchar nz = uchar((fz + 1.0f) * 127.5f); ++ ++ scanline[j][x+i] = qRgb(nx, ny, nz); ++ } ++ } ++ } ++ } ++ } ++ ++ return true; ++ } ++ ++ ++ ++ typedef bool (* TextureLoader)( QDataStream & s, const DDSHeader & header, QImage & img ); + + // Get an appropiate texture loader for the given type. +- TextureLoader GetTextureLoader( DDSType type ) { ++ static TextureLoader GetTextureLoader( DDSType type ) { + switch( type ) { + case DDS_A8R8G8B8: + return LoadA8R8G8B8; +@@ -664,6 +795,10 @@ namespace { // Private. + return LoadDXT4; + case DDS_DXT5: + return LoadDXT5; ++ case DDS_RXGB: ++ return LoadRXGB; ++ case DDS_ATI2: ++ return LoadATI2; + default: + return NULL; + }; +@@ -671,7 +806,7 @@ namespace { // Private. + + + // Load a 2d texture. +- bool LoadTexture( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadTexture( QDataStream & s, const DDSHeader & header, QImage & img ) + { + // Create dst image. + if( !img.create( header.width, header.height, 32 )) { +@@ -695,7 +830,7 @@ namespace { // Private. + } + + +- int FaceOffset( const DDSHeader & header ) { ++ static int FaceOffset( const DDSHeader & header ) { + + DDSType type = GetType( header ); + +@@ -727,11 +862,11 @@ namespace { // Private. + } + + #if CUBE_LAYOUT == HORIZONTAL +- int face_offset[6][2] = { {2, 1}, {0, 1}, {1, 0}, {1, 2}, {1, 1}, {3, 1} }; ++ static int face_offset[6][2] = { {2, 1}, {0, 1}, {1, 0}, {1, 2}, {1, 1}, {3, 1} }; + #elif CUBE_LAYOUT == VERTICAL +- int face_offset[6][2] = { {2, 1}, {0, 1}, {1, 0}, {1, 2}, {1, 1}, {1, 3} }; ++ static int face_offset[6][2] = { {2, 1}, {0, 1}, {1, 0}, {1, 2}, {1, 1}, {1, 3} }; + #endif +- int face_flags[6] = { ++ static int face_flags[6] = { + DDSCAPS2_CUBEMAP_POSITIVEX, + DDSCAPS2_CUBEMAP_NEGATIVEX, + DDSCAPS2_CUBEMAP_POSITIVEY, +@@ -741,7 +876,7 @@ namespace { // Private. + }; + + // Load unwrapped cube map. +- bool LoadCubeMap( QDataStream & s, const DDSHeader & header, QImage img ) ++ static bool LoadCubeMap( QDataStream & s, const DDSHeader & header, QImage & img ) + { + // Create dst image. + #if CUBE_LAYOUT == HORIZONTAL +diff -u -3 -d -p -r1.3 -r1.3.2.1 +--- exr.cpp 9 Jun 2004 08:28:36 -0000 1.3 ++++ exr.cpp 19 Apr 2005 11:11:09 -0000 1.3.2.1 +@@ -136,6 +136,8 @@ void kimgio_exr_read( QImageIO *io ) + file.readPixels (dw.min.y, dw.max.y); + + QImage image(width, height, 32, 0, QImage::BigEndian); ++ if( image.isNull()) ++ return; + + // somehow copy pixels into image + for ( int y=0; y < height; y++ ) { +diff -u -3 -d -p -r1.21 -r1.21.2.1 +--- ico.cpp 9 Jun 2004 08:28:36 -0000 1.21 ++++ ico.cpp 19 Apr 2005 11:11:09 -0000 1.21.2.1 +@@ -113,6 +113,8 @@ namespace + // closest size match precedes everything else + if ( std::abs( int( lhs.width - size ) ) < + std::abs( int( rhs.width - size ) ) ) return true; ++ else if ( std::abs( int( lhs.width - size ) ) > ++ std::abs( int( rhs.width - size ) ) ) return false; + else if ( colors == 0 ) + { + // high/true color requested +@@ -144,17 +146,31 @@ namespace + header.biBitCount != 8 && header.biBitCount != 24 && + header.biBitCount != 32 ) ) return false; + +- unsigned colors = header.biBitCount >= 24 ? +- 0 : header.biClrUsed ? +- header.biClrUsed : 1 << header.biBitCount; ++ unsigned paletteSize, paletteEntries; ++ ++ if (header.biBitCount > 8) ++ { ++ paletteEntries = 0; ++ paletteSize = 0; ++ } ++ else ++ { ++ paletteSize = (1 << header.biBitCount); ++ paletteEntries = paletteSize; ++ if (header.biClrUsed && header.biClrUsed < paletteSize) ++ paletteEntries = header.biClrUsed; ++ } ++ + // Always create a 32-bit image to get the mask right ++ // Note: this is safe as rec.width, rec.height are bytes + icon.create( rec.width, rec.height, 32 ); + if ( icon.isNull() ) return false; + icon.setAlphaBuffer( true ); + +- QMemArray< QRgb > colorTable( 1 << header.biBitCount ); ++ QMemArray< QRgb > colorTable( paletteSize ); ++ + colorTable.fill( QRgb( 0 ) ); +- for ( unsigned i = 0; i < colors; ++i ) ++ for ( unsigned i = 0; i < paletteEntries; ++i ) + { + unsigned char rgb[ 4 ]; + stream.readRawBytes( reinterpret_cast< char* >( &rgb ), +@@ -163,6 +179,7 @@ namespace + } + + unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4; ++ + unsigned char* buf = new unsigned char[ bpl ]; + unsigned char** lines = icon.jumpTable(); + for ( unsigned y = rec.height; !stream.atEnd() && y--; ) +@@ -265,11 +282,13 @@ extern "C" void kimgio_ico_read( QImageI + stream >> rec; + icons.push_back( rec ); + } +- IconList::const_iterator selected = +- requestedIndex >= 0 ? +- std::min( icons.begin() + requestedIndex, icons.end() ) : +- std::min_element( icons.begin(), icons.end(), ++ IconList::const_iterator selected; ++ if (requestedIndex >= 0) { ++ selected = std::min( icons.begin() + requestedIndex, icons.end() ); ++ } else { ++ selected = std::min_element( icons.begin(), icons.end(), + LessDifference( requestedSize, requestedColors ) ); ++ } + if ( stream.atEnd() || selected == icons.end() || + offset + selected->offset > io->ioDevice()->size() ) + return; +diff -u -3 -d -p -r1.13 -r1.13.6.1 +--- jp2.cpp 30 Sep 2003 12:49:01 -0000 1.13 ++++ jp2.cpp 19 Apr 2005 11:11:09 -0000 1.13.6.1 +@@ -157,8 +157,9 @@ namespace { + void + draw_view_gray( gs_t& gs, QImage& qti ) + { +- qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), +- 8, 256 ); ++ if( !qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), ++ 8, 256 )) ++ return; + for( int i = 0; i < 256; ++i ) + qti.setColor( i, qRgb( i, i, i ) ); + +diff -u -3 -d -p -r1.11 -r1.11.6.1 +--- pcx.cpp 23 Oct 2003 13:17:27 -0000 1.11 ++++ pcx.cpp 19 Apr 2005 11:11:09 -0000 1.11.6.1 +@@ -1,5 +1,5 @@ + /* This file is part of the KDE project +- Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> ++ Copyright (C) 2002-2005 Nadeem Hasan <nhasan@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public +@@ -44,6 +44,11 @@ static QDataStream &operator>>( QDataStr + s >> ph.HScreenSize; + s >> ph.VScreenSize; + ++ // Skip the rest of the header ++ Q_UINT8 byte; ++ while ( s.device()->at() < 128 ) ++ s >> byte; ++ + return s; + } + +@@ -85,25 +90,22 @@ static QDataStream &operator<<( QDataStr + return s; + } + +-static PCXHEADER header; +-static QImage img; +-static Q_UINT16 w, h; +- +-void PCXHEADER::reset() ++PCXHEADER::PCXHEADER() + { ++ // Initialize all data to zero + QByteArray dummy( 128 ); + dummy.fill( 0 ); + QDataStream s( dummy, IO_ReadOnly ); + s >> *this; + } + +-static void readLine( QDataStream &s, QByteArray &buf ) ++static void readLine( QDataStream &s, QByteArray &buf, const PCXHEADER &header ) + { + Q_UINT32 i=0; + Q_UINT32 size = buf.size(); + Q_UINT8 byte, count; + +- if ( header.Encoding == 1 ) ++ if ( header.isCompressed() ) + { + // Uncompress the image data + while ( i < size ) +@@ -130,13 +132,14 @@ static void readLine( QDataStream &s, QB + } + } + +-static void readImage1( QDataStream &s ) ++static void readImage1( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 1, 2, QImage::BigEndian ); ++ if(!img.create( header.width(), header.height(), 1, 2, QImage::BigEndian )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -144,10 +147,11 @@ static void readImage1( QDataStream &s ) + return; + } + +- readLine( s, buf ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *( img.scanLine( y )+x ) = buf[ x ]; ++ readLine( s, buf, header ); ++ uchar *p = img.scanLine( y ); ++ unsigned int bpl = QMIN((header.width()+7)/8, header.BytesPerLine); ++ for ( unsigned int x=0; x< bpl; ++x ) ++ p[ x ] = buf[x]; + } + + // Set the color palette +@@ -155,14 +159,15 @@ static void readImage1( QDataStream &s ) + img.setColor( 1, qRgb( 255, 255, 255 ) ); + } + +-static void readImage4( QDataStream &s ) ++static void readImage4( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine*4 ); +- QByteArray pixbuf( w ); ++ QByteArray pixbuf( header.width() ); + +- img.create( w, h, 8, 16, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 16 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -171,20 +176,19 @@ static void readImage4( QDataStream &s ) + } + + pixbuf.fill( 0 ); +- readLine( s, buf ); ++ readLine( s, buf, header ); + + for ( int i=0; i<4; i++ ) + { + Q_UINT32 offset = i*header.BytesPerLine; +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + if ( buf[ offset + ( x/8 ) ] & ( 128 >> ( x%8 ) ) ) + pixbuf[ x ] += ( 1 << i ); + } + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<w; ++x ) +- *p++ = pixbuf[ x ]; ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = pixbuf[ x ]; + } + + // Read the palette +@@ -192,13 +196,14 @@ static void readImage4( QDataStream &s ) + img.setColor( i, header.ColorMap.color( i ) ); + } + +-static void readImage8( QDataStream &s ) ++static void readImage8( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 8, 256, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 256 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -206,19 +211,19 @@ static void readImage8( QDataStream &s ) + return; + } + +- readLine( s, buf ); ++ readLine( s, buf, header ); + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = buf[ x ]; ++ unsigned int bpl = QMIN(header.BytesPerLine, header.width()); ++ for ( unsigned int x=0; x<bpl; ++x ) ++ p[ x ] = buf[ x ]; + } + + Q_UINT8 flag; + s >> flag; +- kdDebug() << "Flag: " << flag << endl; ++ kdDebug( 399 ) << "Palette Flag: " << flag << endl; + +- if ( flag == 12 && header.Version == 5 ) ++ if ( flag == 12 && ( header.Version == 5 || header.Version == 2 ) ) + { + // Read the palette + Q_UINT8 r, g, b; +@@ -230,15 +235,16 @@ static void readImage8( QDataStream &s ) + } + } + +-static void readImage24( QDataStream &s ) ++static void readImage24( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray r_buf( header.BytesPerLine ); + QByteArray g_buf( header.BytesPerLine ); + QByteArray b_buf( header.BytesPerLine ); + +- img.create( w, h, 32 ); ++ if(!img.create( header.width(), header.height(), 32 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -246,14 +252,13 @@ static void readImage24( QDataStream &s + return; + } + +- readLine( s, r_buf ); +- readLine( s, g_buf ); +- readLine( s, b_buf ); ++ readLine( s, r_buf, header ); ++ readLine( s, g_buf, header ); ++ readLine( s, b_buf, header ); + + uint *p = ( uint * )img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); + } + } + +@@ -268,6 +273,8 @@ void kimgio_pcx_read( QImageIO *io ) + return; + } + ++ PCXHEADER header; ++ + s >> header; + + if ( header.Manufacturer != 10 || s.atEnd()) +@@ -276,10 +283,8 @@ void kimgio_pcx_read( QImageIO *io ) + return; + } + +- w = ( header.XMax-header.XMin ) + 1; +- h = ( header.YMax-header.YMin ) + 1; +- +- img.reset(); ++ int w = header.width(); ++ int h = header.height(); + + kdDebug( 399 ) << "Manufacturer: " << header.Manufacturer << endl; + kdDebug( 399 ) << "Version: " << header.Version << endl; +@@ -288,30 +293,27 @@ void kimgio_pcx_read( QImageIO *io ) + kdDebug( 399 ) << "Width: " << w << endl; + kdDebug( 399 ) << "Height: " << h << endl; + kdDebug( 399 ) << "Window: " << header.XMin << "," << header.XMax << "," +- << header.YMin << "," << header.YMax << endl; ++ << header.YMin << "," << header.YMax << endl; + kdDebug( 399 ) << "BytesPerLine: " << header.BytesPerLine << endl; + kdDebug( 399 ) << "NPlanes: " << header.NPlanes << endl; + +- // Skip the rest of the header +- Q_UINT8 byte; +- while ( s.device()->at() < 128 ) +- s >> byte; ++ QImage img; + + if ( header.Bpp == 1 && header.NPlanes == 1 ) + { +- readImage1( s ); ++ readImage1( img, s, header ); + } + else if ( header.Bpp == 1 && header.NPlanes == 4 ) + { +- readImage4( s ); ++ readImage4( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 1 ) + { +- readImage8( s ); ++ readImage8( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 3 ) + { +- readImage24( s ); ++ readImage24( img, s, header ); + } + + kdDebug( 399 ) << "Image Bytes: " << img.numBytes() << endl; +@@ -359,7 +361,7 @@ static void writeLine( QDataStream &s, Q + } + } + +-static void writeImage1( QDataStream &s ) ++static void writeImage1( QImage &img, QDataStream &s, PCXHEADER &header ) + { + img = img.convertBitOrder( QImage::BigEndian ); + +@@ -367,29 +369,27 @@ static void writeImage1( QDataStream &s + header.NPlanes = 1; + header.BytesPerLine = img.bytesPerLine(); + +- header.ColorMap.setColor( 0, qRgb( 0, 0, 0 ) ); +- header.ColorMap.setColor( 1, qRgb( 255, 255, 255 ) ); +- + s << header; + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + ++ // Invert as QImage uses reverse palette for monochrome images? + for ( int i=0; i<header.BytesPerLine; ++i ) +- buf[ i ] = p[ i ]; ++ buf[ i ] = ~p[ i ]; + + writeLine( s, buf ); + } + } + +-static void writeImage4( QDataStream &s ) ++static void writeImage4( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 1; + header.NPlanes = 4; +- header.BytesPerLine = w/8; ++ header.BytesPerLine = header.width()/8; + + for ( int i=0; i<16; ++i ) + header.ColorMap.setColor( i, img.color( i ) ); +@@ -401,14 +401,14 @@ static void writeImage4( QDataStream &s + for ( int i=0; i<4; ++i ) + buf[ i ].resize( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + + for ( int i=0; i<4; ++i ) + buf[ i ].fill( 0 ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + for ( int i=0; i<4; ++i ) + if ( *( p+x ) & ( 1 << i ) ) +@@ -420,7 +420,7 @@ static void writeImage4( QDataStream &s + } + } + +-static void writeImage8( QDataStream &s ) ++static void writeImage8( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 1; +@@ -430,7 +430,7 @@ static void writeImage8( QDataStream &s + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + +@@ -449,23 +449,23 @@ static void writeImage8( QDataStream &s + s << RGB( img.color( i ) ); + } + +-static void writeImage24( QDataStream &s ) ++static void writeImage24( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 3; +- header.BytesPerLine = w; ++ header.BytesPerLine = header.width(); + + s << header; + +- QByteArray r_buf( w ); +- QByteArray g_buf( w ); +- QByteArray b_buf( w ); ++ QByteArray r_buf( header.width() ); ++ QByteArray g_buf( header.width() ); ++ QByteArray b_buf( header.width() ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + uint *p = ( uint * )img.scanLine( y ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + QRgb rgb = *p++; + r_buf[ x ] = qRed( rgb ); +@@ -484,10 +484,10 @@ void kimgio_pcx_write( QImageIO *io ) + QDataStream s( io->ioDevice() ); + s.setByteOrder( QDataStream::LittleEndian ); + +- img = io->image(); ++ QImage img = io->image(); + +- w = img.width(); +- h = img.height(); ++ int w = img.width(); ++ int h = img.height(); + + kdDebug( 399 ) << "Width: " << w << endl; + kdDebug( 399 ) << "Height: " << h << endl; +@@ -495,6 +495,8 @@ void kimgio_pcx_write( QImageIO *io ) + kdDebug( 399 ) << "BytesPerLine: " << img.bytesPerLine() << endl; + kdDebug( 399 ) << "Num Colors: " << img.numColors() << endl; + ++ PCXHEADER header; ++ + header.Manufacturer = 10; + header.Version = 5; + header.Encoding = 1; +@@ -509,19 +511,19 @@ void kimgio_pcx_write( QImageIO *io ) + + if ( img.depth() == 1 ) + { +- writeImage1( s ); ++ writeImage1( img, s, header ); + } + else if ( img.depth() == 8 && img.numColors() <= 16 ) + { +- writeImage4( s ); ++ writeImage4( img, s, header ); + } + else if ( img.depth() == 8 ) + { +- writeImage8( s ); ++ writeImage8( img, s, header ); + } + else if ( img.depth() == 32 ) + { +- writeImage24( s ); ++ writeImage24( img, s, header ); + } + + io->setStatus( 0 ); +Index: pcx.h +=================================================================== +RCS file: /home/kde/kdelibs/kimgio/pcx.h,v +retrieving revision 1.4 +retrieving revision 1.4.6.1 +diff -u -3 -d -p -r1.4 -r1.4.6.1 +--- pcx.h 4 Jan 2003 00:48:25 -0000 1.4 ++++ pcx.h 19 Apr 2005 11:11:09 -0000 1.4.6.1 +@@ -49,7 +49,7 @@ class Palette + rgb[ i ] = RGB( color ); + } + +- QRgb color( int i ) ++ QRgb color( int i ) const + { + return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); + } +@@ -60,12 +60,11 @@ class Palette + class PCXHEADER + { + public: +- PCXHEADER() +- { +- reset(); +- } ++ PCXHEADER(); + +- void reset(); ++ inline int width() const { return ( XMax-XMin ) + 1; } ++ inline int height() const { return ( YMax-YMin ) + 1; } ++ inline bool isCompressed() const { return ( Encoding==1 ); } + + Q_UINT8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx + Q_UINT8 Version; // Version information· +@@ -99,7 +98,7 @@ class PCXHEADER + // found only in PB IV/IV Plus + Q_UINT16 VScreenSize; // Vertical screen size in pixels. New field + // found only in PB IV/IV Plus +-}; ++} KDE_PACKED; + + #endif // PCX_H + +diff -u -3 -d -p -r1.25 -r1.25.2.1 +--- rgb.cpp 9 Jun 2004 08:28:36 -0000 1.25 ++++ rgb.cpp 19 Apr 2005 11:11:09 -0000 1.25.2.1 +@@ -87,7 +87,9 @@ bool SGIImage::getRow(uchar *dest) + int n, i; + if (!m_rle) { + for (i = 0; i < m_xsize; i++) { +- *dest++ = uchar(*m_pos); ++ if(m_pos >= m_data.end()) ++ return false; ++ dest[i] = uchar(*m_pos); + m_pos += m_bpc; + } + return true; +@@ -120,7 +122,7 @@ bool SGIImage::readData(QImage& img) + { + QRgb *c; + Q_UINT32 *start = m_starttab; +- QCString lguard(m_xsize); ++ QByteArray lguard(m_xsize); + uchar *line = (uchar *)lguard.data(); + unsigned x, y; + +@@ -128,7 +130,7 @@ bool SGIImage::readData(QImage& img) + m_pos = m_data.begin(); + + for (y = 0; y < m_ysize; y++) { +- c = reinterpret_cast<QRgb *>(img.scanLine(m_ysize - y - 1)); ++ c = (QRgb *) img.scanLine(m_ysize - y - 1); + if (m_rle) + m_pos = m_data.begin() + *start++; + if (!getRow(line)) +@@ -166,11 +168,11 @@ bool SGIImage::readData(QImage& img) + } + + for (y = 0; y < m_ysize; y++) { +- c = reinterpret_cast<QRgb *>(img.scanLine(m_ysize - y - 1)); + if (m_rle) + m_pos = m_data.begin() + *start++; + if (!getRow(line)) + return false; ++ c = (QRgb*) img.scanLine(m_ysize - y - 1); + for (x = 0; x < m_xsize; x++, c++) + *c = qRgba(qRed(*c), qGreen(*c), qBlue(*c), line[x]); + } +@@ -270,7 +272,7 @@ bool SGIImage::readImage(QImage& img) + // sanity ckeck + if (m_rle) + for (uint o = 0; o < m_numrows; o++) +- if (m_starttab[o] + m_lengthtab[o] > m_data.size()) { ++ if (m_starttab[o] + m_lengthtab[o] >= m_data.size()) { + kdDebug(399) << "image corrupt (sanity check failed)" << endl; + return false; + } +@@ -351,24 +353,32 @@ uchar SGIImage::intensity(uchar c) + + uint SGIImage::compact(uchar *d, uchar *s) + { +- uchar *dest = d, *src = s, patt, *cnt; +- int n; +- while (src - s < m_xsize) { +- if (src - s + 1 == m_xsize) { // last bit +- *dest++ = 0x81; +- *dest++ = *src; ++ uchar *dest = d, *src = s, patt, *t, *end = s + m_xsize; ++ int i, n; ++ while (src < end) { ++ for (n = 0, t = src; t + 2 < end && !(*t == t[1] && *t == t[2]); t++) ++ n++; ++ ++ while (n) { ++ i = n > 126 ? 126 : n; ++ n -= i; ++ *dest++ = 0x80 | i; ++ while (i--) ++ *dest++ = *src++; ++ } ++ ++ if (src == end) + break; +- } else if (*src == src[1]) { +- patt = *src++; +- for (n = 1; src - s < m_xsize && n < 126 && *src == patt; src++) +- n++; +- *dest++ = n; ++ ++ patt = *src++; ++ for (n = 1; src < end && *src == patt; src++) ++ n++; ++ ++ while (n) { ++ i = n > 126 ? 126 : n; ++ n -= i; ++ *dest++ = i; + *dest++ = patt; +- } else { +- cnt = dest++; +- for (n = 0; src - s < m_xsize && n < 126 && *src != src[1]; n++) +- *dest++ = *src++; +- *cnt = 0x80 | n; + } + } + *dest++ = 0; +@@ -444,16 +454,12 @@ void SGIImage::writeHeader() + kdDebug(399) << "Description: " << desc << endl; + desc.truncate(79); + +- char id[] = "KDE kimgio", *s = id; + for (i = 0; i < desc.length(); i++) + m_imagename[i] = desc.latin1()[i]; + for (; i < 80; i++) + m_imagename[i] = '\0'; +- if (desc.length() < 68) +- for (i = 69; *s; i++) +- m_imagename[i] = *s++; +- + m_stream.writeRawBytes(m_imagename, 80); ++ + m_stream << m_colormap; + for (i = 0; i < 404; i++) + m_stream << Q_UINT8(0); +@@ -551,13 +557,6 @@ bool SGIImage::writeImage(QImage& img) + + m_numrows = m_ysize * m_zsize; + +- // compressing a row with up to 11 pixels takes 11 or more bytes +- // (start/length table: 8, smallest possible RLE packet: 3) +- if (m_xsize <= 11) { +- writeVerbatim(img); +- return true; +- } +- + m_starttab = new Q_UINT32[m_numrows]; + m_rlemap.setBaseOffset(512 + m_numrows * 2 * sizeof(Q_UINT32)); + +@@ -579,7 +578,7 @@ bool SGIImage::writeImage(QImage& img) + kdDebug(399) << "total savings: " << (verbatim_size - rle_size) << " bytes" << endl; + kdDebug(399) << "compression: " << (rle_size * 100.0 / verbatim_size) << '%' << endl; + +- if (verbatim_size <= rle_size) ++ if (verbatim_size <= rle_size || m_io->quality() > 50) + writeVerbatim(img); + else + writeRle(); +diff -u -3 -d -p -r1.7 -r1.7.2.1 +--- tga.cpp 1 Aug 2004 16:45:53 -0000 1.7 ++++ tga.cpp 19 Apr 2005 11:11:09 -0000 1.7.2.1 +@@ -1,5 +1,6 @@ + /* This file is part of the KDE project + Copyright (C) 2003 Dominik Seichter <domseichter@web.de> ++ Copyright (C) 2004 Ignacio Castaño <castano@ludicon.com> + + This program is free software; you can redistribute it and/or + modify it under the terms of the Lesser GNU General Public +@@ -9,213 +10,347 @@ + + /* this code supports: + * reading: +- * run length encoded true color tga files +- * uncompressed true color tga files ++ * uncompressed and run length encoded indexed, grey and color tga files. ++ * image types 1, 2, 3, 9, 10 and 11. ++ * only RGB color maps with no more than 256 colors. ++ * pixel formats 8, 15, 24 and 32. + * writing: + * uncompressed true color tga files + */ + + #include "tga.h" + ++#include <assert.h> ++ + #include <qimage.h> + #include <qdatastream.h> + +-/* +- * uncompressed TGA magic header +- */ +-unsigned char targaMagic[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++#include <kdebug.h> + +-/* +- * compressed TGA magic header +- */ +-unsigned char compMagic[12] = { 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ++typedef Q_UINT32 uint; ++typedef Q_UINT16 ushort; ++typedef Q_UINT8 uchar; + +-/* +- * the origin of the image (default is TOP_LEFT) +- */ +-enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; ++namespace { // Private. + +-/* +- * Read one pixel and return its color +- */ +-int getData( QDataStream* s, int bpp ) +-{ +- unsigned char* data = new unsigned char[bpp]; ++ // Header format of saved files. ++ uchar targaMagic[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +- for( int d = 0; d < bpp; d++ ) +- *s >> data[d]; ++ enum TGAType { ++ TGA_TYPE_INDEXED = 1, ++ TGA_TYPE_RGB = 2, ++ TGA_TYPE_GREY = 3, ++ TGA_TYPE_RLE_INDEXED = 9, ++ TGA_TYPE_RLE_RGB = 10, ++ TGA_TYPE_RLE_GREY = 11 ++ }; + +- int color = 0; +- if( bpp == 4 ) +- color = qRgba( data[0], data[1], data[2], data[3] ); +- else +- color = qRgb( data[0], data[1], data[2] ); ++#define TGA_INTERLEAVE_MASK 0xc0 ++#define TGA_INTERLEAVE_NONE 0x00 ++#define TGA_INTERLEAVE_2WAY 0x40 ++#define TGA_INTERLEAVE_4WAY 0x80 + +- delete [] data; +- return color; +-} ++#define TGA_ORIGIN_MASK 0x30 ++#define TGA_ORIGIN_LEFT 0x00 ++#define TGA_ORIGIN_RIGHT 0x10 ++#define TGA_ORIGIN_LOWER 0x00 ++#define TGA_ORIGIN_UPPER 0x20 + +-/* +- * checks wether y is inside of the image +- * when origin is of mode m +- */ +-bool checky( int y, int h, int m ) +-{ +- if( m == TOP_LEFT ) +- return (y < h); +- else if( m == BOTTOM_LEFT || m == BOTTOM_RIGHT ) +- return ( y >= 0 ); ++ /** Tga Header. */ ++ struct TgaHeader { ++ uchar id_length; ++ uchar colormap_type; ++ uchar image_type; ++ ushort colormap_index; ++ ushort colormap_length; ++ uchar colormap_size; ++ ushort x_origin; ++ ushort y_origin; ++ ushort width; ++ ushort height; ++ uchar pixel_size; ++ uchar flags; ++ ++ enum { SIZE = 18 }; // const static int SIZE = 18; ++ }; + +- return false; +-} ++ static QDataStream & operator>> ( QDataStream & s, TgaHeader & head ) ++ { ++ s >> head.id_length; ++ s >> head.colormap_type; ++ s >> head.image_type; ++ s >> head.colormap_index; ++ s >> head.colormap_length; ++ s >> head.colormap_size; ++ s >> head.x_origin; ++ s >> head.y_origin; ++ s >> head.width; ++ s >> head.height; ++ s >> head.pixel_size; ++ s >> head.flags; ++ return s; ++ } + +- /* +- * checks wether x is inside of the image +- * when origin is of mode m +- */ +- bool checkx( int x, int w, int m ) +- { +- if( m == TOP_LEFT || m == BOTTOM_LEFT ) +- return (x < w); +- else if( m == BOTTOM_RIGHT ) +- return ( x >= 0 ); ++ static bool IsSupported( const TgaHeader & head ) ++ { ++ if( head.image_type != TGA_TYPE_INDEXED && ++ head.image_type != TGA_TYPE_RGB && ++ head.image_type != TGA_TYPE_GREY && ++ head.image_type != TGA_TYPE_RLE_INDEXED && ++ head.image_type != TGA_TYPE_RLE_RGB && ++ head.image_type != TGA_TYPE_RLE_GREY ) ++ { ++ return false; ++ } ++ if( head.image_type == TGA_TYPE_INDEXED || ++ head.image_type == TGA_TYPE_RLE_INDEXED ) ++ { ++ if( head.colormap_length > 256 || head.colormap_size != 24 ) ++ { ++ return false; ++ } ++ } ++ if( head.width == 0 || head.height == 0 ) ++ { ++ return false; ++ } ++ if( head.pixel_size != 8 && head.pixel_size != 16 && ++ head.pixel_size != 24 && head.pixel_size != 32 ) ++ { ++ return false; ++ } ++ return true; ++ } + +- return false; +- } ++ struct Color555 { ++ ushort b : 5; ++ ushort g : 5; ++ ushort r : 5; ++ }; ++ ++ static bool HasAlpha( const TgaHeader & tga ) ++ { ++ return tga.pixel_size == 32; ++ } + +- void kimgio_tga_read( QImageIO *io ) +- { +- unsigned char header[6]; +- bool compressed = false; ++ struct TgaHeaderInfo { ++ bool rle; ++ bool pal; ++ bool rgb; ++ bool grey; ++ bool supported; ++ ++ TgaHeaderInfo( const TgaHeader & tga ) : rle(false), pal(false), rgb(false), grey(false), supported(true) ++ { ++ switch( tga.image_type ) { ++ case TGA_TYPE_RLE_INDEXED: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_INDEXED: ++ if( tga.colormap_type!=1 || tga.colormap_size!=24 || tga.colormap_length>256 ) { ++ supported = false; ++ } ++ pal = true; ++ break; ++ ++ case TGA_TYPE_RLE_RGB: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_RGB: ++ rgb = true; ++ break; ++ ++ case TGA_TYPE_RLE_GREY: ++ rle = true; ++ // no break is intended! ++ case TGA_TYPE_GREY: ++ grey = true; ++ break; ++ ++ default: ++ // Error, unknown image type. ++ supported = false; ++ } ++ } ++ }; ++ + +- QDataStream s( io->ioDevice() ); +- s.setByteOrder( QDataStream::LittleEndian ); + +- /* +- * check whether it is a targa file or not +- */ +- for( int i = 0; i < 12; i++ ) { +- unsigned char a; +- s >> a; +- if( a != targaMagic[i] && a!= compMagic[i]) { +- io->setImage( 0 ); +- io->setStatus( -1 ); +- return; +- } ++ static bool LoadTGA( QDataStream & s, const TgaHeader & tga, QImage &img ) ++ { ++ // Create image. ++ if( !img.create( tga.width, tga.height, 32 )) { ++ return false; ++ } + +- // check if it is a compressed targa file +- if( i == 2 && a == compMagic[i] ) +- compressed = true; +- } ++ TgaHeaderInfo info(tga); ++ if( !info.supported ) { ++ // File not supported. ++ kdDebug(399) << "This TGA file is not supported." << endl; ++ return false; ++ } ++ ++ // Enable alpha buffer for transparent images. ++ if( HasAlpha( tga ) ) { ++ img.setAlphaBuffer( true ); ++ } + +- for( int i = 0; i < 6; i++ ) +- s >> header[i]; +- if( s.atEnd()) { +- io->setImage( 0 ); +- io->setStatus( -1 ); +- return; +- } ++ uint pixel_size = (tga.pixel_size/8); ++ uint size = tga.width * tga.height * pixel_size; + +- int width = header[1] * 256 + header[0]; +- int height = header[3] * 256 + header[2]; +- int bpp = header[4]; +- int bit = header[5]; +- int bytesPerPixel = bpp / 8; ++ ++ // Read palette. ++ char palette[768]; ++ if( info.pal ) { ++ // @todo Support palettes in other formats! ++ s.readRawBytes( palette, 3 * tga.colormap_length ); ++ } + +- /* Bit values: +- * bit 0-3: number of alpha bits per fixel +- * bit 4-5: origin of image: +- * - 0 0 bottom left +- * - 1 0 bottom right +- * - 0 1 top left // that's what we write +- * - 1 1 top right +- */ ++ // Allocate image. ++ uchar * const image = new uchar[size]; + +- int mode; +- if( (bit | 0) == 0 ) +- mode = BOTTOM_LEFT; +- else if( (bit & 8) == 8 ) +- /* +- * should be BOTTOM_RIGHT, +- * but GIMP writes them this way. +- */ +- mode = BOTTOM_LEFT; +- else if( (bit & 32) == 32 ) +- mode = TOP_LEFT; +- else +- mode = TOP_LEFT; ++ if( info.rle ) { ++ // Decode image. ++ char * dst = (char *)image; ++ int num = size; ++ ++ while (num > 0) { ++ // Get packet header. ++ uchar c; ++ s >> c; ++ ++ uint count = (c & 0x7f) + 1; ++ num -= count * pixel_size; ++ ++ if (c & 0x80) { ++ // RLE pixels. ++ assert(pixel_size <= 8); ++ char pixel[8]; ++ s.readRawBytes( pixel, pixel_size ); ++ do { ++ memcpy(dst, pixel, pixel_size); ++ dst += pixel_size; ++ } while (--count); ++ } ++ else { ++ // Raw pixels. ++ count *= pixel_size; ++ s.readRawBytes( dst, count ); ++ dst += count; ++ } ++ } ++ } ++ else { ++ // Read raw image. ++ s.readRawBytes( (char *)image, size ); ++ } + +- if( bytesPerPixel != 3 && bytesPerPixel != 4 ) { +- io->setImage( 0 ); +- io->setStatus( -1 ); +- return; +- } ++ // Convert image to internal format. ++ int y_start, y_step, y_end; ++ if( tga.flags & TGA_ORIGIN_UPPER ) { ++ y_start = 0; ++ y_step = 1; ++ y_end = tga.height - 1; ++ } ++ else { ++ y_start = tga.height - 1; ++ y_step = -1; ++ y_end = 0; ++ } + +- QImage img; +- if( !img.create( width, height, (bpp == 24 ? 32 : bpp) )) { +- io->setImage( 0 ); +- io->setStatus( -1 ); +- return; +- } ++ uchar * src = image; + +- /* +- * Enable alpha buffer for transparent images +- */ +- if( img.depth() == 32 ) +- img.setAlphaBuffer( true ); ++ for( int y = y_start; y != y_end; y += y_step ) { ++ QRgb * scanline = (QRgb *) img.scanLine( y ); ++ ++ if( info.pal ) { ++ // Paletted. ++ for( int x = 0; x < tga.width; x++ ) { ++ uchar idx = *src++; ++ scanline[x] = qRgb( palette[3*idx+2], palette[3*idx+1], palette[3*idx+0] ); ++ } ++ } ++ else if( info.grey ) { ++ // Greyscale. ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgb( *src, *src, *src ); ++ src++; ++ } ++ } ++ else { ++ // True Color. ++ if( tga.pixel_size == 16 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ Color555 c = *reinterpret_cast<Color555 *>(src); ++ scanline[x] = qRgb( (c.r << 3) | (c.r >> 2), (c.g << 3) | (c.g >> 2), (c.b << 3) | (c.b >> 2) ); ++ src += 2; ++ } ++ } ++ else if( tga.pixel_size == 24 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgb( src[2], src[1], src[0] ); ++ src += 3; ++ } ++ } ++ else if( tga.pixel_size == 32 ) { ++ for( int x = 0; x < tga.width; x++ ) { ++ scanline[x] = qRgba( src[2], src[1], src[0], src[3] ); ++ src += 4; ++ } ++ } ++ } ++ } + ++ // Free image. ++ delete [] image; ++ ++ return true; ++ } ++ ++} // namespace + +- int x = 0; +- int y = 0; +- int addy = 1; +- int addx = 1; +- if( mode == BOTTOM_LEFT || mode == BOTTOM_RIGHT ) { +- y = height - 1; +- addy = -1; +- } + +- if( mode == BOTTOM_RIGHT || mode == TOP_RIGHT ) { +- x = width - 1; +- addx = -1; +- } ++void kimgio_tga_read( QImageIO *io ) ++{ ++ //kdDebug(399) << "Loading TGA file!" << endl; ++ ++ QDataStream s( io->ioDevice() ); ++ s.setByteOrder( QDataStream::LittleEndian ); ++ ++ ++ // Read image header. ++ TgaHeader tga; ++ s >> tga; ++ s.device()->at( TgaHeader::SIZE + tga.id_length ); ++ ++ // Check image file format. ++ if( s.atEnd() ) { ++ kdDebug(399) << "This TGA file is not valid." << endl; ++ io->setImage( 0 ); ++ io->setStatus( -1 ); ++ return; ++ } ++ ++ // Check supported file types. ++ if( !IsSupported(tga) ) { ++ kdDebug(399) << "This TGA file is not supported." << endl; ++ io->setImage( 0 ); ++ io->setStatus( -1 ); ++ return; ++ } ++ ++ ++ QImage img; ++ bool result = LoadTGA(s, tga, img); ++ ++ if( result == false ) { ++ kdDebug(399) << "Error loading TGA file." << endl; ++ io->setImage( 0 ); ++ io->setStatus( -1 ); ++ return; ++ } + +- /* +- * we have to restore the value of x after each loop +- */ +- int oldx = x; +- if( !compressed ) { +- for( ; !s.atEnd() && checky( y, height, mode ); y += addy ) +- for( x = oldx; checkx( x, width, mode ); x += addx ) { +- img.setPixel( x, y, getData( &s, bytesPerPixel ) ); +- } +- } else { +- unsigned char cur; +- while( !s.atEnd() && checky( y, height, mode ) ) { +- while( checkx( x, width, mode ) ) { +- s >> cur; +- if( (cur & 128) == 128 ) { +- // found a RLE chunk +- int length = (cur & 127) + 1; +- int color = getData( &s, bytesPerPixel ); +- for( int i = 0; i < length; i++ ) { +- img.setPixel( x, y, color ); +- x += addx; +- } +- } else { +- int length = (cur & 127) + 1; +- for( int i = 0; i < length; i++ ) { +- img.setPixel( x, y, getData( &s, bytesPerPixel ) ); +- x += addx; +- } +- } +- } +- y += addy; +- x = oldx; +- } +- } + +- img = img.swapRGB(); +- + io->setImage( img ); + io->setStatus( 0 ); + } +diff -u -3 -d -p -r1.12 -r1.12.2.1 +--- tiffr.cpp 9 Jun 2004 08:28:36 -0000 1.12 ++++ tiffr.cpp 19 Apr 2005 11:11:09 -0000 1.12.2.1 +@@ -83,6 +83,10 @@ void kimgio_tiff_read( QImageIO *io ) + return; + + QImage image( width, height, 32 ); ++ if( image.isNull()) { ++ TIFFClose( tiff ); ++ return; ++ } + data = (uint32 *)image.bits(); + + //Sven: changed to %ld for 64bit machines +diff -u -3 -d -p -r1.10 -r1.10.6.1 +--- xview.cpp 6 Sep 2003 19:06:36 -0000 1.10 ++++ xview.cpp 19 Apr 2005 11:11:09 -0000 1.10.6.1 +@@ -7,12 +7,16 @@ + + #include <stdio.h> + #include <string.h> ++#include <stdlib.h> + #include <qimage.h> + + #include "xview.h" + + #define BUFSIZE 1024 + ++static const int b_255_3[]= {0,85,170,255}, // index*255/3 ++ rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 ++ + void kimgio_xv_read( QImageIO *_imageio ) + { + int x=-1; +@@ -48,10 +52,14 @@ void kimgio_xv_read( QImageIO *_imageio + sscanf(str, "%d %d %d", &x, &y, &maxval); + + if (maxval != 255) return; ++ int blocksize = x*y; ++ if(x < 0 || y < 0 || blocksize < x || blocksize < y) ++ return; + + // now follows a binary block of x*y bytes. +- int blocksize = x*y; +- char *block = new char[ blocksize ]; ++ char *block = (char*) malloc(blocksize); ++ if(!block) ++ return; + + if (iodev->readBlock(block, blocksize) != blocksize ) + { +@@ -60,6 +68,10 @@ void kimgio_xv_read( QImageIO *_imageio + + // Create the image + QImage image( x, y, 8, maxval + 1, QImage::BigEndian ); ++ if( image.isNull()) { ++ free(block); ++ return; ++ } + + // how do the color handling? they are absolute 24bpp + // or at least can be calculated as such. +@@ -67,29 +79,9 @@ void kimgio_xv_read( QImageIO *_imageio + + for ( int j = 0; j < 256; j++ ) + { +-// ----------- OLIVER EIDEN +-// That is the old-code ! +-/* r = ((int) ((j >> 5) & 0x07)) << 5; +- g = ((int) ((j >> 2) & 0x07)) << 5; +- b = ((int) ((j >> 0) & 0x03)) << 6;*/ +- +- +-// That is the code-how xv, decode 3-3-2 pixmaps, it is slighly different, +-// but yields much better visuals results +-/* r = (((int) ((j >> 5) & 0x07)) *255) / 7; +- g = (((int) ((j >> 2) & 0x07)) *255) / 7; +- b = (((int) ((j >> 0) & 0x03)) *255) / 3;*/ +- +-// This is the same as xv, with multiplications/divisions replaced by indexing +- +-// Look-up table to avoid multiplications and divisons +- static int b_255_3[]= {0,85,170,255}, // index*255/3 +- rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 +- + r = rg_255_7[((j >> 5) & 0x07)]; + g = rg_255_7[((j >> 2) & 0x07)]; + b = b_255_3[((j >> 0) & 0x03)]; +-// --------------- + image.setColor( j, qRgb( r, g, b ) ); + } + +@@ -102,7 +94,7 @@ void kimgio_xv_read( QImageIO *_imageio + _imageio->setImage( image ); + _imageio->setStatus( 0 ); + +- delete [] block; ++ free(block); + return; + } + diff --git a/kde-base/kdelibs/files/post-3.4.0-kdelibs-kimgio.diff b/kde-base/kdelibs/files/post-3.4.0-kdelibs-kimgio.diff new file mode 100644 index 000000000000..92cde24525bf --- /dev/null +++ b/kde-base/kdelibs/files/post-3.4.0-kdelibs-kimgio.diff @@ -0,0 +1,1017 @@ +diff -u -3 -d -p -r1.4 -r1.4.2.1 +--- exr.cpp 22 Nov 2004 03:48:27 -0000 1.4 ++++ exr.cpp 19 Apr 2005 10:48:00 -0000 1.4.2.1 +@@ -136,6 +136,8 @@ KDE_EXPORT void kimgio_exr_read( QImageI + file.readPixels (dw.min.y, dw.max.y); + + QImage image(width, height, 32, 0, QImage::BigEndian); ++ if( image.isNull()) ++ return; + + // somehow copy pixels into image + for ( int y=0; y < height; y++ ) { +diff -u -3 -d -p -r1.4 -r1.4.2.1 +--- g3r.cpp 22 Nov 2004 03:48:27 -0000 1.4 ++++ g3r.cpp 18 Apr 2005 13:08:44 -0000 1.4.2.1 +@@ -28,7 +28,7 @@ KDE_EXPORT void kimgio_g3_read( QImageIO + + QImage image(width, height, 1, 0, QImage::BigEndian); + +- if (scanlength != image.bytesPerLine()) ++ if (image.isNull() || scanlength != image.bytesPerLine()) + { + TIFFClose(tiff); + return; +diff -u -3 -d -p -r1.14 -r1.14.2.1 +--- jp2.cpp 22 Nov 2004 03:48:27 -0000 1.14 ++++ jp2.cpp 19 Apr 2005 10:48:00 -0000 1.14.2.1 +@@ -157,8 +157,9 @@ namespace { + void + draw_view_gray( gs_t& gs, QImage& qti ) + { +- qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), +- 8, 256 ); ++ if( !qti.create( jas_image_width( gs.image ), jas_image_height( gs.image ), ++ 8, 256 )) ++ return; + for( int i = 0; i < 256; ++i ) + qti.setColor( i, qRgb( i, i, i ) ); + +diff -u -3 -d -p -r1.12 -r1.12.2.2 +--- pcx.cpp 22 Nov 2004 03:48:27 -0000 1.12 ++++ pcx.cpp 19 Apr 2005 10:48:00 -0000 1.12.2.2 +@@ -1,5 +1,5 @@ + /* This file is part of the KDE project +- Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> ++ Copyright (C) 2002-2005 Nadeem Hasan <nhasan@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public +@@ -44,6 +44,11 @@ static QDataStream &operator>>( QDataStr + s >> ph.HScreenSize; + s >> ph.VScreenSize; + ++ // Skip the rest of the header ++ Q_UINT8 byte; ++ while ( s.device()->at() < 128 ) ++ s >> byte; ++ + return s; + } + +@@ -85,25 +90,22 @@ static QDataStream &operator<<( QDataStr + return s; + } + +-static PCXHEADER header; +-static QImage img; +-static Q_UINT16 w, h; +- +-void PCXHEADER::reset() ++PCXHEADER::PCXHEADER() + { ++ // Initialize all data to zero + QByteArray dummy( 128 ); + dummy.fill( 0 ); + QDataStream s( dummy, IO_ReadOnly ); + s >> *this; + } + +-static void readLine( QDataStream &s, QByteArray &buf ) ++static void readLine( QDataStream &s, QByteArray &buf, const PCXHEADER &header ) + { + Q_UINT32 i=0; + Q_UINT32 size = buf.size(); + Q_UINT8 byte, count; + +- if ( header.Encoding == 1 ) ++ if ( header.isCompressed() ) + { + // Uncompress the image data + while ( i < size ) +@@ -130,13 +132,14 @@ static void readLine( QDataStream &s, QB + } + } + +-static void readImage1( QDataStream &s ) ++static void readImage1( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 1, 2, QImage::BigEndian ); ++ if(!img.create( header.width(), header.height(), 1, 2, QImage::BigEndian )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -144,10 +147,11 @@ static void readImage1( QDataStream &s ) + return; + } + +- readLine( s, buf ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *( img.scanLine( y )+x ) = buf[ x ]; ++ readLine( s, buf, header ); ++ uchar *p = img.scanLine( y ); ++ unsigned int bpl = QMIN((header.width()+7)/8, header.BytesPerLine); ++ for ( unsigned int x=0; x< bpl; ++x ) ++ p[ x ] = buf[x]; + } + + // Set the color palette +@@ -155,14 +159,15 @@ static void readImage1( QDataStream &s ) + img.setColor( 1, qRgb( 255, 255, 255 ) ); + } + +-static void readImage4( QDataStream &s ) ++static void readImage4( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine*4 ); +- QByteArray pixbuf( w ); ++ QByteArray pixbuf( header.width() ); + +- img.create( w, h, 8, 16, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 16 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -171,20 +176,19 @@ static void readImage4( QDataStream &s ) + } + + pixbuf.fill( 0 ); +- readLine( s, buf ); ++ readLine( s, buf, header ); + + for ( int i=0; i<4; i++ ) + { + Q_UINT32 offset = i*header.BytesPerLine; +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + if ( buf[ offset + ( x/8 ) ] & ( 128 >> ( x%8 ) ) ) + pixbuf[ x ] += ( 1 << i ); + } + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<w; ++x ) +- *p++ = pixbuf[ x ]; ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = pixbuf[ x ]; + } + + // Read the palette +@@ -192,13 +196,14 @@ static void readImage4( QDataStream &s ) + img.setColor( i, header.ColorMap.color( i ) ); + } + +-static void readImage8( QDataStream &s ) ++static void readImage8( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray buf( header.BytesPerLine ); + +- img.create( w, h, 8, 256, QImage::IgnoreEndian ); ++ if(!img.create( header.width(), header.height(), 8, 256 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -206,19 +211,19 @@ static void readImage8( QDataStream &s ) + return; + } + +- readLine( s, buf ); ++ readLine( s, buf, header ); + + uchar *p = img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = buf[ x ]; ++ unsigned int bpl = QMIN(header.BytesPerLine, header.width()); ++ for ( unsigned int x=0; x<bpl; ++x ) ++ p[ x ] = buf[ x ]; + } + + Q_UINT8 flag; + s >> flag; +- kdDebug() << "Flag: " << flag << endl; ++ kdDebug( 399 ) << "Palette Flag: " << flag << endl; + +- if ( flag == 12 && header.Version == 5 ) ++ if ( flag == 12 && ( header.Version == 5 || header.Version == 2 ) ) + { + // Read the palette + Q_UINT8 r, g, b; +@@ -230,15 +235,16 @@ static void readImage8( QDataStream &s ) + } + } + +-static void readImage24( QDataStream &s ) ++static void readImage24( QImage &img, QDataStream &s, const PCXHEADER &header ) + { + QByteArray r_buf( header.BytesPerLine ); + QByteArray g_buf( header.BytesPerLine ); + QByteArray b_buf( header.BytesPerLine ); + +- img.create( w, h, 32 ); ++ if(!img.create( header.width(), header.height(), 32 )) ++ return; + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + if ( s.atEnd() ) + { +@@ -246,14 +252,13 @@ static void readImage24( QDataStream &s + return; + } + +- readLine( s, r_buf ); +- readLine( s, g_buf ); +- readLine( s, b_buf ); ++ readLine( s, r_buf, header ); ++ readLine( s, g_buf, header ); ++ readLine( s, b_buf, header ); + + uint *p = ( uint * )img.scanLine( y ); +- +- for ( int x=0; x<header.BytesPerLine; ++x ) +- *p++ = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); ++ for ( unsigned int x=0; x<header.width(); ++x ) ++ p[ x ] = qRgb( r_buf[ x ], g_buf[ x ], b_buf[ x ] ); + } + } + +@@ -268,6 +273,8 @@ KDE_EXPORT void kimgio_pcx_read( QImageI + return; + } + ++ PCXHEADER header; ++ + s >> header; + + if ( header.Manufacturer != 10 || s.atEnd()) +@@ -276,10 +283,8 @@ KDE_EXPORT void kimgio_pcx_read( QImageI + return; + } + +- w = ( header.XMax-header.XMin ) + 1; +- h = ( header.YMax-header.YMin ) + 1; +- +- img.reset(); ++ int w = header.width(); ++ int h = header.height(); + + kdDebug( 399 ) << "Manufacturer: " << header.Manufacturer << endl; + kdDebug( 399 ) << "Version: " << header.Version << endl; +@@ -288,30 +293,27 @@ KDE_EXPORT void kimgio_pcx_read( QImageI + kdDebug( 399 ) << "Width: " << w << endl; + kdDebug( 399 ) << "Height: " << h << endl; + kdDebug( 399 ) << "Window: " << header.XMin << "," << header.XMax << "," +- << header.YMin << "," << header.YMax << endl; ++ << header.YMin << "," << header.YMax << endl; + kdDebug( 399 ) << "BytesPerLine: " << header.BytesPerLine << endl; + kdDebug( 399 ) << "NPlanes: " << header.NPlanes << endl; + +- // Skip the rest of the header +- Q_UINT8 byte; +- while ( s.device()->at() < 128 ) +- s >> byte; ++ QImage img; + + if ( header.Bpp == 1 && header.NPlanes == 1 ) + { +- readImage1( s ); ++ readImage1( img, s, header ); + } + else if ( header.Bpp == 1 && header.NPlanes == 4 ) + { +- readImage4( s ); ++ readImage4( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 1 ) + { +- readImage8( s ); ++ readImage8( img, s, header ); + } + else if ( header.Bpp == 8 && header.NPlanes == 3 ) + { +- readImage24( s ); ++ readImage24( img, s, header ); + } + + kdDebug( 399 ) << "Image Bytes: " << img.numBytes() << endl; +@@ -359,7 +361,7 @@ static void writeLine( QDataStream &s, Q + } + } + +-static void writeImage1( QDataStream &s ) ++static void writeImage1( QImage &img, QDataStream &s, PCXHEADER &header ) + { + img = img.convertBitOrder( QImage::BigEndian ); + +@@ -367,29 +369,27 @@ static void writeImage1( QDataStream &s + header.NPlanes = 1; + header.BytesPerLine = img.bytesPerLine(); + +- header.ColorMap.setColor( 0, qRgb( 0, 0, 0 ) ); +- header.ColorMap.setColor( 1, qRgb( 255, 255, 255 ) ); +- + s << header; + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + ++ // Invert as QImage uses reverse palette for monochrome images? + for ( int i=0; i<header.BytesPerLine; ++i ) +- buf[ i ] = p[ i ]; ++ buf[ i ] = ~p[ i ]; + + writeLine( s, buf ); + } + } + +-static void writeImage4( QDataStream &s ) ++static void writeImage4( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 1; + header.NPlanes = 4; +- header.BytesPerLine = w/8; ++ header.BytesPerLine = header.width()/8; + + for ( int i=0; i<16; ++i ) + header.ColorMap.setColor( i, img.color( i ) ); +@@ -401,14 +401,14 @@ static void writeImage4( QDataStream &s + for ( int i=0; i<4; ++i ) + buf[ i ].resize( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + + for ( int i=0; i<4; ++i ) + buf[ i ].fill( 0 ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + for ( int i=0; i<4; ++i ) + if ( *( p+x ) & ( 1 << i ) ) +@@ -420,7 +420,7 @@ static void writeImage4( QDataStream &s + } + } + +-static void writeImage8( QDataStream &s ) ++static void writeImage8( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 1; +@@ -430,7 +430,7 @@ static void writeImage8( QDataStream &s + + QByteArray buf( header.BytesPerLine ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + Q_UINT8 *p = img.scanLine( y ); + +@@ -449,23 +449,23 @@ static void writeImage8( QDataStream &s + s << RGB( img.color( i ) ); + } + +-static void writeImage24( QDataStream &s ) ++static void writeImage24( QImage &img, QDataStream &s, PCXHEADER &header ) + { + header.Bpp = 8; + header.NPlanes = 3; +- header.BytesPerLine = w; ++ header.BytesPerLine = header.width(); + + s << header; + +- QByteArray r_buf( w ); +- QByteArray g_buf( w ); +- QByteArray b_buf( w ); ++ QByteArray r_buf( header.width() ); ++ QByteArray g_buf( header.width() ); ++ QByteArray b_buf( header.width() ); + +- for ( int y=0; y<h; ++y ) ++ for ( int y=0; y<header.height(); ++y ) + { + uint *p = ( uint * )img.scanLine( y ); + +- for ( int x=0; x<w; ++x ) ++ for ( unsigned int x=0; x<header.width(); ++x ) + { + QRgb rgb = *p++; + r_buf[ x ] = qRed( rgb ); +@@ -484,10 +484,10 @@ KDE_EXPORT void kimgio_pcx_write( QImage + QDataStream s( io->ioDevice() ); + s.setByteOrder( QDataStream::LittleEndian ); + +- img = io->image(); ++ QImage img = io->image(); + +- w = img.width(); +- h = img.height(); ++ int w = img.width(); ++ int h = img.height(); + + kdDebug( 399 ) << "Width: " << w << endl; + kdDebug( 399 ) << "Height: " << h << endl; +@@ -495,6 +495,8 @@ KDE_EXPORT void kimgio_pcx_write( QImage + kdDebug( 399 ) << "BytesPerLine: " << img.bytesPerLine() << endl; + kdDebug( 399 ) << "Num Colors: " << img.numColors() << endl; + ++ PCXHEADER header; ++ + header.Manufacturer = 10; + header.Version = 5; + header.Encoding = 1; +@@ -509,19 +511,19 @@ KDE_EXPORT void kimgio_pcx_write( QImage + + if ( img.depth() == 1 ) + { +- writeImage1( s ); ++ writeImage1( img, s, header ); + } + else if ( img.depth() == 8 && img.numColors() <= 16 ) + { +- writeImage4( s ); ++ writeImage4( img, s, header ); + } + else if ( img.depth() == 8 ) + { +- writeImage8( s ); ++ writeImage8( img, s, header ); + } + else if ( img.depth() == 32 ) + { +- writeImage24( s ); ++ writeImage24( img, s, header ); + } + + io->setStatus( 0 ); +Index: pcx.h +=================================================================== +RCS file: /home/kde/kdelibs/kimgio/pcx.h,v +retrieving revision 1.4 +retrieving revision 1.4.8.1 +diff -u -3 -d -p -r1.4 -r1.4.8.1 +--- pcx.h 4 Jan 2003 00:48:25 -0000 1.4 ++++ pcx.h 19 Apr 2005 10:48:00 -0000 1.4.8.1 +@@ -49,7 +49,7 @@ class Palette + rgb[ i ] = RGB( color ); + } + +- QRgb color( int i ) ++ QRgb color( int i ) const + { + return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); + } +@@ -60,12 +60,11 @@ class Palette + class PCXHEADER + { + public: +- PCXHEADER() +- { +- reset(); +- } ++ PCXHEADER(); + +- void reset(); ++ inline int width() const { return ( XMax-XMin ) + 1; } ++ inline int height() const { return ( YMax-YMin ) + 1; } ++ inline bool isCompressed() const { return ( Encoding==1 ); } + + Q_UINT8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx + Q_UINT8 Version; // Version information· +@@ -99,7 +98,7 @@ class PCXHEADER + // found only in PB IV/IV Plus + Q_UINT16 VScreenSize; // Vertical screen size in pixels. New field + // found only in PB IV/IV Plus +-}; ++} KDE_PACKED; + + #endif // PCX_H + +diff -u -3 -d -p -r1.1 -r1.1.2.1 +--- psd.cpp 16 Dec 2004 09:59:07 -0000 1.1 ++++ psd.cpp 19 Apr 2005 10:48:00 -0000 1.1.2.1 +@@ -66,6 +66,19 @@ namespace { // Private. + s >> header.color_mode; + return s; + } ++ static bool seekBy(QDataStream& s, unsigned int bytes) ++ { ++ char buf[4096]; ++ while (bytes) { ++ unsigned int num= QMIN(bytes,sizeof(buf)); ++ unsigned int l = num; ++ s.readRawBytes(buf, l); ++ if(l != num) ++ return false; ++ bytes -= num; ++ } ++ return true; ++ } + + // Check that the header is a valid PSD. + static bool IsValid( const PSDHeader & header ) +@@ -149,10 +162,8 @@ namespace { // Private. + if( compression ) { + + // Skip row lengths. +- ushort w; +- for(uint i = 0; i < header.height * header.channel_count; i++) { +- s >> w; +- } ++ if(!seekBy(s, header.height*header.channel_count*sizeof(ushort))) ++ return false; + + // Read RLE data. + for(uint channel = 0; channel < channel_num; channel++) { +@@ -162,6 +173,8 @@ namespace { // Private. + uint count = 0; + while( count < pixel_count ) { + uchar c; ++ if(s.atEnd()) ++ return false; + s >> c; + uint len = c; + +@@ -169,6 +182,9 @@ namespace { // Private. + // Copy next len+1 bytes literally. + len++; + count += len; ++ if ( count > pixel_count ) ++ return false; ++ + while( len != 0 ) { + s >> *ptr; + ptr += 4; +@@ -181,6 +197,8 @@ namespace { // Private. + len ^= 0xFF; + len += 2; + count += len; ++ if(s.atEnd() || count > pixel_count) ++ return false; + uchar val; + s >> val; + while( len != 0 ) { +diff -u -3 -d -p -r1.31 -r1.31.2.1 +--- rgb.cpp 10 Jan 2005 19:54:19 -0000 1.31 ++++ rgb.cpp 19 Apr 2005 10:48:00 -0000 1.31.2.1 +@@ -87,7 +87,9 @@ bool SGIImage::getRow(uchar *dest) + int n, i; + if (!m_rle) { + for (i = 0; i < m_xsize; i++) { +- *dest++ = uchar(*m_pos); ++ if(m_pos >= m_data.end()) ++ return false; ++ dest[i] = uchar(*m_pos); + m_pos += m_bpc; + } + return true; +@@ -120,7 +122,7 @@ bool SGIImage::readData(QImage& img) + { + QRgb *c; + Q_UINT32 *start = m_starttab; +- QCString lguard(m_xsize); ++ QByteArray lguard(m_xsize); + uchar *line = (uchar *)lguard.data(); + unsigned x, y; + +@@ -128,7 +130,7 @@ bool SGIImage::readData(QImage& img) + m_pos = m_data.begin(); + + for (y = 0; y < m_ysize; y++) { +- c = reinterpret_cast<QRgb *>(img.scanLine(m_ysize - y - 1)); ++ c = (QRgb *) img.scanLine(m_ysize - y - 1); + if (m_rle) + m_pos = m_data.begin() + *start++; + if (!getRow(line)) +@@ -166,11 +168,11 @@ bool SGIImage::readData(QImage& img) + } + + for (y = 0; y < m_ysize; y++) { +- c = reinterpret_cast<QRgb *>(img.scanLine(m_ysize - y - 1)); + if (m_rle) + m_pos = m_data.begin() + *start++; + if (!getRow(line)) + return false; ++ c = (QRgb*) img.scanLine(m_ysize - y - 1); + for (x = 0; x < m_xsize; x++, c++) + *c = qRgba(qRed(*c), qGreen(*c), qBlue(*c), line[x]); + } +@@ -270,7 +272,7 @@ bool SGIImage::readImage(QImage& img) + // sanity ckeck + if (m_rle) + for (uint o = 0; o < m_numrows; o++) +- if (m_starttab[o] + m_lengthtab[o] > m_data.size()) { ++ if (m_starttab[o] + m_lengthtab[o] >= m_data.size()) { + kdDebug(399) << "image corrupt (sanity check failed)" << endl; + return false; + } +diff -u -3 -d -p -r1.14 -r1.14.2.1 +--- tiffr.cpp 22 Nov 2004 03:52:18 -0000 1.14 ++++ tiffr.cpp 19 Apr 2005 10:48:00 -0000 1.14.2.1 +@@ -84,6 +84,10 @@ KDE_EXPORT void kimgio_tiff_read( QImage + return; + + QImage image( width, height, 32 ); ++ if( image.isNull()) { ++ TIFFClose( tiff ); ++ return; ++ } + data = (uint32 *)image.bits(); + + //Sven: changed to %ld for 64bit machines +diff -u -3 -d -p -r1.3 -r1.3.2.1 +--- xcf.cpp 22 Nov 2004 03:48:27 -0000 1.3 ++++ xcf.cpp 19 Apr 2005 10:48:00 -0000 1.3.2.1 +@@ -234,10 +234,10 @@ bool XCFImageFormat::loadImageProperties + property.readBytes(tag, size); + + Q_UINT32 flags; +- char* data; ++ char* data=0; + property >> flags >> data; + +- if (strcmp(tag, "gimp-comment") == 0) ++ if (tag && strncmp(tag, "gimp-comment", strlen("gimp-comment")) == 0) + xcf_image.image.setText("Comment", 0, data); + + delete[] tag; +@@ -257,6 +257,9 @@ bool XCFImageFormat::loadImageProperties + + case PROP_COLORMAP: + property >> xcf_image.num_colors; ++ if(xcf_image.num_colors < 0 || xcf_image.num_colors > 65535) ++ return false; ++ + xcf_image.palette.reserve(xcf_image.num_colors); + + for (int i = 0; i < xcf_image.num_colors; i++) { +@@ -307,6 +310,9 @@ bool XCFImageFormat::loadProperty(QDataS + return false; + } + ++ if(size > 65535 || size < 4) ++ return false; ++ + size = 3 * (size - 4) + 4; + data = new char[size]; + +@@ -336,19 +342,21 @@ bool XCFImageFormat::loadProperty(QDataS + } + + size = 0; +- } else +- xcf_io.readBytes(data, size); ++ } else { ++ xcf_io >> size; ++ if(size >256000) ++ return false; ++ data = new char[size]; ++ xcf_io.readRawBytes(data, size); ++ } + + if (xcf_io.device()->status() != IO_Ok) { + kdDebug(399) << "XCF: read failure on property " << type << " data, size " << size << endl; + return false; + } + +- if (size != 0) { +- bytes.resize(size); +- for (uint i = 0; i < size; i++) +- bytes[i] = data[i]; +- delete[] data; ++ if (size != 0 && data) { ++ bytes.assign(data,size); + } + + return true; +@@ -401,7 +409,8 @@ bool XCFImageFormat::loadLayer(QDataStre + // Allocate the individual tile QImages based on the size and type + // of this layer. + +- composeTiles(xcf_image); ++ if( !composeTiles(xcf_image)) ++ return false; + xcf_io.device()->at(layer.hierarchy_offset); + + // As tiles are loaded, they are copied into the layers tiles by +@@ -425,7 +434,8 @@ bool XCFImageFormat::loadLayer(QDataStre + // of the QImage. + + if (!xcf_image.initialized) { +- initializeImage(xcf_image); ++ if( !initializeImage(xcf_image)) ++ return false; + copyLayerToImage(xcf_image); + xcf_image.initialized = true; + } else +@@ -516,7 +526,7 @@ bool XCFImageFormat::loadLayerProperties + * QImage structures for each of them. + * \param xcf_image contains the current layer. + */ +-void XCFImageFormat::composeTiles(XCFImage& xcf_image) ++bool XCFImageFormat::composeTiles(XCFImage& xcf_image) + { + Layer& layer(xcf_image.layer); + +@@ -556,48 +566,67 @@ void XCFImageFormat::composeTiles(XCFIma + switch (layer.type) { + case RGB_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height, 32, 0); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + layer.image_tiles[j][i].setAlphaBuffer(false); + break; + + case RGBA_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height, 32, 0); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + layer.image_tiles[j][i].setAlphaBuffer(true); + break; + + case GRAY_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height, 8, 256); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + setGrayPalette(layer.image_tiles[j][i]); + break; + + case GRAYA_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height, 8, 256); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + setGrayPalette(layer.image_tiles[j][i]); + + layer.alpha_tiles[j][i] = QImage( tile_width, tile_height, 8, 256); ++ if( layer.alpha_tiles[j][i].isNull()) ++ return false; + setGrayPalette(layer.alpha_tiles[j][i]); + break; + + case INDEXED_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height, 8, + xcf_image.num_colors); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + setPalette(xcf_image, layer.image_tiles[j][i]); + break; + + case INDEXEDA_GIMAGE: + layer.image_tiles[j][i] = QImage(tile_width, tile_height,8, + xcf_image.num_colors); ++ if( layer.image_tiles[j][i].isNull()) ++ return false; + setPalette(xcf_image, layer.image_tiles[j][i]); + + layer.alpha_tiles[j][i] = QImage(tile_width, tile_height, 8, 256); ++ if( layer.alpha_tiles[j][i].isNull()) ++ return false; + setGrayPalette(layer.alpha_tiles[j][i]); + } + + if (layer.mask_offset != 0) { + layer.mask_tiles[j][i] = QImage(tile_width, tile_height, 8, 256); ++ if( layer.mask_tiles[j][i].isNull()) ++ return false; + setGrayPalette(layer.mask_tiles[j][i]); + } + } + } ++ return true; + } + + +@@ -1072,7 +1101,7 @@ void XCFImageFormat::assignMaskBytes(Lay + * For indexed images, translucency is an all or nothing effect. + * \param xcf_image contains image info and bottom-most layer. + */ +-void XCFImageFormat::initializeImage(XCFImage& xcf_image) ++bool XCFImageFormat::initializeImage(XCFImage& xcf_image) + { + // (Aliases to make the code look a little better.) + Layer& layer(xcf_image.layer); +@@ -1082,12 +1111,16 @@ void XCFImageFormat::initializeImage(XCF + case RGB_GIMAGE: + if (layer.opacity == OPAQUE_OPACITY) { + image.create( xcf_image.width, xcf_image.height, 32); ++ if( image.isNull()) ++ return false; + image.fill(qRgb(255, 255, 255)); + break; + } // else, fall through to 32-bit representation + + case RGBA_GIMAGE: + image.create(xcf_image.width, xcf_image.height, 32); ++ if( image.isNull()) ++ return false; + image.fill(qRgba(255, 255, 255, 0)); + // Turning this on prevents fill() from affecting the alpha channel, + // by the way. +@@ -1097,6 +1130,8 @@ void XCFImageFormat::initializeImage(XCF + case GRAY_GIMAGE: + if (layer.opacity == OPAQUE_OPACITY) { + image.create(xcf_image.width, xcf_image.height, 8, 256); ++ if( image.isNull()) ++ return false; + setGrayPalette(image); + image.fill(255); + break; +@@ -1104,6 +1139,8 @@ void XCFImageFormat::initializeImage(XCF + + case GRAYA_GIMAGE: + image.create(xcf_image.width, xcf_image.height, 32); ++ if( image.isNull()) ++ return false; + image.fill(qRgba(255, 255, 255, 0)); + image.setAlphaBuffer(true); + break; +@@ -1125,12 +1162,16 @@ void XCFImageFormat::initializeImage(XCF + image.create(xcf_image.width, xcf_image.height, + 1, xcf_image.num_colors, + QImage::LittleEndian); ++ if( image.isNull()) ++ return false; + image.fill(0); + setPalette(xcf_image, image); + } else if (xcf_image.num_colors <= 256) { + image.create(xcf_image.width, xcf_image.height, + 8, xcf_image.num_colors, + QImage::LittleEndian); ++ if( image.isNull()) ++ return false; + image.fill(0); + setPalette(xcf_image, image); + } +@@ -1147,6 +1188,8 @@ void XCFImageFormat::initializeImage(XCF + image.create(xcf_image.width, xcf_image.height, + 1, xcf_image.num_colors, + QImage::LittleEndian); ++ if( image.isNull()) ++ return false; + image.fill(0); + setPalette(xcf_image, image); + image.setAlphaBuffer(true); +@@ -1160,6 +1203,8 @@ void XCFImageFormat::initializeImage(XCF + xcf_image.palette[0] = qRgba(255, 255, 255, 0); + image.create( xcf_image.width, xcf_image.height, + 8, xcf_image.num_colors); ++ if( image.isNull()) ++ return false; + image.fill(0); + setPalette(xcf_image, image); + image.setAlphaBuffer(true); +@@ -1168,6 +1213,8 @@ void XCFImageFormat::initializeImage(XCF + // true color. (There is no equivalent PNG representation output + // from The GIMP as of v1.2.) + image.create(xcf_image.width, xcf_image.height, 32); ++ if( image.isNull()) ++ return false; + image.fill(qRgba(255, 255, 255, 0)); + image.setAlphaBuffer(true); + } +@@ -1176,6 +1223,7 @@ void XCFImageFormat::initializeImage(XCF + + image.setDotsPerMeterX((int)(xcf_image.x_resolution * INCHESPERMETER)); + image.setDotsPerMeterY((int)(xcf_image.y_resolution * INCHESPERMETER)); ++ return true; + } + + +Index: xcf.h +=================================================================== +RCS file: /home/kde/kdelibs/kimgio/xcf.h,v +retrieving revision 1.1 +retrieving revision 1.1.2.1 +diff -u -3 -d -p -r1.1 -r1.1.2.1 +--- xcf.h 13 Aug 2004 18:31:44 -0000 1.1 ++++ xcf.h 19 Apr 2005 10:48:00 -0000 1.1.2.1 +@@ -176,7 +176,7 @@ private: + bool loadProperty(QDataStream& xcf_io, PropType& type, QByteArray& bytes); + bool loadLayer(QDataStream& xcf_io, XCFImage& xcf_image); + bool loadLayerProperties(QDataStream& xcf_io, Layer& layer); +- void composeTiles(XCFImage& xcf_image); ++ bool composeTiles(XCFImage& xcf_image); + void setGrayPalette(QImage& image); + void setPalette(XCFImage& xcf_image, QImage& image); + static void assignImageBytes(Layer& layer, uint i, uint j); +@@ -185,7 +185,7 @@ private: + static void assignMaskBytes(Layer& layer, uint i, uint j); + bool loadMask(QDataStream& xcf_io, Layer& layer); + bool loadChannelProperties(QDataStream& xcf_io, Layer& layer); +- void initializeImage(XCFImage& xcf_image); ++ bool initializeImage(XCFImage& xcf_image); + bool loadTileRLE(QDataStream& xcf_io, uchar* tile, int size, + int data_length, Q_INT32 bpp); + static void copyLayerToImage(XCFImage& xcf_image); +diff -u -3 -d -p -r1.12 -r1.12.2.1 +--- xview.cpp 22 Nov 2004 03:52:18 -0000 1.12 ++++ xview.cpp 19 Apr 2005 10:48:00 -0000 1.12.2.1 +@@ -7,6 +7,7 @@ + + #include <stdio.h> + #include <string.h> ++#include <stdlib.h> + #include <qimage.h> + + #include <kdelibs_export.h> +@@ -15,6 +16,9 @@ + + #define BUFSIZE 1024 + ++static const int b_255_3[]= {0,85,170,255}, // index*255/3 ++ rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 ++ + KDE_EXPORT void kimgio_xv_read( QImageIO *_imageio ) + { + int x=-1; +@@ -50,10 +54,14 @@ KDE_EXPORT void kimgio_xv_read( QImageIO + sscanf(str, "%d %d %d", &x, &y, &maxval); + + if (maxval != 255) return; ++ int blocksize = x*y; ++ if(x < 0 || y < 0 || blocksize < x || blocksize < y) ++ return; + + // now follows a binary block of x*y bytes. +- int blocksize = x*y; +- char *block = new char[ blocksize ]; ++ char *block = (char*) malloc(blocksize); ++ if(!block) ++ return; + + if (iodev->readBlock(block, blocksize) != blocksize ) + { +@@ -62,6 +70,10 @@ KDE_EXPORT void kimgio_xv_read( QImageIO + + // Create the image + QImage image( x, y, 8, maxval + 1, QImage::BigEndian ); ++ if( image.isNull()) { ++ free(block); ++ return; ++ } + + // how do the color handling? they are absolute 24bpp + // or at least can be calculated as such. +@@ -69,29 +81,9 @@ KDE_EXPORT void kimgio_xv_read( QImageIO + + for ( int j = 0; j < 256; j++ ) + { +-// ----------- OLIVER EIDEN +-// That is the old-code ! +-/* r = ((int) ((j >> 5) & 0x07)) << 5; +- g = ((int) ((j >> 2) & 0x07)) << 5; +- b = ((int) ((j >> 0) & 0x03)) << 6;*/ +- +- +-// That is the code-how xv, decode 3-3-2 pixmaps, it is slighly different, +-// but yields much better visuals results +-/* r = (((int) ((j >> 5) & 0x07)) *255) / 7; +- g = (((int) ((j >> 2) & 0x07)) *255) / 7; +- b = (((int) ((j >> 0) & 0x03)) *255) / 3;*/ +- +-// This is the same as xv, with multiplications/divisions replaced by indexing +- +-// Look-up table to avoid multiplications and divisons +- static int b_255_3[]= {0,85,170,255}, // index*255/3 +- rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7 +- + r = rg_255_7[((j >> 5) & 0x07)]; + g = rg_255_7[((j >> 2) & 0x07)]; + b = b_255_3[((j >> 0) & 0x03)]; +-// --------------- + image.setColor( j, qRgb( r, g, b ) ); + } + +@@ -104,7 +96,7 @@ KDE_EXPORT void kimgio_xv_read( QImageIO + _imageio->setImage( image ); + _imageio->setStatus( 0 ); + +- delete [] block; ++ free(block); + return; + } + diff --git a/kde-base/kdelibs/kdelibs-3.2.3-r9.ebuild b/kde-base/kdelibs/kdelibs-3.2.3-r9.ebuild new file mode 100644 index 000000000000..7b60e8461e49 --- /dev/null +++ b/kde-base/kdelibs/kdelibs-3.2.3-r9.ebuild @@ -0,0 +1,105 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/kde-base/kdelibs/kdelibs-3.2.3-r9.ebuild,v 1.1 2005/04/20 22:07:12 carlo Exp $ + +inherit kde eutils + +need-autoconf 2.5 +set-kdedir ${PV} + +DESCRIPTION="KDE libraries needed by all kde programs" +HOMEPAGE="http://www.kde.org/" +SRC_URI="mirror://kde/stable/${PV}/src/${PN}-${PV}.tar.bz2" + +LICENSE="GPL-2 LGPL-2" +SLOT="3.2" +KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~mips ~ppc ~sparc x86" +IUSE="alsa cups ipv6 ssl doc ldap" + +# kde.eclass has kdelibs in DEPEND, and we can't have that in here. +# so we recreate the entire DEPEND from scratch. +DEPEND=">=sys-devel/autoconf-2.58 + >=sys-devel/automake-1.8 + >=app-arch/bzip2-1.0.2 + >=dev-libs/libxslt-1.0.31 + >=dev-libs/libxml2-2.5.8 + >=dev-libs/libpcre-3.9 + ssl? ( >=dev-libs/openssl-0.9.6k ) + alsa? ( media-libs/alsa-lib virtual/alsa ) + cups? ( >=net-print/cups-1.1.19 ) + ldap? ( >=net-nds/openldap-2.0.25 ) + media-libs/tiff + >=app-admin/fam-2.6.10 + virtual/ghostscript + media-libs/libart_lgpl + sys-devel/gettext + ~kde-base/arts-1.2.3 + >=x11-libs/qt-3.2.3" +RDEPEND="${DEPEND} + app-text/sgml-common + cups? ( net-print/cups ) + doc? ( app-doc/doxygen ) + dev-lang/python" + +src_unpack() { + kde_src_unpack + epatch ${FILESDIR}/post-3.2.3-kdelibs-kcookiejar.patch + epatch ${FILESDIR}/post-3.2.3-kdelibs-kstandarddirs.patch + epatch ${FILESDIR}/post-3.2.3-kdelibs-htmlframes.patch + epatch ${FILESDIR}/post-3.2.3-kdelibs-htmlframes2.patch + epatch ${FILESDIR}/post-3.2.3-kdelibs-kio.diff + epatch ${FILESDIR}/post-3.2.3-kdelibs-khtml.diff + epatch ${FILESDIR}/post-3.2.3-kdelibs-kioslave.patch + epatch ${FILESDIR}/kde3-dcopidlng.patch + cd ${S}/dcop && patch -p0 < ${FILESDIR}/post-3.2.3-kdelibs-dcopserver.patch + cd ${S} + epatch ${FILESDIR}/post-3.2.3-kdelibs-dcop.patch + epatch ${FILESDIR}/post-3.2.3-kdelibs-idn.patch + + # kimgio input validation errors, see bug #88862 + epatch "${FILESDIR}/post-3.2.3-kdelibs-kimgio.diff" + make -f admin/Makefile.common || die +} + +src_compile() { + kde_src_compile myconf + + myconf="$myconf --with-distribution=Gentoo --enable-libfam --enable-dnotify" + myconf="$myconf `use_with alsa` `use_enable cups`" + + use ipv6 || myconf="$myconf --with-ipv6-lookup=no" + use ssl && myconf="$myconf --with-ssl-dir=/usr" || myconf="$myconf --without-ssl" + use alsa && myconf="$myconf --with-alsa" || myconf="$myconf --without-alsa" + use cups && myconf="$myconf --enable-cups" || myconf="$myconf --disable-cups" + + use x86 && myconf="$myconf --enable-fast-malloc=full" + + kde_src_compile configure make + + use doc && make apidox +} + +src_install() { + kde_src_install + dohtml *.html + + if use doc ; then + einfo "Copying API documentation..." + dodir ${KDEDIR}/share/doc/HTML/en/kdelibs-apidocs + cp -r ${S}/apidocs/* ${D}/$KDEDIR/share/doc/HTML/en/kdelibs-apidocs + else + rm -r ${D}/$KDEDIR/share/doc/HTML/en/kdelibs-apidocs + fi + + # needed to fix lib64 issues on amd64, see bug #45669 + use amd64 && ln -s ${KDEDIR}/lib ${D}/${KDEDIR}/lib64 + +} + +pkg_postinst() { + if use doc ; then + rm $KDEDIR/share/doc/HTML/en/kdelibs-apidocs/common + ln -sf $KDEDIR/share/doc/HTML/en/common \ + $KDEDIR/share/doc/HTML/en/kdelibs-apidocs/common + fi +} diff --git a/kde-base/kdelibs/kdelibs-3.3.2-r8.ebuild b/kde-base/kdelibs/kdelibs-3.3.2-r8.ebuild new file mode 100644 index 000000000000..a9a4255fd497 --- /dev/null +++ b/kde-base/kdelibs/kdelibs-3.3.2-r8.ebuild @@ -0,0 +1,130 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/kde-base/kdelibs/kdelibs-3.3.2-r8.ebuild,v 1.1 2005/04/20 22:07:12 carlo Exp $ + +inherit kde eutils flag-o-matic +set-kdedir 3.3 + +DESCRIPTION="KDE libraries needed by all kde programs" +HOMEPAGE="http://www.kde.org/" +SRC_URI="mirror://kde/stable/${PV}/src/${PN}-${PV}.tar.bz2" + +LICENSE="GPL-2 LGPL-2" +SLOT="3.3" +KEYWORDS="~amd64 ~hppa ~mips ~ppc ~ppc64 ~sparc x86 ~alpha" +IUSE="alsa arts cups doc ipv6 kerberos ldap spell ssl tiff" + +# kde.eclass has kdelibs in DEPEND, and we can't have that in here. +# so we recreate the entire DEPEND from scratch. +RDEPEND="arts? ( ~kde-base/arts-1.3.2 ) + >=x11-libs/qt-3.3.3 + app-arch/bzip2 + >=dev-libs/libxslt-1.1.4 + >=dev-libs/libxml2-2.6.6 + >=dev-libs/libpcre-4.2 + ssl? ( >=dev-libs/openssl-0.9.7d ) + alsa? ( media-libs/alsa-lib virtual/alsa ) + cups? ( >=net-print/cups-1.1.19 ) + ldap? ( >=net-nds/openldap-2.1.26 ) + tiff? ( media-libs/tiff ) + spell? ( || ( app-text/aspell + app-text/ispell ) ) + kerberos? ( virtual/krb5 ) + virtual/fam + virtual/ghostscript + media-libs/libart_lgpl + net-dns/libidn + sys-devel/gettext" + +DEPEND="${RDEPEND} + >=sys-devel/autoconf-2.58 + >=sys-devel/automake-1.8 + doc? ( app-doc/doxygen ) + !kde-misc/kgamma" + +src_unpack() { + kde_src_unpack + epatch ${FILESDIR}/post-3.3.2-kdelibs-kio.diff + epatch ${FILESDIR}/post-3.3.2-kdelibs-htmlframes2.patch + epatch ${FILESDIR}/post-3.3.2-kdelibs-kioslave.patch + + # see bug #67748. Patch applied in kdelibs 3.4.x. + epatch ${FILESDIR}/${P}-aspell-dir.patch + + # see bug #77127. Patch applied in kdelibs 3.3.3. + epatch ${FILESDIR}/${P}-anchor-fix.patch + + # see bug #81652. + epatch ${FILESDIR}/kde3-dcopidlng.patch + + # see bug #63529. + epatch ${FILESDIR}/${P}-ppc64.patch + + # see bug #83814. + epatch ${FILESDIR}/post-3.3.2-kdelibs-dcop.patch + + # see bug #81110. + epatch ${FILESDIR}/post-3.3.2-kdelibs-idn-2.patch + + # kimgio input validation errors, see bug #88862 + cd ${S}/kimgio && patch -p0 < "${FILESDIR}/post-3.3.2-kdelibs-kimgio.diff" +} + +src_compile() { + kde_src_compile myconf + + myconf="$myconf --with-distribution=Gentoo --enable-libfam --enable-dnotify" + myconf="$myconf $(use_with alsa) $(use_enable cups) $(use_with arts)" + + use ipv6 || myconf="$myconf --with-ipv6-lookup=no" + use ssl && myconf="$myconf --with-ssl-dir=/usr" || myconf="$myconf --without-ssl" + + use kerberos || myconf="$myconf --with-gssapi=no" + + use x86 && myconf="$myconf --enable-fast-malloc=full" + use ppc64 && append-flags -mminimal-toc + + kde_src_compile configure make + + use doc && make apidox +} + +src_install() { + kde_src_install + dohtml *.html + + if use doc ; then + einfo "Copying API documentation..." + dodir ${KDEDIR}/share/doc/HTML/en/kdelibs-apidocs + cp -r ${S}/apidocs/* ${D}/$KDEDIR/share/doc/HTML/en/kdelibs-apidocs + else + rm -r ${D}/$KDEDIR/share/doc/HTML/en/kdelibs-apidocs + fi + + # needed to fix lib64 issues on amd64, see bug #45669 + use amd64 && ln -s ${KDEDIR}/lib ${D}/${KDEDIR}/lib64 + # Needed to create lib -> lib64 symlink for amd64 2005.0 profile + if [ "${SYMLINK_LIB}" = "yes" ]; then + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) ${KDEDIR}/lib + fi + + if ! use arts ; then + + dodir /etc/env.d + + echo "PATH=${PREFIX}/bin +ROOTPATH=${PREFIX}/sbin:${PREFIX}/bin +LDPATH=${PREFIX}/lib +CONFIG_PROTECT=\"${PREFIX}/share/config ${PREFIX}/env ${PREFIX}/shutdown\"" > ${D}/etc/env.d/47kdepaths-3.3.1 # number goes down with version upgrade + + fi + +} + +pkg_postinst() { + if use doc ; then + rm $KDEDIR/share/doc/HTML/en/kdelibs-apidocs/common + ln -sf $KDEDIR/share/doc/HTML/en/common \ + $KDEDIR/share/doc/HTML/en/kdelibs-apidocs/common + fi +} diff --git a/kde-base/kdelibs/kdelibs-3.4.0-r1.ebuild b/kde-base/kdelibs/kdelibs-3.4.0-r1.ebuild new file mode 100644 index 000000000000..eb7473941932 --- /dev/null +++ b/kde-base/kdelibs/kdelibs-3.4.0-r1.ebuild @@ -0,0 +1,105 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/kde-base/kdelibs/kdelibs-3.4.0-r1.ebuild,v 1.1 2005/04/20 22:07:12 carlo Exp $ + +inherit kde eutils +set-qtdir 3 +set-kdedir 3.4 + +DESCRIPTION="KDE libraries needed by all kde programs" +HOMEPAGE="http://www.kde.org/" +SRC_URI="mirror://kde/stable/3.4/src/${P}.tar.bz2" + +LICENSE="GPL-2 LGPL-2" +SLOT="3.4" +KEYWORDS="~x86 ~amd64 ~sparc ~ppc" +IUSE="alsa arts cups doc jpeg2k kerberos openexr spell ssl tiff zeroconf" + +# kde.eclass has kdelibs in DEPEND, and we can't have that in here. +# so we recreate the entire DEPEND from scratch. +RDEPEND="arts? ( ~kde-base/arts-${PV} ) + >=x11-libs/qt-3.3.3 + app-arch/bzip2 + >=dev-libs/libxslt-1.1.4 + >=dev-libs/libxml2-2.6.6 + >=dev-libs/libpcre-4.2 + media-libs/libart_lgpl + net-dns/libidn + ssl? ( >=dev-libs/openssl-0.9.7d ) + alsa? ( media-libs/alsa-lib ) + cups? ( >=net-print/cups-1.1.19 ) + tiff? ( media-libs/tiff ) + kerberos? ( virtual/krb5 ) + jpeg2k? ( media-libs/jasper ) + openexr? ( >=media-libs/openexr-1.2 ) + spell? ( || ( app-text/aspell + app-text/ispell ) ) + zeroconf? ( net-misc/mDNSResponder ) + virtual/fam + virtual/ghostscript" + +DEPEND="${RDEPEND} + >=sys-devel/autoconf-2.58 + >=sys-devel/automake-1.8 + doc? ( app-doc/doxygen ) + sys-devel/gettext" + +# No longer needed; the bindings that required this (kdejava?) may need a patch +# from branch to work without this patch +#PATCHES="${FILESDIR}/${PN}-3.4.0_beta2-export-kio-symbols.diff" + +src_unpack() { + kde_src_unpack + + # Fix freezing in web forms (kde bug 100963). Applied for 3.4.1. + epatch "${FILESDIR}/${P}-form-freeze.patch" + + # Fix forms with images (kde bug 59701). Applied for 3.4.1. + epatch "${FILESDIR}/${P}-imagemap.patch" + + # kimgio input validation errors, bug 88862 + cd ${S}/kimgio && patch -p0 < "${FILESDIR}/post-3.4.0-kdelibs-kimgio.diff" +} + +src_compile() { + myconf="--with-distribution=Gentoo --enable-libfam --enable-dnotify" + myconf="${myconf} $(use_with alsa) $(use_with arts)" + myconf="${myconf} $(use_with tiff) $(use_with jpeg2k jasper) $(use_with openexr)" + myconf="${myconf} $(use_enable cups) $(use_enable zeroconf dnssd)" + + use ssl && myconf="${myconf} --with-ssl-dir=/usr" || myconf="${myconf} --without-ssl" + + use kerberos || myconf="${myconf} --with-gssapi=no" + + use x86 && myconf="${myconf} --enable-fast-malloc=full" + + kde_src_compile + + use doc && make apidox +} + +src_install() { + kde_src_install + + use doc && make DESTDIR=${D} install-apidox + + # needed to fix lib64 issues on amd64, see bug #45669 + use amd64 && ln -s ${KDEDIR}/lib ${D}/${KDEDIR}/lib64 + + # Needed to create lib -> lib64 symlink for amd64 2005.0 profile + if [ "${SYMLINK_LIB}" = "yes" ]; then + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) ${KDEDIR}/lib + fi + + if ! use arts ; then + dodir /etc/env.d + + cat <<EOF > ${D}/etc/env.d/46kdepaths-${SLOT} # number goes down with version upgrade +PATH=${PREFIX}/bin +ROOTPATH=${PREFIX}/sbin:${PREFIX}/bin +LDPATH=${PREFIX}/lib +CONFIG_PROTECT="${PREFIX}/share/config ${PREFIX}/env ${PREFIX}/shutdown" +EOF + fi + +} |