wangjwchn / AImage
- суббота, 27 августа 2016 г. в 03:13:48
Swift
A animated GIF&APNG engine for iOS in Swift. Optimized for Multi-Image case.
An animated GIF&APNG engine for iOS in Swift with low memory & cpu usage.
You can use CocoaPods to install AImage
by adding it to your Podfile
:
platform :ios, '8.0'
use_frameworks!
pod 'AImage'
To get the full benefits import AImage
wherever you import UIKit
import UIKit
import AImage
Create a Cartfile
that lists the framework and run carthage bootstrap
. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/AImage.framework
to an iOS project.
github "wangjwchn/AImage"
/AImage
folder in your project./* Load gif or apng image as NSData */
let imageData = NSData(contentsOfURL:NSBundle.mainBundle().URLForResource("test", withExtension: "gif")!)
/* Pass NSData into UIImage */
let image = UIImage(AImageData:imageData!)
/* Pass UIImage into UIImageView */
let imageview = UIImageView(AImage: image)
/* Add view to root view */
imageview.frame = CGRect(x: 7.0, y: 50.0, width: 400.0, height: 224.0)
view.addSubview(imageview)
/* Start displaying animated image */
imageview.APlay();
...
...
...
/* Stop displaying animated image */
iamgeview.AStop();
CPU Usage[average] | Memory Usage[average]/MB | |
---|---|---|
AImage | 6% ~ 14% [8%] | 7.5 ~ 8.4 [8.2] |
FLAnimatedImage | 8% ~ 24% [11%] | 7.3 ~ ??? [???] |
CPU Usage[average] | Memory Usage[average]/MB | |
---|---|---|
AImage | 31% ~ 44% [38%] | 12.4 ~ 13.4 [12.9] |
FLAnimatedImage | 36% ~ 62% [54%] | 11.0 ~ 12.4 [11.3] |
CPU Usage[average] | Memory Usage[average]/MB | |
---|---|---|
AImage | 38% ~ 81% [53%] | 59.3 ~ 82.4 [63.3] |
FLAnimatedImage | 126% ~ 185% [143%] | 58.4 ~ 98.9 [74.2] |
CPU Usage[average] | Memory Usage[average]/MB | |
---|---|---|
AImage (Cache) | 2% ~ 44% [3%] | 43.2 ~ 43.2 [43.2] |
AImage (noCache) | 20% ~ 49% [33%] | 6.6 ~ 8.3 [7.5] |
APNGKit (Cache) | 1% ~ 42% [1%] | 95.6 ~ 95.6 [95.6] |
APNGKit (noCache) | 1% ~ 26% [1%] | 95.9 ~ 95.9 [95.9] |
Measurement Factors:
Last updated: April 26, 2016
Measurement device: iPhone6 with iOS 9.3
Measurement tool: Profile in Xcode 7.3
Measurement image: See it in repository, all the parameters are default.
Raw data are here.
AImage is released under the MIT license. See LICENSE for details.