Git Product home page Git Product logo

aimage's Introduction

Cover

Language Build Status CocoaPods Compatible Carthage compatible Pod License

An animated gif & apng engine for iOS in Swift with low memory & cpu usage.

video

##Features

  • Small but complete,only 250 lines of code.
  • As UIImage and UIImageView extension,easy to use.
  • Allow to control display quality, memory usage and display progress.
  • Optimized for multi-image case.
  • Have a great performance on memory and cpu usage.Using asynchronous image decoding to reduce the main thread CPU usage.

Installation

CocoaPods

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

Carthage

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"

Manually

  1. Download and drop /AImagefolder in your project.
  2. Congratulations!

Usage

/* 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();

Principles

##Benchmark ###Display GIF:Compared with FLAnimatedImage #####1.Display 1 Image

CPU Usage[average] Memory Usage[average]/MB
AImage 6% ~ 14% [8%] 7.5 ~ 8.4 [8.2]
FLAnimatedImage 8% ~ 24% [11%] 7.3 ~ ??? [???]

#####2.Display 3 Images

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]

#####3.Display 30 Images

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]

###Display APNG:Compared with APNGKit

#####1.Display 1 Image

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:

  • Measurement time: 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.

##Licence AImage is released under the MIT license. See LICENSE for details.

aimage's People

Contributors

kirualex avatar lfarah avatar wangjwchn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.