Fix the issue when WebP contains the ICC Profile with colorSpace other than RGB, which cause the CGImageCreate failed
This commit is contained in:
parent
4b256c033f
commit
1316f5b340
|
@ -434,6 +434,14 @@
|
||||||
NSData *profileData = [NSData dataWithBytes:chunk_iter.chunk.bytes length:chunk_iter.chunk.size];
|
NSData *profileData = [NSData dataWithBytes:chunk_iter.chunk.bytes length:chunk_iter.chunk.size];
|
||||||
colorSpaceRef = CGColorSpaceCreateWithICCProfile((__bridge CFDataRef)profileData);
|
colorSpaceRef = CGColorSpaceCreateWithICCProfile((__bridge CFDataRef)profileData);
|
||||||
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||||
|
if (colorSpaceRef) {
|
||||||
|
// `CGImageCreate` does not support colorSpace other than RGB (such as Monochrome), we must filter the colorSpace mode
|
||||||
|
CGColorSpaceModel model = CGColorSpaceGetModel(colorSpaceRef);
|
||||||
|
if (model != kCGColorSpaceModelRGB) {
|
||||||
|
CGColorSpaceRelease(colorSpaceRef);
|
||||||
|
colorSpaceRef = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue