Git Product home page Git Product logo

aimage's Introduction

Cover

Language Pod License

Features

  • Small but complete, only200lines of code.
  • Allow to control display quality, memory usage, loop time and display progress.
  • Have a great performance on memory and cpu usage.
  • Using asynchronous image decoding to reduce the main thread CPU usage.

Usage

/* Create AImage with URL */
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)

/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))

/* Add AImage to AImageView */
imageview.add(image: image!)

/* Start displaying animated image */
imageview.play = true

...
...

/* Stop displaying animated image */
imageview.play = false

Benchmark

Compared with Gifu and Apple's example code.

Test1: Display view.gif

Library CPU Memory
Apple's Example Code
Gifu
AImage

Test2: Display earth.gif

Library CPU Memory
Apple's Example Code
Gifu
AImage

Measurement Factors:

  • Measurement time: August 24, 2017

  • Measurement device: iPhone6, iOS 11.0(15A5362a)

Principles

Old Version

Version of swift 2.3 can be found in here.

Licence

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

aimage's People

Contributors

alexiscreuzot avatar arkdan avatar jackcolley avatar jaumevn avatar lfarah avatar proxpero avatar wangjwchn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aimage's Issues

Unable to bridge NSNumber to Float

I have know idea what I'm doing wrong but it's crashing since swift 4.1
` }

    let frameDelays: [Float] = frameProperties.map() {
        var delayObject: AnyObject = unsafeBitCast(CFDictionaryGetValue($0, Unmanaged.passUnretained(kCGImagePropertyGIFUnclampedDelayTime).toOpaque()), to: AnyObject.self)
        if (delayObject.floatValue == 0.0){
            delayObject = unsafeBitCast(CFDictionaryGetValue($0, Unmanaged.passUnretained(kCGImagePropertyGIFDelayTime).toOpaque()), to: AnyObject.self)
        }
        return delayObject as! Float   // <-- error occurs here
    }
    return frameDelays
}`

IOS 10 EXC_BAD_ACCESS

Have setted all parameter as Readme File specified, in the moment of excecution at line 61 AImage.swift file occurs EXC_BAD_ACCESS trying check CFDictionaryContainsKey(imageProperties[1],unsafeAddressOf("{GIF}"))

Crash on Swift 4.1

Hi.
There was no problem with Swift 4.0 but on Swift 4.1 on timerFired() func there is a crash on this line:

    `let nextAt = ((self.indexAt)+1)%(self.aImage!.displayIndex.count)`

and it says:
Fatal error: Remainder of division by zero

Compile error

Multiple commands produce '/Users/zss/Library/Developer/Xcode/DerivedData/GifTest-bpfttbarcugddsfbqavvzsqcrckt/Build/Products/Debug-iphonesimulator/AImage/AImage.framework/Info.plist'

Framerate increasing in a reuse context

When using GIFs on a UICollectionView cell that is reused, the framerate does increase exponentially. A great addition would be to set a maximum framerate.

_cacheKey` is nil...

fatal error: unexpectedly found nil while unwrapping an Optional value

JWAnimatedImageView.Swift Line 74 -> _cacheKey is nil...

iOS10?

Not really a code issue, really a documentation/README issue. Your README says this code hasn't been updated since April 2016 but of course it has. Also, FLAnimatedImage has had issues (or reported issues) with iOS 10. Have you tested with iOS10 yet? if you would just update the README you can then delete or close this issue.

Thanks for creating this repository!

Comparison to FLAnimatedImage

Hey @wangjwchn, thanks for open sourcing this! I was using FLAnimatedImage in a project several weeks ago and had to abandon GIF support because of the memory issues. Although in Xcode it would show never ending memory growth, I wasn't experiencing an actual memory leak, it was just that the caching system they had implemented was poor and was causing really high transient counts in Instruments.

I would love to run some tests and compare JWAnimatedImage's transient counts to FLAnimatedImage's.

gif speed getting faster

i did set imageView on collectionViewCell and i have data.
so there is serveral cells.
i played gif more and more.
gif spped getting faster.

Possible off-by-one error in calculating the AImage `displayIndex` array.

I have a two-frame gif and only the first frame shows. With a three-frame gif only two frames animate back and forth. One frame is being dropped. I think it has something to do with the displayIndex array on AImage, but I can't understand the logic in the calculateFrameDelay function well enough to figure out exactly what is causing the issue.

Slows down entire app: suggestions?

Hi, I'd like to inquire about the app's performance in general. I understand it slows down the view it's in, but it currently seems to be affecting the entire app (I have an iCarousel running in the main View).
I have a single apng sitting in my SettingsViewController and display it in the footer view of the table. It's loaded with imageview.APlay();. Do I need to somehow use iamgeview.AStop(); in order for it not to affect the rest of the app? I understand this is a noob question, I'm just slightly confused by how slow the entire app has become all of a sudden.

Thanks a bunch!

Cocoapods

I'd be cool to also add Cocoapods support. I done this implementation myself last week for my library. Just follow this post and this checklist.
Lemme know if you need any help! 😄

Provide a way to stop a GIF

In one of my previous PR I had put a stopGIF() function. This allows for UIViewController that stays in the view hierarchy. For instance in the case of an UINavigationController push, it allows to stop GIFs in the viewDidDisappear, which prevent undisplayed GIFs to hog on the CPU.

An even better way would be to automatically stop any GIF that is not displayed.

发生闪白现象

swift4.0 版,播放完一次gif之后会像闪光灯一样闪烁1秒

iOS10 kCGImagePropertyGIFDictionary or kCGImagePropertyPNGDictionary

    var frameProperties = [CFDictionary]()
    if(imageProperty.imageType == ImageType.Gif){
        frameProperties = imageProperties.map(){
            let propertyGIFDic =  CFDictionaryGetValue($0,unsafeAddressOf(kCGImagePropertyGIFDictionary))
            return unsafeBitCast(propertyGIFDic,CFDictionary.self)
        }//gif
    }
    else if(CFDictionaryContainsKey(imageProperties[0],unsafeAddressOf(kCGImagePropertyPNGDictionary))){
        frameProperties = imageProperties.map(){
            unsafeBitCast(CFDictionaryGetValue($0,unsafeAddressOf(kCGImagePropertyPNGDictionary)),CFDictionary.self)
        }//apng
    }

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.