AnimatedImage Save

High-performance animation image library.

Project README

AnimatedImage

High-performance animation image library.

Install

let package = Package(
    dependencies: [
        .package(url: "https://github.com/noppefoxwolf/AnimatedImage", from: "0.0.x")
    ],
)

How It Works

AnimatedImage pre-decodes and caches all animation frames. Optimize the number of drawing frames from the drawing size and drawing timestamp to prevent the cache size from becoming too large. It is designed so that all processing does not depend on the MainActor.

Usage

UIKit

let imageView = AnimatedImage(frame: .null)
let image = APNGImage(data: data)
imageView.image = image
imageView.startAnimating()

SwiftUI

@State var image = GIFImage(data: data)

var body: some View {
    AnimatedImagePlayer(image: image)
}

Features

Low access main actor

Support playback APNG, GIF, WebP

Automatically adjust playback quality

Synchronize frame update

Customizable playback format

public final class ManualAnimatedImage: AnimatedImage {
    public let name: String
    let images: [CGImage]
    
    public init(name: String = UUID().uuidString, images: [CGImage]) {
        self.name = name
        self.images = images
    }
    
    public nonisolated func makeImageCount() -> Int {
        images.count
    }
    
    public nonisolated func makeDelayTime(at index: Int) -> Double {
        0.1
    }
    
    public nonisolated func makeImage(at index: Int) -> CGImage? {
        images[index]
    }
}

Required

  • Swift 5.9
  • iOS 16+

Apps Using

License

AnimatedImage is available under the MIT license. See the LICENSE file for more info.

Open Source Agenda is not affiliated with "AnimatedImage" Project. README Source: noppefoxwolf/AnimatedImage
Stars
51
Open Issues
0
Last Commit
3 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating