This commit is contained in:
zhongwuzw 2019-01-22 16:04:12 +08:00
parent 5b1ad45889
commit c3b0f64017
1 changed files with 10 additions and 15 deletions

View File

@ -89,14 +89,7 @@
return nil;
}
CGColorSpaceRef colorSpace = NULL;
// ICC profile
if (flags & ICCP_FLAG) {
colorSpace = [self sd_colorSpaceWithDemuxer:demuxer];
} else {
colorSpace = SDCGColorSpaceGetDeviceRGB();
CGColorSpaceRetain(colorSpace);
}
CGColorSpaceRef colorSpace = [self sd_colorSpaceWithDemuxer:demuxer];
if (!(flags & ANIMATION_FLAG)) {
// for static single webp image
@ -347,16 +340,18 @@
// WebP contains ICC Profile should use the desired colorspace, instead of default device colorspace
// See: https://developers.google.com/speed/webp/docs/riff_container#color_profile
WebPChunkIterator chunk_iter;
CGColorSpaceRef colorSpaceRef = NULL;
uint32_t flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS);
if (flags & ICCP_FLAG) {
WebPChunkIterator chunk_iter;
int result = WebPDemuxGetChunk(demuxer, "ICCP", 1, &chunk_iter);
if (result) {
NSData *profileData = [NSData dataWithBytesNoCopy:(void *)chunk_iter.chunk.bytes length:chunk_iter.chunk.size freeWhenDone:NO];
colorSpaceRef = CGColorSpaceCreateWithICCProfile((__bridge CFDataRef)profileData);
}
WebPDemuxReleaseChunkIterator(&chunk_iter);
}
}
if (!colorSpaceRef) {
colorSpaceRef = SDCGColorSpaceGetDeviceRGB();