OSDN Git Service

QImageIOHandler::Quality is documented as image writing only property
authorIvailo Monev <xakepa10@gmail.com>
Sun, 27 Feb 2022 18:53:57 +0000 (20:53 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 27 Feb 2022 18:53:57 +0000 (20:53 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qimagereader.cpp
src/gui/image/qimagereader.h
src/gui/image/qimagewriter.cpp

index 99ebf00..51aeaa1 100644 (file)
@@ -506,45 +506,6 @@ QString QImageReader::fileName() const
 }
 
 /*!
-    \since 4.2
-
-    This is an image format specific function that sets the quality
-    level of the image to \a quality. For image formats that do not
-    support setting the quality, this value is ignored.
-
-    The value range of \a quality should be between 0 and 100.
-
-    \sa quality()
-*/
-void QImageReader::setQuality(int quality)
-{
-    if (!d->initHandler())
-        return;
-    if (Q_UNLIKELY(quality < 0 || quality > 100)) {
-        qWarning("QImageReader::setQuality: invalid quality value %d", quality);
-        quality = 100;
-    }
-    if (d->handler->supportsOption(QImageIOHandler::Quality))
-        d->handler->setOption(QImageIOHandler::Quality, quality);
-}
-
-/*!
-    \since 4.2
-
-    Returns the quality level of the image. Default value is 100.
-
-    \sa setQuality()
-*/
-int QImageReader::quality() const
-{
-    if (!d->initHandler())
-        return 100;
-    if (d->handler->supportsOption(QImageIOHandler::Quality))
-        return d->handler->option(QImageIOHandler::Quality).toInt();
-    return 100;
-}
-
-/*!
     Returns the size of the image, without actually reading the image
     contents.
 
index 9f80c15..63eda24 100644 (file)
@@ -69,9 +69,6 @@ public:
     void setScaledSize(const QSize &size);
     QSize scaledSize() const;
 
-    void setQuality(int quality);
-    int quality() const;
-
     void setBackgroundColor(const QColor &color);
     QColor backgroundColor() const;
 
index 8dafb34..800ec58 100644 (file)
@@ -317,7 +317,12 @@ QString QImageWriter::fileName() const
 */
 void QImageWriter::setQuality(int quality)
 {
-    d->quality = quality;
+    if (Q_UNLIKELY(quality < 0 || quality > 100)) {
+        qWarning("QImageWriter::setQuality: invalid quality value %d", quality);
+        quality = 100;
+    } else {
+        d->quality = quality;
+    }
 }
 
 /*!