From daa837344940c472b96f19abd3f6c4d8cbfe24bf Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 8 Nov 2023 17:47:07 +0800 Subject: [PATCH] Keep the rendering intent information from CGImage as well --- SDWebImageWebPCoder/Classes/SDImageWebPCoder.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index 31acd23..a9ee149 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -888,11 +888,13 @@ WEBP_CSP_MODE ConvertCSPMode(CGBitmapInfo bitmapInfo) { if (!colorSpace) { colorSpace = [SDImageCoderHelper colorSpaceGetDeviceRGB]; } + CGColorRenderingIntent renderingIntent = CGImageGetRenderingIntent(imageRef); vImage_CGImageFormat destFormat = { .bitsPerComponent = 8, .bitsPerPixel = hasAlpha ? 32 : 24, .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; // We could not assume that input CGImage's color mode is always RGB888/RGBA8888. Convert all other cases to target color mode using vImage