Kapng-Android/README.md

54 lines
1.3 KiB
Markdown
Raw Normal View History

2018-09-29 19:37:34 +00:00
# Kapng-Android
An android library to create or display apng
2018-10-05 19:51:13 +00:00
Exemple of apng :
![apng-example](https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png)
How to use this library :
To load animated png to an imageview :
```kotlin
val imageUrl = "https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png" // image url could be an url, or a file path. You could also load byteArray and file
2018-10-25 13:20:04 +00:00
val animator = ApngAnimator(this).loadInto(imageView)
2018-10-05 19:51:13 +00:00
animator.load(imageUrl)
animator.play()
```
2018-10-23 14:55:49 +00:00
To create animated png :
```kotlin
val apng = Apng()
val file1 = File("image path 1")
val file2 = File("image path 2")
apng.addFrames(BitmapFactory.decodeByteArray(file1.readBytes(), 0, file1.readBytes().size))
apng.addFrames(BitmapFactory.decodeByteArray(file2.readBytes(), 0, file2.readBytes().size))
val apngByteArray = apng.generateAPNGByteArray()
File("output file path").writeBytes(apngByteArray)
```
2018-10-24 11:28:13 +00:00
How to install :
Via jitpack
```gradle
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
2018-11-15 11:33:45 +00:00
implementation 'com.github.oupson:Kapng-Android:1.0.3'
2018-10-24 11:28:13 +00:00
}
```
Or put the aar file in /libs/ and verify that you have :
```gradle
dependencies {
implementation fileTree(include: ['*.aar'], dir: 'libs')
}