Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noppefoxwolf/animatedimage
High-performance animation image library.
https://github.com/noppefoxwolf/animatedimage
apng gif ios swift swiftui webp
Last synced: about 1 month ago
JSON representation
High-performance animation image library.
- Host: GitHub
- URL: https://github.com/noppefoxwolf/animatedimage
- Owner: noppefoxwolf
- License: mit
- Created: 2023-11-21T23:06:16.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-17T18:20:30.000Z (4 months ago)
- Last Synced: 2024-10-15T22:47:45.691Z (3 months ago)
- Topics: apng, gif, ios, swift, swiftui, webp
- Language: Swift
- Homepage:
- Size: 6.34 MB
- Stars: 57
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AnimatedImage
High-performance animation image library.
![](https://github.com/noppefoxwolf/AnimatedImage/blob/main/.github/Format.gif)
# Install
```swift
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
```swift
let imageView = AnimatedImage(frame: .null)
let image = APNGImage(data: data)
imageView.image = image
imageView.startAnimating()
```## SwiftUI
```swift
@State var image = GIFImage(data: data)var body: some View {
AnimatedImagePlayer(image: image)
}
```# Features
## Low access main actor
![](https://github.com/noppefoxwolf/AnimatedImage/blob/main/.github/Instruments.png)
## Support playback APNG, GIF, WebP
![](https://github.com/noppefoxwolf/AnimatedImage/blob/main/.github/Format.gif)
## Automatically adjust playback quality
![](https://github.com/noppefoxwolf/AnimatedImage/blob/main/.github/AdjustQuality.gif)
## Synchronize frame update
![](https://github.com/noppefoxwolf/AnimatedImage/blob/main/.github/Synchronize.gif)
## Customizable playback format
```swift
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 6.0
- iOS 16## Apps Using
# License
AnimatedImage is available under the MIT license. See the LICENSE file for more info.