Keep the rendering intent information from CGImage as well

This commit is contained in:
DreamPiggy 2023-11-08 17:47:07 +08:00
parent 8113caf1b7
commit daa8373449
1 changed files with 3 additions and 1 deletions

View File

@ -888,11 +888,13 @@ WEBP_CSP_MODE ConvertCSPMode(CGBitmapInfo bitmapInfo) {
if (!colorSpace) { if (!colorSpace) {
colorSpace = [SDImageCoderHelper colorSpaceGetDeviceRGB]; colorSpace = [SDImageCoderHelper colorSpaceGetDeviceRGB];
} }
CGColorRenderingIntent renderingIntent = CGImageGetRenderingIntent(imageRef);
vImage_CGImageFormat destFormat = { vImage_CGImageFormat destFormat = {
.bitsPerComponent = 8, .bitsPerComponent = 8,
.bitsPerPixel = hasAlpha ? 32 : 24, .bitsPerPixel = hasAlpha ? 32 : 24,
.colorSpace = colorSpace, .colorSpace = colorSpace,
.bitmapInfo = hasAlpha ? kCGImageAlphaLast | kCGBitmapByteOrderDefault : kCGImageAlphaNone | kCGBitmapByteOrderDefault // RGB888/RGBA8888 (Non-premultiplied to works for libwebp) .bitmapInfo = hasAlpha ? kCGImageAlphaLast | kCGBitmapByteOrderDefault : kCGImageAlphaNone | kCGBitmapByteOrderDefault, // RGB888/RGBA8888 (Non-premultiplied to works for libwebp)
.renderingIntent = renderingIntent
}; };
vImage_Buffer dest; vImage_Buffer dest;
// We could not assume that input CGImage's color mode is always RGB888/RGBA8888. Convert all other cases to target color mode using vImage // We could not assume that input CGImage's color mode is always RGB888/RGBA8888. Convert all other cases to target color mode using vImage