Fix the issue when monochome colorspace cause the WebP encoding failed
Just translate into RGBA first, don't need extra code to re-implements monochrome WebP encoding
This commit is contained in:
parent
db4603921b
commit
304bed2c4b
|
@ -885,6 +885,12 @@ WEBP_CSP_MODE ConvertCSPMode(CGBitmapInfo bitmapInfo) {
|
||||||
uint8_t *rgba = NULL; // RGBA Buffer managed by CFData, don't call `free` on it, instead call `CFRelease` on `dataRef`
|
uint8_t *rgba = NULL; // RGBA Buffer managed by CFData, don't call `free` on it, instead call `CFRelease` on `dataRef`
|
||||||
// We must prefer the input CGImage's color space, which may contains ICC profile
|
// We must prefer the input CGImage's color space, which may contains ICC profile
|
||||||
CGColorSpaceRef colorSpace = CGImageGetColorSpace(imageRef);
|
CGColorSpaceRef colorSpace = CGImageGetColorSpace(imageRef);
|
||||||
|
// We only supports RGB colorspace, filter the un-supported one (like Monochrome, CMYK, etc)
|
||||||
|
if (CGColorSpaceGetModel(colorSpace) != kCGColorSpaceModelRGB) {
|
||||||
|
// Ignore and convert, we don't know how to encode this colorspace directlly to WebP
|
||||||
|
// This may cause little visible difference because of colorpsace conversion
|
||||||
|
colorSpace = NULL;
|
||||||
|
}
|
||||||
if (!colorSpace) {
|
if (!colorSpace) {
|
||||||
colorSpace = [SDImageCoderHelper colorSpaceGetDeviceRGB];
|
colorSpace = [SDImageCoderHelper colorSpaceGetDeviceRGB];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue