NsGifLib is a library for working with GIF files in Android.
for gradle.kts:
- add this inside repositories block:
- maven("https://jitpack.io")
- implementation("com.github.Onix-Systems:NSGIF-Android:0.0.2")
- Load, process, utilize gifs
- Work with native code using JNI
- Without *any Android dependencies
- val gifLib = NsGifLib.getInstance()
- Load GIF from file: val gifId = gifLib.setGif("path/to/your/file.gif")
- Load GIF from byte array val gifId = gifLib.setGif(byteArray)
- Load GIF from input stream val gifId = gifLib.setGif(inputStream)
- val gifInfo = gifLib.getGifInfo(gifId)
- val dest = IntArray(gifInfo.width * gifInfo.height) //create pixel array of gif size
- val isSuccess = gifLib.copyPixels(dest, gifId) or
- gifLib.setGifFrame(frame, gifId) // when using, please be aware that non-zero frame might be dependent on previous one
- For example: frame 2 is dependent on frames 0 and 1, so to get frame 2 of the gif animation, you need to call:
- gifLib.setGifFrame(0, gifId) // not needed, frame 0 is set by default
- gifLib.setGifFrame(1, gifId)
- gifLib.setGifFrame(2, gifId)
- And then copy pixels as of your need
- For example: frame 2 is dependent on frames 0 and 1, so to get frame 2 of the gif animation, you need to call:
- val isSuccess = gifLib.copyPixels(dest, gifId)
- gifLib.destroyGif(gifId) // free allocated memory. please don't skip this step, it will cause memory leaks
MIT License. For more information see LICENSE