Change only ImageIO decoded CGImage should enter the `Force Decode` logic
Others coder, like WebP, should not use this approach
This commit is contained in:
parent
3277824d43
commit
ff6b3b9bb5
|
@ -14,7 +14,24 @@
|
|||
|
||||
- (BOOL)sd_isDecoded {
|
||||
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isDecoded));
|
||||
return value.boolValue;
|
||||
if (value) {
|
||||
return value.boolValue;
|
||||
} else {
|
||||
// Assume only CGImage based can use lazy decoding
|
||||
CGImageRef cgImage = self.CGImage;
|
||||
if (cgImage) {
|
||||
CFStringRef uttype = CGImageGetUTType(self.CGImage);
|
||||
if (uttype) {
|
||||
// Only ImageIO can set `com.apple.ImageIO.imageSourceTypeIdentifier`
|
||||
return NO;
|
||||
} else {
|
||||
// Thumbnail or CGBitmapContext drawn image
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Assume others as non-decoded
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)setSd_isDecoded:(BOOL)sd_isDecoded {
|
||||
|
|
|
@ -166,10 +166,8 @@
|
|||
return imageFormat;
|
||||
}
|
||||
// Check CGImage's UTType, may return nil for non-Image/IO based image
|
||||
if (@available(iOS 9.0, tvOS 9.0, macOS 10.11, watchOS 2.0, *)) {
|
||||
CFStringRef uttype = CGImageGetUTType(self.CGImage);
|
||||
imageFormat = [NSData sd_imageFormatFromUTType:uttype];
|
||||
}
|
||||
CFStringRef uttype = CGImageGetUTType(self.CGImage);
|
||||
imageFormat = [NSData sd_imageFormatFromUTType:uttype];
|
||||
return imageFormat;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue