summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimagewriter
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 /tests/auto/qimagewriter
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 'tests/auto/qimagewriter')
-rw-r--r--tests/auto/qimagewriter/tst_qimagewriter.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp
index 878d398..70d9e70 100644
--- a/tests/auto/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp
@@ -97,6 +97,9 @@ private slots:
void saveWithNoFormat_data();
void saveWithNoFormat();
+ void resolution_data();
+ void resolution();
+
void saveToTemporaryFile();
};
@@ -162,7 +165,7 @@ tst_QImageWriter::tst_QImageWriter()
tst_QImageWriter::~tst_QImageWriter()
{
- QDir dir("images");
+ QDir dir(prefix + QLatin1String("images"));
QStringList filesToDelete = dir.entryList(QStringList() << "gen-*" , QDir::NoDotAndDotDot | QDir::Files);
foreach( QString file, filesToDelete) {
QFile::remove(dir.absoluteFilePath(file));
@@ -530,6 +533,39 @@ void tst_QImageWriter::saveWithNoFormat()
QVERIFY2(!outImage.isNull(), qPrintable(reader.errorString()));
}
+void tst_QImageWriter::resolution_data()
+{
+ QTest::addColumn<QString>("filename");
+ QTest::addColumn<int>("expectedDotsPerMeterX");
+ QTest::addColumn<int>("expectedDotsPerMeterY");
+#if defined QTEST_HAVE_TIFF
+ QTest::newRow("TIFF: 100 dpi") << ("image_100dpi.tif") << qRound(100 * (100 / 2.54)) << qRound(100 * (100 / 2.54));
+ QTest::newRow("TIFF: 50 dpi") << ("image_50dpi.tif") << qRound(50 * (100 / 2.54)) << qRound(50 * (100 / 2.54));
+ QTest::newRow("TIFF: 300 dot per meter") << ("image_300dpm.tif") << 300 << 300;
+#endif
+}
+
+void tst_QImageWriter::resolution()
+{
+ QFETCH(QString, filename);
+ QFETCH(int, expectedDotsPerMeterX);
+ QFETCH(int, expectedDotsPerMeterY);
+
+ QImage image(prefix + QLatin1String("colorful.bmp"));
+ image.setDotsPerMeterX(expectedDotsPerMeterX);
+ image.setDotsPerMeterY(expectedDotsPerMeterY);
+ const QString generatedFilepath = prefix + "gen-" + filename;
+ {
+ QImageWriter writer(generatedFilepath);
+ QVERIFY(writer.write(image));
+ }
+ QImageReader reader(generatedFilepath);
+ const QImage generatedImage = reader.read();
+
+ QCOMPARE(expectedDotsPerMeterX, generatedImage.dotsPerMeterX());
+ QCOMPARE(expectedDotsPerMeterY, generatedImage.dotsPerMeterY());
+}
+
void tst_QImageWriter::saveToTemporaryFile()
{
QImage image(prefix + "kollada.png");