...
|
...
|
@@ -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,9 +394,12 @@ 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;
|
|
|
}
|
...
|
...
|
@@ -469,6 +472,28 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over |
|
|
return YES;
|
|
|
}
|
|
|
|
|
|
+ (BOOL)canEncodeToHEICFormat
|
|
|
{
|
|
|
static BOOL canEncode = NO;
|
|
|
static dispatch_once_t onceToken;
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
NSMutableData *imageData = [NSMutableData data];
|
|
|
CFStringRef imageUTType = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatHEIC];
|
|
|
|
|
|
// Create an image destination.
|
|
|
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
|
|
|
if (!imageDestination) {
|
|
|
// Can't encode to HEIC
|
|
|
canEncode = NO;
|
|
|
} else {
|
|
|
// Can encode to HEIC
|
|
|
CFRelease(imageDestination);
|
|
|
canEncode = YES;
|
|
|
}
|
|
|
});
|
|
|
return canEncode;
|
|
|
}
|
|
|
|
|
|
#if SD_UIKIT || SD_WATCH
|
|
|
#pragma mark EXIF orientation tag converter
|
|
|
+ (UIImageOrientation)sd_imageOrientationFromImageData:(nonnull NSData *)imageData {
|
...
|
...
|
|