summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2014-05-29 10:58:33 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-04 15:10:37 +0200
commit1c66c5786c35a7d841e0004757cff06da3f9a2cc (patch)
tree2769dc9c221f35b2c562552db6bcd92ffc482134
parentbcc7909dfe9d89f793919bc96abdfd6b704c4c0e (diff)
Make QWebpHandler::write() work on big endian systemsv5.3.1stable
Currently, we convert image to Format_ARGB32. This means that on big endian systems the order of bytes will be (0xAA, 0xRR, 0xGG, 0xBB). However, in WebP library there is no function to import bytes in ARGB format. This commit makes us use Format_RGBA8888 and WebPPictureImportRGBA on big endian systems, which will make the function work correctly. Change-Id: I5f347f3ec66f0a57df0d40d4900b1573f9400506 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: aavit <eirik.aavitsland@digia.com>
-rw-r--r--src/plugins/imageformats/webp/qwebphandler.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/imageformats/webp/qwebphandler.cpp b/src/plugins/imageformats/webp/qwebphandler.cpp
index 8834820..599cb00 100644
--- a/src/plugins/imageformats/webp/qwebphandler.cpp
+++ b/src/plugins/imageformats/webp/qwebphandler.cpp
@@ -137,8 +137,13 @@ bool QWebpHandler::write(const QImage &image)
}
QImage srcImage = image;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
if (srcImage.format() != QImage::Format_ARGB32)
srcImage = srcImage.convertToFormat(QImage::Format_ARGB32);
+#else /* Q_BIG_ENDIAN */
+ if (srcImage.format() != QImage::Format_RGBA8888)
+ srcImage = srcImage.convertToFormat(QImage::Format_RGBA8888);
+#endif
WebPPicture picture;
WebPConfig config;
@@ -151,7 +156,11 @@ bool QWebpHandler::write(const QImage &image)
picture.width = srcImage.width();
picture.height = srcImage.height();
picture.use_argb = 1;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
if (!WebPPictureImportBGRA(&picture, srcImage.bits(), srcImage.bytesPerLine())) {
+#else /* Q_BIG_ENDIAN */
+ if (!WebPPictureImportRGBA(&picture, srcImage.bits(), srcImage.bytesPerLine())) {
+#endif
qWarning() << "failed to import image data to webp picture.";
WebPPictureFree(&picture);