diff --git a/SDWebImage/SDWebImageCoder.h b/SDWebImage/SDWebImageCoder.h index 7e16ad89..7c0a63f2 100644 --- a/SDWebImage/SDWebImageCoder.h +++ b/SDWebImage/SDWebImageCoder.h @@ -33,10 +33,12 @@ CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef); /** This is the image coder protocol to provide custom image decoding/encoding. + These methods are all required to implement. @note Pay attention that these methods are not called from main queue. */ @protocol SDWebImageCoder +@required #pragma mark - Decoding /** Returns YES if this coder can decode some data. Otherwise, the data should be passed to another coder. @@ -90,10 +92,12 @@ CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef); /** This is the image coder protocol to provide custom progressive image decoding. + These methods are all required to implement. @note Pay attention that these methods are not called from main queue. */ @protocol SDWebImageProgressiveCoder +@required /** Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder. diff --git a/SDWebImage/SDWebImageImageIOCoder.m b/SDWebImage/SDWebImageImageIOCoder.m index 56feb046..f04c2561 100644 --- a/SDWebImage/SDWebImageImageIOCoder.m +++ b/SDWebImage/SDWebImageImageIOCoder.m @@ -66,8 +66,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over #pragma mark - Decode - (BOOL)canDecodeFromData:(nullable NSData *)data { switch ([NSData sd_imageFormatForImageData:data]) { - // Do not support WebP decoding case SDImageFormatWebP: + // Do not support WebP decoding return NO; default: return YES; @@ -76,8 +76,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over - (BOOL)canIncrementallyDecodeFromData:(NSData *)data { switch ([NSData sd_imageFormatForImageData:data]) { - // Support static GIF progressive decoding case SDImageFormatWebP: + // Do not support WebP progressive decoding return NO; default: return YES; @@ -394,10 +394,11 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over #pragma mark - Encode - (BOOL)canEncodeToFormat:(SDImageFormat)format { switch (format) { - // Do not support WebP encoding case SDImageFormatWebP: + // Do not support WebP encoding return NO; case SDImageFormatHEIC: + // Check HEIC encoding compatibility return [[self class] canEncodeToHEICFormat]; default: return YES; @@ -482,10 +483,10 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over // Create an image destination. CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL); if (!imageDestination) { - // Can encode to HEIC + // Can't encode to HEIC canEncode = NO; } else { - // Can't encode to HEIF + // Can encode to HEIC CFRelease(imageDestination); canEncode = YES; }