From eb5ef3312260479ada82e6463e7ec3a8b6245e7f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 7 Aug 2014 13:47:21 +0200 Subject: [PATCH] Handle 10-bit per color formats in qt_mac_toCGImage Add support for the four new RGB30 formats to qt_mac_toCGImage so that they get converted to ARGB32_Premultiplied instead of potentially misinterpreted. Change-Id: I0921edaef7509c1db9bd547b454dade03d289ea3 Reviewed-by: Gunnar Sletta --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index e3916ea787..894c2c1168 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -97,13 +97,10 @@ CGImageRef qt_mac_toCGImage(const QImage &inImage) if (inImage.isNull()) return 0; - QImage image = (inImage.depth() == 32) ? inImage : inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QImage image = inImage; uint cgflags = kCGImageAlphaNone; switch (image.format()) { - case QImage::Format_ARGB32_Premultiplied: - cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; - break; case QImage::Format_ARGB32: cgflags = kCGImageAlphaFirst | kCGBitmapByteOrder32Host; break; @@ -123,7 +120,11 @@ CGImageRef qt_mac_toCGImage(const QImage &inImage) cgflags = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big; break; default: - Q_ASSERT(false); // Should never be reached. + // Everything not recognized explicitly is converted to ARGB32_Premultiplied. + image = inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); + // no break; + case QImage::Format_ARGB32_Premultiplied: + cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; break; }