diff options
Diffstat (limited to 'src/plugins/imageformats')
-rw-r--r-- | src/plugins/imageformats/macjp2/qiiofhelpers.cpp | 24 | ||||
-rw-r--r-- | src/plugins/imageformats/webp/qwebphandler.cpp | 8 | ||||
-rw-r--r-- | src/plugins/imageformats/webp/qwebphandler_p.h | 1 |
3 files changed, 10 insertions, 23 deletions
diff --git a/src/plugins/imageformats/macjp2/qiiofhelpers.cpp b/src/plugins/imageformats/macjp2/qiiofhelpers.cpp index c894932..1b8ee11 100644 --- a/src/plugins/imageformats/macjp2/qiiofhelpers.cpp +++ b/src/plugins/imageformats/macjp2/qiiofhelpers.cpp @@ -94,20 +94,15 @@ static size_t cbPutBytes(void *info, const void *buffer, size_t count) } -// QImage <-> CGImage conversion functions -typedef QImage (*cgImageToQImagePtr)(CGImageRef image); -typedef CGImageRef (*qImageToCGImagePtr)(const QImage &image); +// QImage <-> CGImage conversion functions from QtGui on darwin +CGImageRef qt_mac_toCGImage(const QImage &qImage); +QImage qt_mac_toQImage(CGImageRef image); bool QIIOFHelpers::readImage(QImageIOHandler *q_ptr, QImage *out) { static const CGDataProviderSequentialCallbacks cgCallbacks = { 0, &cbGetBytes, &cbSkipForward, &cbRewind, nullptr }; - static cgImageToQImagePtr cgImageToQImageFn = nullptr; - if (!cgImageToQImageFn) { - if (QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface()) - cgImageToQImageFn = reinterpret_cast<cgImageToQImagePtr>(pni->nativeResourceFunctionForIntegration(QByteArrayLiteral("cgImageToQImage"))); - } - if (!q_ptr || !q_ptr->device() || !out || !cgImageToQImageFn) + if (!q_ptr || !q_ptr->device() || !out) return false; QCFType<CGDataProviderRef> cgDataProvider; @@ -127,7 +122,7 @@ bool QIIOFHelpers::readImage(QImageIOHandler *q_ptr, QImage *out) if (!cgImage) return false; - *out = cgImageToQImageFn(cgImage); + *out = qt_mac_toQImage(cgImage); return !out->isNull(); } @@ -135,16 +130,11 @@ bool QIIOFHelpers::readImage(QImageIOHandler *q_ptr, QImage *out) bool QIIOFHelpers::writeImage(QImageIOHandler *q_ptr, const QImage &in, const QString &uti) { static const CGDataConsumerCallbacks cgCallbacks = { &cbPutBytes, nullptr }; - static qImageToCGImagePtr qImageToCGImageFn = nullptr; - if (!qImageToCGImageFn) { - if (QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface()) - qImageToCGImageFn = reinterpret_cast<qImageToCGImagePtr>(pni->nativeResourceFunctionForIntegration(QByteArrayLiteral("qImageToCGImage"))); - } - if (!q_ptr || !q_ptr->device() || in.isNull() || !qImageToCGImageFn) + if (!q_ptr || !q_ptr->device() || in.isNull()) return false; - QCFType<CGImageRef> cgImage = qImageToCGImageFn(in); + QCFType<CGImageRef> cgImage = qt_mac_toCGImage(in); QCFType<CGDataConsumerRef> cgDataConsumer = CGDataConsumerCreate(q_ptr->device(), &cgCallbacks); QCFType<CFStringRef> cfUti = uti.toCFString(); QCFType<CGImageDestinationRef> cgImageDest = CGImageDestinationCreateWithDataConsumer(cgDataConsumer, cfUti, 1, nullptr); diff --git a/src/plugins/imageformats/webp/qwebphandler.cpp b/src/plugins/imageformats/webp/qwebphandler.cpp index 7bea4d0..3a7bf43 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; |