An android library to create or display apng
Go to file
Oupson b0e79ccee9 More deprecations 2021-02-06 17:35:15 +01:00
apng_library More deprecations 2021-02-06 17:35:15 +01:00
app-test Update dependencies 2021-02-05 20:52:13 +01:00
gradle/wrapper Remove useless string conversion. 2020-12-06 19:22:05 +01:00
.gitignore Updating gitignore 2020-05-11 14:43:22 +02:00
LICENSE Create LICENSE 2018-09-29 21:38:44 +02:00
README.md Update README 2020-09-19 11:09:47 +02:00
build.gradle Update dependencies 2021-02-05 20:52:13 +01:00
gradle.properties Update to androidx 2019-05-17 18:48:32 +02:00
gradlew Initial commit 2018-09-27 22:05:08 +02:00
gradlew.bat Initial commit 2018-09-27 22:05:08 +02:00
settings.gradle Initial commit 2018-09-27 22:05:08 +02:00

README.md

Kapng-Android

An android library to create or display apng

Example of apng :

apng-example

How to use this library :

To load an animated png to an imageView :

val imageUrl = "https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png"

ApngDecoder.decodeApngAsyncInto(context, URL(url), imageView)

You can load a file, an uri, a resource int, an url, or an inputStream.

With a callback :

ApngDecoder.decodeApngAsyncInto(this, uri, viewerImageView, callback = object : ApngDecoder.Callback {
  override fun onSuccess(drawable: Drawable) { println("Success !") }
  override fun onError(error: Exception) { println("Error : $error") }
})

To create animated png :

val output : OutputStream = FileOutputStream("res.png") // An OutputStream (ex : a FileOutputStream)
val maxWidth : Int = 256 // The width of your image (ex : 256)
val maxHeight : Int = 256// The height of your image (ex : 256)
val nFrame : Int = 2 // Number of frame (ex : 2)

val inputFrame1 : InputStream = FileInputStream("frame1.png") // Input stream of your frame 1 (ex : a FileInputStream)
val inputFrame2 : InputStream = FileInputStream("frame2.png") // Input stream of your frame 2 (ex : a FileInputStream)

val encoder = ApngEncoder(output, maxWidth, maxHeight, nFrame)

encoder.writeFrame(inputFrame1)
inputFrame1.close()

encoder.writeFrame(inputFrame2, delay=500f) // With delay ! Default is 1000ms
inputFrame2.close()

encoder.writeEnd()
output.close()

How to install :

Via jitpack

repositories {
  maven { url "https://jitpack.io" }
 }
 
 dependencies {
  implementation 'com.github.oupson:Kapng-Android:1.0.10-beta3'
 }

Or put the aar file in /libs/ and verify that you have :

 dependencies {
   implementation fileTree(include: ['*.aar'], dir: 'libs')
 }