diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /krita/core/kis_pattern.cc | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/core/kis_pattern.cc')
-rw-r--r-- | krita/core/kis_pattern.cc | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/krita/core/kis_pattern.cc b/krita/core/kis_pattern.cc index db6ae0a1..516d3d8b 100644 --- a/krita/core/kis_pattern.cc +++ b/krita/core/kis_pattern.cc @@ -27,12 +27,12 @@ #include <limits.h> #include <stdlib.h> -#include <qpoint.h> -#include <qsize.h> -#include <qimage.h> -#include <qvaluevector.h> -#include <qmap.h> -#include <qfile.h> +#include <tqpoint.h> +#include <tqsize.h> +#include <tqimage.h> +#include <tqvaluevector.h> +#include <tqmap.h> +#include <tqfile.h> #include <kdebug.h> #include <klocale.h> @@ -43,19 +43,19 @@ namespace { struct GimpPatternHeader { - Q_UINT32 header_size; /* header_size = sizeof (PatternHeader) + brush name */ - Q_UINT32 version; /* pattern file version # */ - Q_UINT32 width; /* width of pattern */ - Q_UINT32 height; /* height of pattern */ - Q_UINT32 bytes; /* depth of pattern in bytes : 1, 2, 3 or 4*/ - Q_UINT32 magic_number; /* GIMP brush magic number */ + TQ_UINT32 header_size; /* header_size = sizeof (PatternHeader) + brush name */ + TQ_UINT32 version; /* pattern file version # */ + TQ_UINT32 width; /* width of pattern */ + TQ_UINT32 height; /* height of pattern */ + TQ_UINT32 bytes; /* depth of pattern in bytes : 1, 2, 3 or 4*/ + TQ_UINT32 magic_number; /* GIMP brush magic number */ }; // Yes! This is _NOT_ what my pat.txt file says. It's really not 'GIMP', but 'GPAT' - Q_UINT32 const GimpPatternMagic = (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0)); + TQ_UINT32 const GimpPatternMagic = (('G' << 24) + ('P' << 16) + ('A' << 8) + ('T' << 0)); } -KisPattern::KisPattern(const QString& file) : super(file), m_hasFile(true) +KisPattern::KisPattern(const TQString& file) : super(file), m_hasFile(true) { } @@ -64,7 +64,7 @@ KisPattern::KisPattern(KisPaintDevice* image, int x, int y, int w, int h) { // Forcefully convert to RGBA8 // XXX profile and exposure? - setImage(image->convertToQImage(0, x, y, w, h)); + setImage(image->convertToTQImage(0, x, y, w, h)); setName(image->name()); } @@ -77,11 +77,11 @@ bool KisPattern::load() if (!m_hasFile) return true; - QFile file(filename()); + TQFile file(filename()); file.open(IO_ReadOnly); - QByteArray data = file.readAll(); + TQByteArray data = file.readAll(); if (!data.isEmpty()) { - Q_INT32 startPos = m_data.size(); + TQ_INT32 startPos = m_data.size(); m_data.resize(m_data.size() + data.count()); memcpy(&m_data[startPos], data.data(), data.count()); @@ -92,10 +92,10 @@ bool KisPattern::load() bool KisPattern::save() { - QFile file(filename()); + TQFile file(filename()); file.open(IO_WriteOnly | IO_Truncate); - QTextStream stream(&file); + TQTextStream stream(&file); // Header: header_size (24+name length),version,width,height,colourdepth of brush,magic,name // depth: 1 = greyscale, 2 = greyscale + A, 3 = RGB, 4 = RGBA // magic = "GPAT", as a single uint32, the docs are wrong here! @@ -105,9 +105,9 @@ bool KisPattern::save() // Version is 1 for now... GimpPatternHeader ph; - QCString utf8Name = name().utf8(); + TQCString utf8Name = name().utf8(); char const* name = utf8Name.data(); - int nameLength = qstrlen(name); + int nameLength = tqstrlen(name); ph.header_size = htonl(sizeof(GimpPatternHeader) + nameLength + 1); // trailing 0 ph.version = htonl(1); @@ -116,7 +116,7 @@ bool KisPattern::save() ph.bytes = htonl(4); ph.magic_number = htonl(GimpPatternMagic); - QByteArray bytes; + TQByteArray bytes; bytes.setRawData(reinterpret_cast<char*>(&ph), sizeof(GimpPatternHeader)); int wrote = file.writeBlock(bytes); bytes.resetRawData(reinterpret_cast<char*>(&ph), sizeof(GimpPatternHeader)); @@ -130,14 +130,14 @@ bool KisPattern::save() int k = 0; bytes.resize(width() * height() * 4); - for (Q_INT32 y = 0; y < height(); y++) { - for (Q_INT32 x = 0; x < width(); x++) { + for (TQ_INT32 y = 0; y < height(); y++) { + for (TQ_INT32 x = 0; x < width(); x++) { // RGBA only - QRgb pixel = m_img.pixel(x,y); - bytes[k++] = static_cast<char>(qRed(pixel)); - bytes[k++] = static_cast<char>(qGreen(pixel)); - bytes[k++] = static_cast<char>(qBlue(pixel)); - bytes[k++] = static_cast<char>(qAlpha(pixel)); + TQRgb pixel = m_img.pixel(x,y); + bytes[k++] = static_cast<char>(tqRed(pixel)); + bytes[k++] = static_cast<char>(tqGreen(pixel)); + bytes[k++] = static_cast<char>(tqBlue(pixel)); + bytes[k++] = static_cast<char>(tqAlpha(pixel)); } } @@ -150,7 +150,7 @@ bool KisPattern::save() return true; } -QImage KisPattern::img() +TQImage KisPattern::img() { return m_img; } @@ -159,8 +159,8 @@ bool KisPattern::init() { // load Gimp patterns GimpPatternHeader bh; - Q_INT32 k; - QValueVector<char> name; + TQ_INT32 k; + TQValueVector<char> name; if (sizeof(GimpPatternHeader) > m_data.size()) { return false; @@ -195,47 +195,47 @@ bool KisPattern::init() if (bh.bytes == 1) { // Grayscale - Q_INT32 val; + TQ_INT32 val; - for (Q_UINT32 y = 0; y < bh.height; y++) { - for (Q_UINT32 x = 0; x < bh.width; x++, k++) { - if (static_cast<Q_UINT32>(k) > m_data.size()) { + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { + if (static_cast<TQ_UINT32>(k) > m_data.size()) { kdDebug(DBG_AREA_FILE) << "failed in gray\n"; return false; } val = m_data[k]; - m_img.setPixel(x, y, qRgb(val, val, val)); + m_img.setPixel(x, y, tqRgb(val, val, val)); m_img.setAlphaBuffer(false); } } } else if (bh.bytes == 2) { // Grayscale + A - Q_INT32 val; - Q_INT32 alpha; - for (Q_UINT32 y = 0; y < bh.height; y++) { - for (Q_UINT32 x = 0; x < bh.width; x++, k++) { - if (static_cast<Q_UINT32>(k + 2) > m_data.size()) { + TQ_INT32 val; + TQ_INT32 alpha; + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++, k++) { + if (static_cast<TQ_UINT32>(k + 2) > m_data.size()) { kdDebug(DBG_AREA_FILE) << "failed in grayA\n"; return false; } val = m_data[k]; alpha = m_data[k++]; - m_img.setPixel(x, y, qRgba(val, val, val, alpha)); + m_img.setPixel(x, y, tqRgba(val, val, val, alpha)); m_img.setAlphaBuffer(true); } } } else if (bh.bytes == 3) { // RGB without alpha - for (Q_UINT32 y = 0; y < bh.height; y++) { - for (Q_UINT32 x = 0; x < bh.width; x++) { - if (static_cast<Q_UINT32>(k + 3) > m_data.size()) { + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++) { + if (static_cast<TQ_UINT32>(k + 3) > m_data.size()) { kdDebug(DBG_AREA_FILE) << "failed in RGB\n"; return false; } - m_img.setPixel(x, y, qRgb(m_data[k], + m_img.setPixel(x, y, tqRgb(m_data[k], m_data[k + 1], m_data[k + 2])); k += 3; @@ -244,14 +244,14 @@ bool KisPattern::init() } } else if (bh.bytes == 4) { // Has alpha - for (Q_UINT32 y = 0; y < bh.height; y++) { - for (Q_UINT32 x = 0; x < bh.width; x++) { - if (static_cast<Q_UINT32>(k + 4) > m_data.size()) { + for (TQ_UINT32 y = 0; y < bh.height; y++) { + for (TQ_UINT32 x = 0; x < bh.width; x++) { + if (static_cast<TQ_UINT32>(k + 4) > m_data.size()) { kdDebug(DBG_AREA_FILE) << "failed in RGBA\n"; return false; } - m_img.setPixel(x, y, qRgba(m_data[k], + m_img.setPixel(x, y, tqRgba(m_data[k], m_data[k + 1], m_data[k + 2], m_data[k + 3])); @@ -277,7 +277,7 @@ bool KisPattern::init() KisPaintDeviceSP KisPattern::image(KisColorSpace * colorSpace) { // Check if there's already a pattern prepared for this colorspace - QMap<QString, KisPaintDeviceSP>::const_iterator it = m_colorspaces.find(colorSpace->id().id()); + TQMap<TQString, KisPaintDeviceSP>::const_iterator it = m_colorspaces.tqfind(colorSpace->id().id()); if (it != m_colorspaces.end()) return (*it); @@ -286,33 +286,33 @@ KisPaintDeviceSP KisPattern::image(KisColorSpace * colorSpace) { Q_CHECK_PTR(layer); - layer->convertFromQImage(m_img,""); + layer->convertFromTQImage(m_img,""); m_colorspaces[colorSpace->id().id()] = layer; return layer; } -Q_INT32 KisPattern::width() const +TQ_INT32 KisPattern::width() const { return m_width; } -void KisPattern::setWidth(Q_INT32 w) +void KisPattern::setWidth(TQ_INT32 w) { m_width = w; } -Q_INT32 KisPattern::height() const +TQ_INT32 KisPattern::height() const { return m_height; } -void KisPattern::setHeight(Q_INT32 h) +void KisPattern::setHeight(TQ_INT32 h) { m_height = h; } -void KisPattern::setImage(const QImage& img) +void KisPattern::setImage(const TQImage& img) { m_hasFile = false; m_img = img; |