This repository has been archived by the owner on May 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DFCompositeImageDecoder, DFAnimatedImageDecoder, DFWebPImageDecoder
- Loading branch information
Showing
13 changed files
with
135 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015 Alexander Grebenyuk (github.com/kean). | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "DFImageDecoding.h" | ||
|
||
@interface DFAnimatedImageDecoder : NSObject <DFImageDecoding> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015 Alexander Grebenyuk (github.com/kean). | ||
|
||
#import "DFAnimatedImageDecoder.h" | ||
#import "DFAnimatedImage.h" | ||
|
||
@implementation DFAnimatedImageDecoder | ||
|
||
- (UIImage *)imageWithData:(NSData *)data partial:(BOOL)partial { | ||
if (![self _isGIFData:data]) { | ||
return nil; | ||
} | ||
FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:data]; | ||
if (!animatedImage) { | ||
return nil; | ||
} | ||
UIImage *posterImage = animatedImage.posterImage; | ||
CGImageRef posterImageRef = posterImage.CGImage; | ||
if (!posterImageRef) { | ||
return nil; | ||
} | ||
return [[DFAnimatedImage alloc] initWithAnimatedImage:animatedImage posterImage:posterImageRef posterImageScale:posterImage.scale posterImageOrientation:posterImage.imageOrientation]; | ||
} | ||
|
||
/*! See https://en.wikipedia.org/wiki/List_of_file_signatures | ||
*/ | ||
- (BOOL)_isGIFData:(NSData *)data { | ||
const NSInteger sigLength = 3; | ||
if (data.length < sigLength) { | ||
return NO; | ||
} | ||
uint8_t sig[sigLength]; | ||
[data getBytes:&sig length:sigLength]; | ||
return sig[0] == 0x47 && sig[1] == 0x49 && sig[2] == 0x46; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015 Alexander Grebenyuk (github.com/kean). | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "DFImageDecoding.h" | ||
|
||
@interface DFWebPImageDecoder : NSObject <DFImageDecoding> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.