Fix that `CGImageDestinationCreateWithData` 0 count arg will log a warning, this does not effect the encoding function.

This commit is contained in:
DreamPiggy 2019-05-29 12:37:50 +08:00
parent 124509e9b6
commit e1b4e5a2d4
2 changed files with 4 additions and 2 deletions

View File

@ -193,7 +193,8 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
NSArray<SDImageFrame *> *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; NSArray<SDImageFrame *> *frames = [SDImageCoderHelper framesFromAnimatedImage:image];
// Create an image destination. APNG does not support EXIF image orientation // Create an image destination. APNG does not support EXIF image orientation
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); // The `CGImageDestinationCreateWithData` will log a warning when count is 0, use 1 instead.
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count ?: 1, NULL);
if (!imageDestination) { if (!imageDestination) {
// Handle failure. // Handle failure.
return nil; return nil;

View File

@ -269,7 +269,8 @@
NSArray<SDImageFrame *> *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; NSArray<SDImageFrame *> *frames = [SDImageCoderHelper framesFromAnimatedImage:image];
// Create an image destination. GIF does not support EXIF image orientation // Create an image destination. GIF does not support EXIF image orientation
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); // The `CGImageDestinationCreateWithData` will log a warning when count is 0, use 1 instead.
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count ?: 1, NULL);
if (!imageDestination) { if (!imageDestination) {
// Handle failure. // Handle failure.
return nil; return nil;