summaryrefslogtreecommitdiffstats
path: root/src/gvcore/xpm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gvcore/xpm.cpp')
-rw-r--r--src/gvcore/xpm.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/src/gvcore/xpm.cpp b/src/gvcore/xpm.cpp
index ce7656f..49acb8e 100644
--- a/src/gvcore/xpm.cpp
+++ b/src/gvcore/xpm.cpp
@@ -4,33 +4,33 @@
/****************************************************************************
**
**
-** Implementation of QImage and QImageIO classes
+** Implementation of TQImage and TQImageIO classes
**
** Created : 950207
**
** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
**
-** This file is part of the kernel module of the Qt GUI Toolkit.
+** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
-** LICENSE.QPL included in the packaging of this file.
+** LICENSE.TQPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
-** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
-** licenses may use this file in accordance with the Qt Commercial License
+** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
+** licenses may use this file in accordance with the TQt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email [email protected] for
-** information about Qt Commercial License Agreements.
-** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** information about TQt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for TQPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact [email protected] if any conditions of this licensing are
@@ -42,7 +42,7 @@
This code is xpm loader copied from qimage.cpp, with changes making it
possible to use this class from another thread. The problem is that
- QColor::setNamedColor() isn't reentrant without thread-safe Xlib,
+ TQColor::setNamedColor() isn't reentrant without thread-safe Xlib,
i.e. without XInitThreads() called. Current KDE applications
don't call XInitThreads(), and since it needs to be the very first
Xlib function called, and Gwenview is also a KPart, it's not possible
@@ -56,25 +56,25 @@
#include "xpm.h"
-#include <qimage.h>
-#include <qmap.h>
-#include <qregexp.h>
+#include <tqimage.h>
+#include <tqmap.h>
+#include <tqregexp.h>
#include "threadgate.h"
namespace Gwenview {
-// Qt code start ---------------------------
-static QString fbname( const QString &fileName ) // get file basename (sort of)
+// TQt code start ---------------------------
+static TQString fbname( const TQString &fileName ) // get file basename (sort of)
{
- QString s = fileName;
+ TQString s = fileName;
if ( !s.isEmpty() ) {
int i;
- if ( (i = s.findRev('/')) >= 0 )
+ if ( (i = s.tqfindRev('/')) >= 0 )
s = s.mid( i );
- if ( (i = s.findRev('\\')) >= 0 )
+ if ( (i = s.tqfindRev('\\')) >= 0 )
s = s.mid( i );
- QRegExp r( QString::fromLatin1("[a-zA-Z][a-zA-Z0-9_]*") );
+ TQRegExp r( TQString::tqfromLatin1("[a-zA-Z][a-zA-Z0-9_]*") );
int p = r.search( s );
if ( p == -1 )
s.truncate( 0 );
@@ -82,7 +82,7 @@ static QString fbname( const QString &fileName ) // get file basename (sort of)
s = s.mid( p, r.matchedLength() );
}
if ( s.isEmpty() )
- s = QString::fromLatin1( "dummy" );
+ s = TQString::tqfromLatin1( "dummy" );
return s;
}
@@ -94,7 +94,7 @@ static QString fbname( const QString &fileName ) // get file basename (sort of)
// Skip until ", read until the next ", return the rest in *buf
// Returns FALSE on error, TRUE on success
-static bool read_xpm_string( QCString &buf, QIODevice *d,
+static bool read_xpm_string( TQCString &buf, TQIODevice *d,
const char * const *source, int &index )
{
if ( source ) {
@@ -130,42 +130,42 @@ static bool read_xpm_string( QCString &buf, QIODevice *d,
-static int nextColorSpec(const QCString & buf)
+static int nextColorSpec(const TQCString & buf)
{
- int i = buf.find(" c ");
+ int i = buf.tqfind(" c ");
if (i < 0)
- i = buf.find(" g ");
+ i = buf.tqfind(" g ");
if (i < 0)
- i = buf.find(" g4 ");
+ i = buf.tqfind(" g4 ");
if (i < 0)
- i = buf.find(" m ");
+ i = buf.tqfind(" m ");
if (i < 0)
- i = buf.find(" s ");
+ i = buf.tqfind(" s ");
return i;
}
//
// INTERNAL
//
-// Reads an .xpm from either the QImageIO or from the QString *.
+// Reads an .xpm from either the TQImageIO or from the TQString *.
// One of the two HAS to be 0, the other one is used.
//
-static void read_xpm_image_or_array( QImageIO * iio, const char * const * source,
- QImage & image)
+static void read_xpm_image_or_array( TQImageIO * iio, const char * const * source,
+ TQImage & image)
{
- QCString buf;
- QIODevice *d = 0;
+ TQCString buf;
+ TQIODevice *d = 0;
buf.resize( 200 );
int i, cpp, ncols, w, h, index = 0;
if ( iio ) {
- iio->setStatus( 1 );
+ iio->setqStatus( 1 );
d = iio ? iio->ioDevice() : 0;
d->readLine( buf.data(), buf.size() ); // "/* XPM */"
- QRegExp r( QString::fromLatin1("/\\*.XPM.\\*/") );
- if ( buf.find(r) == -1 )
+ TQRegExp r( TQString::tqfromLatin1("/\\*.XPM.\\*/") );
+ if ( buf.tqfind(r) == -1 )
return; // bad magic
} else if ( !source ) {
return;
@@ -189,24 +189,24 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
if (image.isNull())
return;
- QMap<QString, int> colorMap;
+ TQMap<TQString, int> colorMap;
int currentColor;
for( currentColor=0; currentColor < ncols; ++currentColor ) {
if ( !read_xpm_string( buf, d, source, index ) ) {
-#if defined(QT_CHECK_RANGE)
- qWarning( "QImage: XPM color specification missing");
+#if defined(TQT_CHECK_RANGE)
+ qWarning( "TQImage: XPM color specification missing");
#endif
return;
}
- QString index;
+ TQString index;
index = buf.left( cpp );
buf = buf.mid( cpp ).simplifyWhiteSpace().lower();
buf.prepend( " " );
i = nextColorSpec(buf);
if ( i < 0 ) {
-#if defined(QT_CHECK_RANGE)
- qWarning( "QImage: XPM color specification is missing: %s", buf.data());
+#if defined(TQT_CHECK_RANGE)
+ qWarning( "TQImage: XPM color specification is missing: %s", buf.data());
#endif
return; // no c/g/g4/m/s specification at all
}
@@ -221,10 +221,10 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
int transparentColor = currentColor;
if ( image.depth() == 8 ) {
image.setColor( transparentColor,
- RGB_MASK & qRgb(198,198,198) );
+ TQRGB_MASK & tqRgb(198,198,198) );
colorMap.insert( index, transparentColor );
} else {
- QRgb rgb = RGB_MASK & qRgb(198,198,198);
+ TQRgb rgb = TQRGB_MASK & tqRgb(198,198,198);
colorMap.insert( index, rgb );
}
} else {
@@ -232,15 +232,15 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
buf.truncate (((buf.length()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick
}
#ifdef GV_XPM_CHANGES
- QColor c = ThreadGate::instance()->color( buf.data());
+ TQColor c = ThreadGate::instance()->color( buf.data());
#else
- QColor c( buf.data() );
+ TQColor c( buf.data() );
#endif
if ( image.depth() == 8 ) {
image.setColor( currentColor, 0xff000000 | c.rgb() );
colorMap.insert( index, currentColor );
} else {
- QRgb rgb = 0xff000000 | c.rgb();
+ TQRgb rgb = 0xff000000 | c.rgb();
colorMap.insert( index, rgb );
}
}
@@ -249,8 +249,8 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
// Read pixels
for( int y=0; y<h; y++ ) {
if ( !read_xpm_string( buf, d, source, index ) ) {
-#if defined(QT_CHECK_RANGE)
- qWarning( "QImage: XPM pixels missing on image line %d", y);
+#if defined(TQT_CHECK_RANGE)
+ qWarning( "TQImage: XPM pixels missing on image line %d", y);
#endif
return;
}
@@ -276,7 +276,7 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
}
}
} else {
- QRgb *p = (QRgb*)image.scanLine(y);
+ TQRgb *p = (TQRgb*)image.scanLine(y);
uchar *d = (uchar *)buf.data();
uchar *end = d + buf.length();
int x;
@@ -284,21 +284,21 @@ static void read_xpm_image_or_array( QImageIO * iio, const char * const * source
b[cpp] = '\0';
for ( x=0; x<w && d<end; x++ ) {
strncpy( b, (char *)d, cpp );
- *p++ = (QRgb)colorMap[b];
+ *p++ = (TQRgb)colorMap[b];
d += cpp;
}
}
}
if ( iio ) {
iio->setImage( image );
- iio->setStatus( 0 ); // image ok
+ iio->setqStatus( 0 ); // image ok
}
}
-static void read_xpm_image( QImageIO * iio )
+static void read_xpm_image( TQImageIO * iio )
{
- QImage i;
+ TQImage i;
(void)read_xpm_image_or_array( iio, 0, i );
return;
}
@@ -308,7 +308,7 @@ static const char* xpm_color_name( int cpp, int index )
{
static char returnable[5];
static const char code[] = ".#abcdefghijklmnopqrstuvwxyzABCD"
- "EFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ "EFGHIJKLMNOPTQRSTUVWXYZ0123456789";
// cpp is limited to 4 and index is limited to 64^cpp
if ( cpp > 1 ) {
if ( cpp > 2 ) {
@@ -337,31 +337,31 @@ static const char* xpm_color_name( int cpp, int index )
// write XPM image data
-static void write_xpm_image( QImageIO * iio )
+static void write_xpm_image( TQImageIO * iio )
{
if ( iio )
- iio->setStatus( 1 );
+ iio->setqStatus( 1 );
else
return;
// ### 8-bit case could be made faster
- QImage image;
+ TQImage image;
if ( iio->image().depth() != 32 )
image = iio->image().convertDepth( 32 );
else
image = iio->image();
- QMap<QRgb, int> colorMap;
+ TQMap<TQRgb, int> colorMap;
int w = image.width(), h = image.height(), ncolors = 0;
int x, y;
// build color table
for( y=0; y<h; y++ ) {
- QRgb * yp = (QRgb *)image.scanLine( y );
+ TQRgb * yp = (TQRgb *)image.scanLine( y );
for( x=0; x<w; x++ ) {
- QRgb color = *(yp + x);
- if ( !colorMap.contains(color) )
+ TQRgb color = *(yp + x);
+ if ( !colorMap.tqcontains(color) )
colorMap.insert( color, ncolors++ );
}
}
@@ -376,27 +376,27 @@ static void write_xpm_image( QImageIO * iio )
break;
}
- QString line;
+ TQString line;
// write header
- QTextStream s( iio->ioDevice() );
+ TQTextStream s( iio->ioDevice() );
s << "/* XPM */" << endl
<< "static char *" << fbname(iio->fileName()) << "[]={" << endl
<< "\"" << w << " " << h << " " << ncolors << " " << cpp << "\"";
// write palette
- QMap<QRgb, int>::Iterator c = colorMap.begin();
+ TQMap<TQRgb, int>::Iterator c = colorMap.begin();
while ( c != colorMap.end() ) {
- QRgb color = c.key();
- if ( image.hasAlphaBuffer() && color == (color & RGB_MASK) )
+ TQRgb color = c.key();
+ if ( image.hasAlphaBuffer() && color == (color & TQRGB_MASK) )
line.sprintf( "\"%s c None\"",
xpm_color_name(cpp, *c) );
else
line.sprintf( "\"%s c #%02x%02x%02x\"",
xpm_color_name(cpp, *c),
- qRed(color),
- qGreen(color),
- qBlue(color) );
+ tqRed(color),
+ tqGreen(color),
+ tqBlue(color) );
++c;
s << "," << endl << line;
}
@@ -404,11 +404,11 @@ static void write_xpm_image( QImageIO * iio )
// write pixels, limit to 4 characters per pixel
line.truncate( cpp*w );
for( y=0; y<h; y++ ) {
- QRgb * yp = (QRgb *) image.scanLine( y );
+ TQRgb * yp = (TQRgb *) image.scanLine( y );
int cc = 0;
for( x=0; x<w; x++ ) {
int color = (int)(*(yp + x));
- QCString chars = xpm_color_name( cpp, colorMap[color] );
+ TQCString chars = xpm_color_name( cpp, colorMap[color] );
line[cc++] = chars[0];
if ( cpp > 1 ) {
line[cc++] = chars[1];
@@ -424,15 +424,15 @@ static void write_xpm_image( QImageIO * iio )
}
s << "};" << endl;
- iio->setStatus( 0 );
+ iio->setqStatus( 0 );
}
-// Qt code end ---------------------------
+// TQt code end ---------------------------
XPM::XPM()
{
- QImageIO::inputFormats(); // trigger registration of Qt's handlers
- QImageIO::defineIOHandler( "XPM", "/\\*.XPM.\\*/", "T",
+ TQImageIO::inputFormats(); // trigger registration of TQt's handlers
+ TQImageIO::defineIOHandler( "XPM", "/\\*.XPM.\\*/", "T",
read_xpm_image, write_xpm_image );
}