File tree 1 file changed +9
-5
lines changed
SDWebImageWebPCoder/Classes 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -422,13 +422,17 @@ - (nonnull CGColorSpaceRef)sd_colorSpaceWithDemuxer:(nonnull WebPDemuxer *)demux
422
422
// WebP contains ICC Profile should use the desired colorspace, instead of default device colorspace
423
423
// See: https://developers.google.com/speed/webp/docs/riff_container#color_profile
424
424
425
- WebPChunkIterator chunk_iter;
426
425
CGColorSpaceRef colorSpaceRef = NULL ;
426
+ uint32_t flags = WebPDemuxGetI (demuxer, WEBP_FF_FORMAT_FLAGS);
427
427
428
- int result = WebPDemuxGetChunk (demuxer, " ICCP" , 1 , &chunk_iter);
429
- if (result) {
430
- NSData *profileData = [NSData dataWithBytes: chunk_iter.chunk.bytes length: chunk_iter.chunk.size];
431
- colorSpaceRef = CGColorSpaceCreateWithICCProfile ((__bridge CFDataRef )profileData);
428
+ if (flags & ICCP_FLAG) {
429
+ WebPChunkIterator chunk_iter;
430
+ int result = WebPDemuxGetChunk (demuxer, " ICCP" , 1 , &chunk_iter);
431
+ if (result) {
432
+ NSData *profileData = [NSData dataWithBytesNoCopy: (void *)chunk_iter.chunk.bytes length: chunk_iter.chunk.size freeWhenDone: NO ];
433
+ colorSpaceRef = CGColorSpaceCreateWithICCProfile ((__bridge CFDataRef )profileData);
434
+ WebPDemuxReleaseChunkIterator (&chunk_iter);
435
+ }
432
436
}
433
437
434
438
if (!colorSpaceRef) {
You can’t perform that action at this time.
0 commit comments