From 1225d9e4aac319cb92ef88ebf7de305033ef30ba Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 13 Dec 2017 15:59:15 +0100 Subject: Make the native darwin image IO work on iOS too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The functions used for converting between QImage and CGImage were not available on iOS. Replace with newer conversions functions which are. Task-number: QTBUG-64722 Change-Id: I3f62d3ccabd103e5b9d4828e8079d94587472872 Reviewed-by: Tor Arne Vestbø --- src/plugins/imageformats/macjp2/qiiofhelpers.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'src') 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(pni->nativeResourceFunctionForIntegration(QByteArrayLiteral("cgImageToQImage"))); - } - if (!q_ptr || !q_ptr->device() || !out || !cgImageToQImageFn) + if (!q_ptr || !q_ptr->device() || !out) return false; QCFType 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(pni->nativeResourceFunctionForIntegration(QByteArrayLiteral("qImageToCGImage"))); - } - if (!q_ptr || !q_ptr->device() || in.isNull() || !qImageToCGImageFn) + if (!q_ptr || !q_ptr->device() || in.isNull()) return false; - QCFType cgImage = qImageToCGImageFn(in); + QCFType cgImage = qt_mac_toCGImage(in); QCFType cgDataConsumer = CGDataConsumerCreate(q_ptr->device(), &cgCallbacks); QCFType cfUti = uti.toCFString(); QCFType cgImageDest = CGImageDestinationCreateWithDataConsumer(cgDataConsumer, cfUti, 1, nullptr); -- cgit v1.2.1