Fix the issue of `CGImageCreateScaled`, which should use BGRX8888 on non-alpha image, BGRA8888 on alpha image
This commit is contained in:
parent
01b23e448c
commit
7e3482d4fc
|
@ -293,12 +293,15 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
if (input_buffer.data) free(input_buffer.data);
|
if (input_buffer.data) free(input_buffer.data);
|
||||||
if (output_buffer.data) free(output_buffer.data);
|
if (output_buffer.data) free(output_buffer.data);
|
||||||
};
|
};
|
||||||
|
BOOL hasAlpha = [self CGImageContainsAlpha:cgImage];
|
||||||
|
// iOS display alpha info (BGRA8888/BGRX8888)
|
||||||
|
CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host;
|
||||||
|
bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst;
|
||||||
vImage_CGImageFormat format = (vImage_CGImageFormat) {
|
vImage_CGImageFormat format = (vImage_CGImageFormat) {
|
||||||
.bitsPerComponent = 8,
|
.bitsPerComponent = 8,
|
||||||
.bitsPerPixel = 32,
|
.bitsPerPixel = 32,
|
||||||
.colorSpace = NULL,
|
.colorSpace = NULL,
|
||||||
.bitmapInfo = kCGImageAlphaFirst | kCGBitmapByteOrderDefault,
|
.bitmapInfo = bitmapInfo,
|
||||||
.version = 0,
|
.version = 0,
|
||||||
.decode = NULL,
|
.decode = NULL,
|
||||||
.renderingIntent = kCGRenderingIntentDefault,
|
.renderingIntent = kCGRenderingIntentDefault,
|
||||||
|
|
|
@ -606,7 +606,7 @@ static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull
|
||||||
.bitsPerComponent = 8,
|
.bitsPerComponent = 8,
|
||||||
.bitsPerPixel = 32,
|
.bitsPerPixel = 32,
|
||||||
.colorSpace = NULL,
|
.colorSpace = NULL,
|
||||||
.bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little, //requests a BGRA buffer.
|
.bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, //requests a BGRA buffer.
|
||||||
.version = 0,
|
.version = 0,
|
||||||
.decode = NULL,
|
.decode = NULL,
|
||||||
.renderingIntent = kCGRenderingIntentDefault
|
.renderingIntent = kCGRenderingIntentDefault
|
||||||
|
|
Loading…
Reference in New Issue