Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evant/android-apngrs
Android bindings to image-rs for APNG support.
https://github.com/evant/android-apngrs
Last synced: about 1 month ago
JSON representation
Android bindings to image-rs for APNG support.
- Host: GitHub
- URL: https://github.com/evant/android-apngrs
- Owner: evant
- License: apache-2.0
- Created: 2023-03-06T05:39:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T08:12:01.000Z (4 months ago)
- Last Synced: 2024-09-10T03:39:00.121Z (3 months ago)
- Language: Kotlin
- Size: 287 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/evant/android-apngrs.svg?style=svg&circle-token=8792fa19911be92d6a1d66dd45ece3bf6712f778)](https://circleci.com/gh/evant/android-apngrs)[![Maven
Central](https://img.shields.io/maven-central/v/me.tatarka.android/apngrs)](https://search.maven.org/search?q=g:me.tatarka.android)
[![Sonatype Snapshot](https://img.shields.io/nexus/s/https/oss.sonatype.org/me.tatarka.android/android-apngrs.svg)](https://oss.sonatype.org/content/repositories/snapshots/me/tatarka/android/)# android-apngrs
Bindings to [image-rs](https://github.com/image-rs/image) for APNG support on Android.
# Usage
You can include the decoder with
```kotlin
implementation("me.tatarka.android:apngrs:0.4")
```Then you can create a source and decode a drawable. The api is mirrored after
[ImageDecoder](https://developer.android.com/reference/android/graphics/ImageDecoder).```kotlin
val source = ApngDecoder.source(resources, R.drawable.my_animated_png)
val drawable = ApngDecoder.decodeDrawable(source)
drawable.start() // to start the animation.
```## Coil Integration
For easy [coil](https://coil-kt.github.io/coil/) integration, include
```kotlin
implementation("me.tatarka.android:apngrs-coil:0.4")
```and then add the decoder
```kotlin
val imageLoader = ImageLoader.Builder(context)
.components {
add(ApngDecoderDecoder.Factory())
}
.build()
```## Current Limitations/Possible Future Directions
- All animations are currently rendered as looping infinitely instead of respecting the num_plays
value.
- Image data is loaded first into a byte array in memory before decoding, could do some sort of
streaming support here if I could figure out the jni bits for that.
- image-rs actually supports a wide range of image formats but only APNGs are currently supported.
May be expanded in the future if there's value.
- Source inputs are limited to byte arrays and resources, this could be expanded pretty easily.