summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2017-11-13 11:40:25 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2017-11-16 08:25:34 +0000
commita1504e8ecfc683691eb4be1f81b6a6e7920d85ab (patch)
treed5008aa80a9b4d9e402919ec8874b21b1ca0bccd
parentfeca51d8c714781378cecc99122035348e0459bb (diff)
WebP: Fix wrong default quality level for writing
If a negative (i.e. illegal/unset) quality value was set to the WebP handler, it would just bound it to 0 (minimum quality level). This would happen on every save where no explicit quality level had been requested on the QImageWriter. Fix by copying the jpeg handler's behavior: If a negative value is set, use the default level (75) when storing. [ChangeLog][WebP handler] Fixed default quality level for writing Task-number: QTBUG-64437 Change-Id: I0f1cabba6cea6851c6a813bf5bf7ab8e8c49ddfb Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/plugins/imageformats/webp/qwebphandler.cpp8
-rw-r--r--src/plugins/imageformats/webp/qwebphandler_p.h1
2 files changed, 3 insertions, 6 deletions
diff --git a/src/plugins/imageformats/webp/qwebphandler.cpp b/src/plugins/imageformats/webp/qwebphandler.cpp
index 7f7bdd9..c59bc40 100644
--- a/src/plugins/imageformats/webp/qwebphandler.cpp
+++ b/src/plugins/imageformats/webp/qwebphandler.cpp
@@ -48,7 +48,6 @@
static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
QWebpHandler::QWebpHandler() :
- m_lossless(false),
m_quality(75),
m_scanState(ScanNotScanned),
m_features(),
@@ -250,8 +249,8 @@ bool QWebpHandler::write(const QImage &image)
return false;
}
- config.lossless = m_lossless;
- config.quality = m_quality;
+ config.quality = m_quality < 0 ? 75 : qMin(m_quality, 100);
+ config.lossless = (config.quality >= 100);
picture.writer = pictureWriter;
picture.custom_ptr = device();
@@ -289,8 +288,7 @@ void QWebpHandler::setOption(ImageOption option, const QVariant &value)
{
switch (option) {
case Quality:
- m_quality = qBound(0, value.toInt(), 100);
- m_lossless = (m_quality >= 100);
+ m_quality = value.toInt();
return;
default:
break;
diff --git a/src/plugins/imageformats/webp/qwebphandler_p.h b/src/plugins/imageformats/webp/qwebphandler_p.h
index 99a7c21..950b501 100644
--- a/src/plugins/imageformats/webp/qwebphandler_p.h
+++ b/src/plugins/imageformats/webp/qwebphandler_p.h
@@ -85,7 +85,6 @@ private:
ScanSuccess = 1,
};
- bool m_lossless;
int m_quality;
mutable ScanState m_scanState;
WebPBitstreamFeatures m_features;