summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index e6c7175..cd70fb9 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -272,6 +272,8 @@ bool QTiffHandlerPrivate::readHeaders(QIODevice *device)
format = QImage::Format_Mono;
else if (photometric == PHOTOMETRIC_MINISBLACK && bitPerSample == 8 && samplesPerPixel == 1)
format = QImage::Format_Grayscale8;
+ else if (photometric == PHOTOMETRIC_MINISBLACK && bitPerSample == 16 && samplesPerPixel == 1)
+ format = QImage::Format_Grayscale16;
else if ((grayscale || photometric == PHOTOMETRIC_PALETTE) && bitPerSample == 8 && samplesPerPixel == 1)
format = QImage::Format_Indexed8;
else if (samplesPerPixel < 4)
@@ -402,9 +404,11 @@ bool QTiffHandler::read(QImage *image)
}
}
bool format8bit = (format == QImage::Format_Mono || format == QImage::Format_Indexed8 || format == QImage::Format_Grayscale8);
+ bool format16bit = (format == QImage::Format_Grayscale16);
bool format64bit = (format == QImage::Format_RGBX64 || format == QImage::Format_RGBA64 || format == QImage::Format_RGBA64_Premultiplied);
- if (format8bit || format64bit) {
+ // Formats we read directly, instead of over RGBA32:
+ if (format8bit || format16bit || format64bit) {
int bytesPerPixel = image->depth() / 8;
if (format == QImage::Format_RGBX64)
bytesPerPixel = 6;
@@ -513,6 +517,7 @@ static QVector<QRgb> effectiveColorTable(const QImage &image)
colors[i] = qRgba(0, 0, 0, i);
break;
case QImage::Format_Grayscale8:
+ case QImage::Format_Grayscale16:
colors.resize(256);
for (int i = 0; i < 256; ++i)
colors[i] = qRgb(i, i, i);
@@ -622,6 +627,7 @@ bool QTiffHandler::write(const QImage &image)
TIFFClose(tiff);
} else if (format == QImage::Format_Indexed8
|| format == QImage::Format_Grayscale8
+ || format == QImage::Format_Grayscale16
|| format == QImage::Format_Alpha8) {
QVector<QRgb> colorTable = effectiveColorTable(image);
bool isGrayscale = checkGrayscale(colorTable);
@@ -631,7 +637,7 @@ bool QTiffHandler::write(const QImage &image)
photometric = PHOTOMETRIC_MINISWHITE;
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, image.depth())
|| !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) {
TIFFClose(tiff);
return false;