summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-01-31 15:36:05 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-10 18:36:26 +0100
commit5c4036eeb2ecdfdac5a403ce43bdd1b0c9a53efb (patch)
treed18d14734ee455d96f2bf25c141759d139d6883e
parente9e7dca9dad1ce0a9a5f9b579db1f209b96695c4 (diff)
Use RGBA8888 format to simplify TIFF writing
We write TIFF files using big-endian RGBA, by using the RGBA8888 QImage format we can remove the manual conversion done in qtiffhandler. Change-Id: I4a7f4810ce4332d1608813d9cd6371bc13d94df0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp24
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler_p.h1
2 files changed, 3 insertions, 22 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index ef76a6d..e217785 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -403,7 +403,7 @@ bool QTiffHandler::write(const QImage &image)
return false;
TIFF *const tiff = TIFFClientOpen("foo",
- "w",
+ "wB",
this,
qtiffReadProc,
qtiffWriteProc,
@@ -560,22 +560,17 @@ bool QTiffHandler::write(const QImage &image)
TIFFClose(tiff);
return false;
}
- // try to do the ARGB32 conversion in chunks no greater than 16 MB
+ // try to do the RGBA8888 conversion in chunks no greater than 16 MB
int chunks = (width * height * 4 / (1024 * 1024 * 16)) + 1;
int chunkHeight = qMax(height / chunks, 1);
int y = 0;
while (y < height) {
- QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y)).convertToFormat(QImage::Format_ARGB32);
+ QImage chunk = image.copy(0, y, width, qMin(chunkHeight, height - y)).convertToFormat(QImage::Format_RGBA8888);
int chunkStart = y;
int chunkEnd = y + chunk.height();
while (y < chunkEnd) {
- if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
- convert32BitOrder(chunk.scanLine(y - chunkStart), width);
- else
- convert32BitOrderBigEndian(chunk.scanLine(y - chunkStart), width);
-
if (TIFFWriteScanline(tiff, reinterpret_cast<uint32 *>(chunk.scanLine(y - chunkStart)), y) != 1) {
TIFFClose(tiff);
return false;
@@ -654,17 +649,4 @@ void QTiffHandler::convert32BitOrder(void *buffer, int width)
| ((p & 0x000000ff) << 16);
}
}
-
-void QTiffHandler::convert32BitOrderBigEndian(void *buffer, int width)
-{
- uint32 *target = reinterpret_cast<uint32 *>(buffer);
- for (int32 x=0; x<width; ++x) {
- uint32 p = target[x];
- target[x] = (p & 0xff000000) >> 24
- | (p & 0x00ff0000) << 8
- | (p & 0x0000ff00) << 8
- | (p & 0x000000ff) << 8;
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/tiff/qtiffhandler_p.h b/src/plugins/imageformats/tiff/qtiffhandler_p.h
index 51268aa..82da2ad 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler_p.h
+++ b/src/plugins/imageformats/tiff/qtiffhandler_p.h
@@ -69,7 +69,6 @@ public:
};
private:
void convert32BitOrder(void *buffer, int width);
- void convert32BitOrderBigEndian(void *buffer, int width);
int compression;
};