summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2009-05-19 11:59:54 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2009-05-19 12:01:17 (GMT)
commitac70ce3f2598f0f3aae64c2e39c580375fd62df0 (patch)
tree8f30d62b36c73447538d29e291ce84bc8e580652 /src/plugins
parentfdce2331a7491b5452c63666267ca2b8b98d1298 (diff)
downloadQt-ac70ce3f2598f0f3aae64c2e39c580375fd62df0.zip
Qt-ac70ce3f2598f0f3aae64c2e39c580375fd62df0.tar.gz
Qt-ac70ce3f2598f0f3aae64c2e39c580375fd62df0.tar.bz2
Set the resolution when saving a tiff file
The resolution was not saved when the image was saved as tiff. This fix add the resolution, and try to guess if the user have set it in dpi or dot per centimeter Task-number: 245242 Reviewed-by: Samuel
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/imageformats/tiff/qtiffhandler.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index 518e6d1..77dfeb3 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -168,7 +168,7 @@ bool QTiffHandler::read(QImage *image)
break;
default:
// do nothing as defaults have already
- // been set within the QImage class
+ // been set within the QImage class
break;
}
for (uint32 y=0; y<height; ++y)
@@ -218,6 +218,24 @@ bool QTiffHandler::write(const QImage &image)
return false;
}
+ // set the resolution
+ bool resolutionSet = false;
+ const int dotPerMeterX = image.dotsPerMeterX();
+ const int dotPerMeterY = image.dotsPerMeterY();
+ if ((dotPerMeterX % 100) == 0
+ && (dotPerMeterY % 100) == 0) {
+ resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER)
+ && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, dotPerMeterX/100.0)
+ && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, dotPerMeterY/100.0);
+ } else {
+ resolutionSet = TIFFSetField(tiff, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH)
+ && TIFFSetField(tiff, TIFFTAG_XRESOLUTION, static_cast<float>(image.logicalDpiX()))
+ && TIFFSetField(tiff, TIFFTAG_YRESOLUTION, static_cast<float>(image.logicalDpiY()));
+ }
+ if (!resolutionSet) {
+ TIFFClose(tiff);
+ return false;
+ }
// try to do the ARGB32 conversion in chunks no greater than 16 MB
int chunks = (width * height * 4 / (1024 * 1024 * 16)) + 1;
int chunkHeight = qMax(height / chunks, 1);