https://github.com/onix-systems/nsgif-android
Android version of NSGIF GIF decoder
https://github.com/onix-systems/nsgif-android
Last synced: about 2 months ago
JSON representation
Android version of NSGIF GIF decoder
- Host: GitHub
- URL: https://github.com/onix-systems/nsgif-android
- Owner: Onix-Systems
- License: other
- Created: 2023-10-03T10:55:16.000Z (over 1 year ago)
- Default Branch: dev
- Last Pushed: 2024-08-26T08:46:09.000Z (8 months ago)
- Last Synced: 2024-08-26T10:59:47.069Z (8 months ago)
- Language: C++
- Size: 19.2 MB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NsGifLib
**NsGifLib** is a library for working with GIF files in Android.
## Installation
**for gradle.kts**:
- add this inside *repositories* block:
- maven("https://jitpack.io")
- implementation("com.github.Onix-Systems:NSGIF-Android:0.0.2")## Core module
- Load, process, utilize gifs
- Work with native code using JNI
- Without *any Android dependencies## Usage
### Initialization
- val gifLib = NsGifLib.getInstance()### Loading Gifs
- 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)### Retrieve Gif info
- val gifInfo = gifLib.getGifInfo(gifId)### Copy Gif Data(frame)
- 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
- val isSuccess = gifLib.copyPixels(dest, gifId)### Cleaning up
- gifLib.destroyGif(gifId) // free allocated memory. please don't skip this step, it will cause memory leaks## License
MIT License. For more information see [LICENSE](LICENSE)