diff options
Diffstat (limited to 'tests/auto/tiff/tst_qtiff.cpp')
-rw-r--r-- | tests/auto/tiff/tst_qtiff.cpp | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/tests/auto/tiff/tst_qtiff.cpp b/tests/auto/tiff/tst_qtiff.cpp index 8e8fd68..70837a5 100644 --- a/tests/auto/tiff/tst_qtiff.cpp +++ b/tests/auto/tiff/tst_qtiff.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtAddOn.ImageFormats module of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -36,6 +36,7 @@ Q_DECLARE_METATYPE(QImage::Format) Q_DECLARE_METATYPE(QImageWriter::ImageWriterError) +Q_DECLARE_METATYPE(QImageIOHandler::Transformation) typedef QList<int> QIntList; Q_DECLARE_METATYPE(QIntList) @@ -363,43 +364,43 @@ void tst_qtiff::readWriteNonDestructive_data() { QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("expectedFormat"); - QTest::addColumn<bool>("grayscale"); - QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono << false; - QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << false; - QTest::newRow("tiff argb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32 << false; - QTest::newRow("tiff rgb32") << QImage::Format_RGB32 << QImage::Format_RGB32 << false; - QTest::newRow("tiff grayscale") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << true; + QTest::addColumn<QImageIOHandler::Transformation>("transformation"); + QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono << QImageIOHandler::TransformationNone; + QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << QImageIOHandler::TransformationMirror; + QTest::newRow("tiff argb32pm") << QImage::Format_ARGB32_Premultiplied << QImage::Format_ARGB32_Premultiplied << QImageIOHandler::TransformationRotate90; + QTest::newRow("tiff rgb32") << QImage::Format_RGB32 << QImage::Format_RGB32 << QImageIOHandler::TransformationRotate270; + QTest::newRow("tiff grayscale") << QImage::Format_Grayscale8 << QImage::Format_Grayscale8 << QImageIOHandler::TransformationFlip; } void tst_qtiff::readWriteNonDestructive() { QFETCH(QImage::Format, format); QFETCH(QImage::Format, expectedFormat); - QFETCH(bool, grayscale); + QFETCH(QImageIOHandler::Transformation, transformation); + QImage image = QImage(prefix + "colorful.bmp").convertToFormat(format); QVERIFY(!image.isNull()); - if (grayscale) { - QVector<QRgb> colors; - for (int i = 0; i < 256; ++i) - colors << qRgb(i, i, i); - image.setColorTable(colors); - } - QByteArray output; QBuffer buf(&output); QVERIFY(buf.open(QIODevice::WriteOnly)); - QVERIFY(image.save(&buf, "tiff")); + QImageWriter writer(&buf, "tiff"); + writer.setTransformation(transformation); + writer.write(image); buf.close(); QVERIFY(buf.open(QIODevice::ReadOnly)); QImageReader reader(&buf); + QCOMPARE(reader.imageFormat(), expectedFormat); + QCOMPARE(reader.size(), image.size()); + QCOMPARE(reader.autoTransform(), true); + reader.setAutoTransform(false); + QCOMPARE(reader.transformation(), transformation); QImage image2 = reader.read(); QVERIFY2(!image.isNull(), qPrintable(reader.errorString())); - QImage::Format readFormat = image2.format(); - QCOMPARE(readFormat, expectedFormat); - QCOMPARE(image, image2); + QCOMPARE(image2.format(), expectedFormat); + QCOMPARE(image2, image); } void tst_qtiff::largeTiff() @@ -408,7 +409,7 @@ void tst_qtiff::largeTiff() QSKIP("not tested on WinCE"); #endif - QImage img(4096, 2048, QImage::Format_ARGB32); + QImage img(4096, 2048, QImage::Format_ARGB32_Premultiplied); QPainter p(&img); img.fill(0x0); @@ -439,8 +440,11 @@ void tst_qtiff::supportsOption_data() { QTest::addColumn<QIntList>("options"); - QTest::newRow("tiff") << (QIntList() << QImageIOHandler::Size - << QImageIOHandler::CompressionRatio); + QTest::newRow("tiff") << (QIntList() + << QImageIOHandler::Size + << QImageIOHandler::CompressionRatio + << QImageIOHandler::ImageTransformation + << QImageIOHandler::TransformedByDefault); } void tst_qtiff::supportsOption() @@ -461,7 +465,9 @@ void tst_qtiff::supportsOption() << QImageIOHandler::IncrementalReading << QImageIOHandler::Endianness << QImageIOHandler::Animation - << QImageIOHandler::BackgroundColor; + << QImageIOHandler::BackgroundColor + << QImageIOHandler::ImageTransformation + << QImageIOHandler::TransformedByDefault; QImageWriter writer; writer.setFormat("tiff"); |