From 1903ac20f3d1af80e16f2a89d5ea9624fc9fecbd Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 1 Feb 2021 21:34:51 +0800 Subject: [PATCH] Fix again for CMYK image --- SDWebImageWebPCoder/Classes/SDImageWebPCoder.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index 4f99aa7..9aec9ff 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -786,7 +786,8 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio .bitsPerComponent = (uint32_t)bitsPerComponent, .bitsPerPixel = (uint32_t)bitsPerPixel, .colorSpace = colorSpace, - .bitmapInfo = bitmapInfo + .bitmapInfo = bitmapInfo, + .renderingIntent = CGImageGetRenderingIntent(imageRef) }; vImage_CGImageFormat destFormat = { .bitsPerComponent = 8, @@ -801,14 +802,15 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio return nil; } - vImage_Buffer src = { - .data = (uint8_t *)CFDataGetBytePtr(dataRef), - .width = width, - .height = height, - .rowBytes = bytesPerRow - }; - vImage_Buffer dest; + vImage_Buffer src; + error = vImageBuffer_InitWithCGImage(&src, &srcFormat, nil, imageRef, kvImageNoFlags); + if (error != kvImageNoError) { + vImageConverter_Release(convertor); + CFRelease(dataRef); + return nil; + } + vImage_Buffer dest; error = vImageBuffer_Init(&dest, height, width, destFormat.bitsPerPixel, kvImageNoFlags); if (error != kvImageNoError) { vImageConverter_Release(convertor);