Set CGImage format when converting from QImage.
Set the CGImage format based on QImage::format(). Handle8-bit per component (A)RGB. Change-Id: I041b0ee53d3943a0aaf9e813eb0a235c4de619dd Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
parent
2e14214357
commit
13fcd1c342
@ -804,13 +804,34 @@ CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy)
|
||||
if (!cgColourSpaceRef)
|
||||
cgColourSpaceRef = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
|
||||
// Create a CGBitmapInfo contiaining the image format.
|
||||
// Support the 8-bit per component (A)RGB formats.
|
||||
CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little;
|
||||
switch (qImage.format()) {
|
||||
case QImage::Format_ARGB32_Premultiplied :
|
||||
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
|
||||
break;
|
||||
case QImage::Format_ARGB32 :
|
||||
bitmapInfo |= kCGImageAlphaFirst;
|
||||
break;
|
||||
case QImage::Format_RGB32 :
|
||||
bitmapInfo |= kCGImageAlphaNoneSkipFirst;
|
||||
break;
|
||||
case QImage::Format_RGB888 :
|
||||
bitmapInfo |= kCGImageAlphaNone;
|
||||
break;
|
||||
default:
|
||||
qWarning() << "qt_mac_toCGImage: Unsupported image format" << qImage.format();
|
||||
break;
|
||||
}
|
||||
|
||||
cgImage = CGImageCreate(width,
|
||||
height,
|
||||
colorBufferSize,
|
||||
bitDepth,
|
||||
bytesPrLine,
|
||||
cgColourSpaceRef,
|
||||
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
|
||||
bitmapInfo,
|
||||
cgDataProviderRef,
|
||||
NULL,
|
||||
false,
|
||||
|
Loading…
Reference in New Issue
Block a user