Add some more comments about coder method
This commit is contained in:
parent
ae67c97320
commit
decb5dcdeb
|
@ -33,10 +33,12 @@ CG_EXTERN BOOL SDCGImageRefContainsAlpha(_Nullable CGImageRef imageRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the image coder protocol to provide custom image decoding/encoding.
|
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.
|
@note Pay attention that these methods are not called from main queue.
|
||||||
*/
|
*/
|
||||||
@protocol SDWebImageCoder <NSObject>
|
@protocol SDWebImageCoder <NSObject>
|
||||||
|
|
||||||
|
@required
|
||||||
#pragma mark - Decoding
|
#pragma mark - Decoding
|
||||||
/**
|
/**
|
||||||
Returns YES if this coder can decode some data. Otherwise, the data should be passed to another coder.
|
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.
|
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.
|
@note Pay attention that these methods are not called from main queue.
|
||||||
*/
|
*/
|
||||||
@protocol SDWebImageProgressiveCoder <SDWebImageCoder>
|
@protocol SDWebImageProgressiveCoder <SDWebImageCoder>
|
||||||
|
|
||||||
|
@required
|
||||||
/**
|
/**
|
||||||
Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder.
|
Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder.
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
#pragma mark - Decode
|
#pragma mark - Decode
|
||||||
- (BOOL)canDecodeFromData:(nullable NSData *)data {
|
- (BOOL)canDecodeFromData:(nullable NSData *)data {
|
||||||
switch ([NSData sd_imageFormatForImageData:data]) {
|
switch ([NSData sd_imageFormatForImageData:data]) {
|
||||||
// Do not support WebP decoding
|
|
||||||
case SDImageFormatWebP:
|
case SDImageFormatWebP:
|
||||||
|
// Do not support WebP decoding
|
||||||
return NO;
|
return NO;
|
||||||
default:
|
default:
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -76,8 +76,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
|
|
||||||
- (BOOL)canIncrementallyDecodeFromData:(NSData *)data {
|
- (BOOL)canIncrementallyDecodeFromData:(NSData *)data {
|
||||||
switch ([NSData sd_imageFormatForImageData:data]) {
|
switch ([NSData sd_imageFormatForImageData:data]) {
|
||||||
// Support static GIF progressive decoding
|
|
||||||
case SDImageFormatWebP:
|
case SDImageFormatWebP:
|
||||||
|
// Do not support WebP progressive decoding
|
||||||
return NO;
|
return NO;
|
||||||
default:
|
default:
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -394,10 +394,11 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
#pragma mark - Encode
|
#pragma mark - Encode
|
||||||
- (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
- (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
// Do not support WebP encoding
|
|
||||||
case SDImageFormatWebP:
|
case SDImageFormatWebP:
|
||||||
|
// Do not support WebP encoding
|
||||||
return NO;
|
return NO;
|
||||||
case SDImageFormatHEIC:
|
case SDImageFormatHEIC:
|
||||||
|
// Check HEIC encoding compatibility
|
||||||
return [[self class] canEncodeToHEICFormat];
|
return [[self class] canEncodeToHEICFormat];
|
||||||
default:
|
default:
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -482,10 +483,10 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
// Create an image destination.
|
// Create an image destination.
|
||||||
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
|
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
|
||||||
if (!imageDestination) {
|
if (!imageDestination) {
|
||||||
// Can encode to HEIC
|
// Can't encode to HEIC
|
||||||
canEncode = NO;
|
canEncode = NO;
|
||||||
} else {
|
} else {
|
||||||
// Can't encode to HEIF
|
// Can encode to HEIC
|
||||||
CFRelease(imageDestination);
|
CFRelease(imageDestination);
|
||||||
canEncode = YES;
|
canEncode = YES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue