Kapng-Android/README.md

36 lines
971 B
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
val animator = ApngAnimator(imageView)
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)
```