diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2017-12-13 15:59:15 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-12-14 13:52:59 +0000 |
commit | 1225d9e4aac319cb92ef88ebf7de305033ef30ba (patch) | |
tree | 5b67429c7efbb3c751491259b1e4af5495e88143 | |
parent | 4a5d500d6da8c7af2d3abfcf759586d5756efa77 (diff) | |
download | qtimageformats-1225d9e4aac319cb92ef88ebf7de305033ef30ba.tar.gz |
Make the native darwin image IO work on iOS too
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ø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/plugins/imageformats/macjp2/qiiofhelpers.cpp | 24 |
1 files changed, 7 insertions, 17 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); |