From 16c32c6dfbca03a46d1a2bb87b6c1c365e6179d5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Sat, 27 Dec 2014 20:36:37 +0100 Subject: JPEG: Fix reading of EXIF orientation. The orientation is unsigned short, read it as such. In JPEG-files created by Ricoh/Pentax cameras, the data is saved in Motorola format. Reading the wrong data size will produce invalid values when converting the byte order. Change-Id: I8f7c5dc5bfc10c02e090d3654aaefa047229a962 Task-number: QTBUG-43563 Reviewed-by: Friedemann Kleint --- .../jpeg_exif_orientation_value_6_motorola.jpg | Bin 0 -> 911 bytes tests/auto/gui/image/qimage/tst_qimage.cpp | 33 +++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg (limited to 'tests/auto/gui/image/qimage') diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg new file mode 100644 index 0000000000..0aa164b78b Binary files /dev/null and b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6_motorola.jpg differ diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index fcee2884d9..1fef747399 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -173,6 +173,7 @@ private slots: void invertPixelsRGB_data(); void invertPixelsRGB(); + void exifOrientation_data(); void exifOrientation(); void cleanupFunctions(); @@ -2626,20 +2627,34 @@ void tst_QImage::invertPixelsRGB() QCOMPARE(qBlue(pixel) >> 4, (255 - 96) >> 4); } +void tst_QImage::exifOrientation_data() +{ + QTest::addColumn("fileName"); + QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg"; + QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg"; + QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg"; + QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg"; + QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg"; + QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg"; + QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg"; + QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg"; + QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg"; +} + void tst_QImage::exifOrientation() { - for (unsigned int i = 1; i <= 8; ++i) { - QImage img; - QRgb px; + QFETCH(QString, fileName); - QVERIFY(img.load(m_prefix + QString::fromLatin1("jpeg_exif_orientation_value_%1.jpg").arg(i))); + QImage img; + QRgb px; - px = img.pixel(0, 0); - QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5); + QVERIFY(img.load(fileName)); - px = img.pixel(img.width() - 1, 0); - QVERIFY(qRed(px) < 5 && qGreen(px) < 5 && qBlue(px) > 250); - } + px = img.pixel(0, 0); + QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5); + + px = img.pixel(img.width() - 1, 0); + QVERIFY(qRed(px) < 5 && qGreen(px) < 5 && qBlue(px) > 250); } static void cleanupFunction(void* info) -- cgit v1.2.3 From c161197b5f749393e462015d0c5fdecad42127b5 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 8 Jan 2015 11:07:48 +0200 Subject: Android: Fix qimage test. We must add all test data to resources. Change-Id: I1b18415cd53a27bd23e51ac6b738d3ed94162ac9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/gui/image/qimage/qimage.pro | 2 ++ tests/auto/gui/image/qimage/qimage.qrc | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/auto/gui/image/qimage/qimage.qrc (limited to 'tests/auto/gui/image/qimage') diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro index 117e34653d..42280d3bd4 100644 --- a/tests/auto/gui/image/qimage/qimage.pro +++ b/tests/auto/gui/image/qimage/qimage.pro @@ -6,4 +6,6 @@ SOURCES += tst_qimage.cpp QT += core-private gui-private testlib contains(QT_CONFIG, c++11): CONFIG += c++11 +android:!android-no-sdk:RESOURCES+=qimage.qrc + TESTDATA += images/* diff --git a/tests/auto/gui/image/qimage/qimage.qrc b/tests/auto/gui/image/qimage/qimage.qrc new file mode 100644 index 0000000000..e5de27faf8 --- /dev/null +++ b/tests/auto/gui/image/qimage/qimage.qrc @@ -0,0 +1,22 @@ + + + images/image.bmp + images/image.gif + images/image.ico + images/image.jpg + images/image.pbm + images/image.pgm + images/image.png + images/image.ppm + images/image.xbm + images/image.xpm + images/jpeg_exif_orientation_value_1.jpg + images/jpeg_exif_orientation_value_2.jpg + images/jpeg_exif_orientation_value_3.jpg + images/jpeg_exif_orientation_value_4.jpg + images/jpeg_exif_orientation_value_5.jpg + images/jpeg_exif_orientation_value_6.jpg + images/jpeg_exif_orientation_value_7.jpg + images/jpeg_exif_orientation_value_8.jpg + + -- cgit v1.2.3