Fix again for CMYK image

This commit is contained in:
DreamPiggy 2021-02-01 21:34:51 +08:00
parent 777065d638
commit 1903ac20f3
1 changed files with 10 additions and 8 deletions

View File

@ -786,7 +786,8 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio
.bitsPerComponent = (uint32_t)bitsPerComponent, .bitsPerComponent = (uint32_t)bitsPerComponent,
.bitsPerPixel = (uint32_t)bitsPerPixel, .bitsPerPixel = (uint32_t)bitsPerPixel,
.colorSpace = colorSpace, .colorSpace = colorSpace,
.bitmapInfo = bitmapInfo .bitmapInfo = bitmapInfo,
.renderingIntent = CGImageGetRenderingIntent(imageRef)
}; };
vImage_CGImageFormat destFormat = { vImage_CGImageFormat destFormat = {
.bitsPerComponent = 8, .bitsPerComponent = 8,
@ -801,14 +802,15 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio
return nil; return nil;
} }
vImage_Buffer src = { vImage_Buffer src;
.data = (uint8_t *)CFDataGetBytePtr(dataRef), error = vImageBuffer_InitWithCGImage(&src, &srcFormat, nil, imageRef, kvImageNoFlags);
.width = width, if (error != kvImageNoError) {
.height = height, vImageConverter_Release(convertor);
.rowBytes = bytesPerRow CFRelease(dataRef);
}; return nil;
vImage_Buffer dest; }
vImage_Buffer dest;
error = vImageBuffer_Init(&dest, height, width, destFormat.bitsPerPixel, kvImageNoFlags); error = vImageBuffer_Init(&dest, height, width, destFormat.bitsPerPixel, kvImageNoFlags);
if (error != kvImageNoError) { if (error != kvImageNoError) {
vImageConverter_Release(convertor); vImageConverter_Release(convertor);