# ohos-gif-drawable
**Repository Path**: HarmonyOS-tpc/ohos-gif-drawable
## Basic Information
- **Project Name**: ohos-gif-drawable
- **Description**: Views and Drawable for animated GIFs, Bundled GIFLib via JNI is used to render frames.
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 10
- **Forks**: 1
- **Created**: 2021-04-01
- **Last Updated**: 2025-06-16
## Categories & Tags
**Categories**: harmony, image-processing
**Tags**: None
## README
# ohos-gif-drawable
ohos-gif-drawable : Views and Drawable for animated GIFs, Bundled GIFLib via JNI is used to render frames.
# Usage Instructions
A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the entry/ folder.
The simplest way is to use GifImageView
```
```
The simplest way is to use GifTextView
```
```
GifDrawable can be constructed directly from various sources:
```
1. Using RawFileDescriptor :
gifDrawable = new GifDrawable(rawFileDescriptor);
2. Using ByteArray:
mbyteArray = getByteArrayFromRawFile("entry/resources/rawfile/anim_flag_chile.gif");
gifDrawable = new GifDrawable(mbyteArray);
3. Using ByteBuffer :
gifDrawable = new GifDrawable(mByteBuffer);
4. Using Uri :
gifDrawable = new GifDrawable(dataAbilityHelper, uri);
5. Using Inputstream :
gifDrawable = new GifDrawable(bufferedInputStream);
6. Using File :
gifDrawable = new GifDrawable(file);
7. Using FileDescripter :
gifDrawable = new GifDrawable(fd);
```
## Animation control
GifDrawable provides below animation control apis :
```
stop() - stops the animation
start() - starts the animation
isRunning() - returns whether animation is currently running or not
seekToFrameAndGet(index) - seeks to the frame with the given index
```
## Retrieving GIF metadata
```
getLoopCount() - returns a loop count
getNumberOfFrames() - returns number of frames
getComment() - returns comment text (null if GIF has no comment)
getFrameByteCount() - returns minimum number of bytes that can be used to store pixels of the single frame
getAllocationByteCount() - returns size (in bytes) of the allocated memory used to store pixels of given GifDrawable
getInputSourceByteCount() - returns length (in bytes) of the backing input data
```
# Installation Instructions:
1. For using ohos-gif-drawable module in your sample application, add below dependencies:
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
implementation project(':ohos-gif-drawable')
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
```
2. For using ohos-gif-drawable in separate application, add the below dependencies and include "ohos-gif-drawable.har" in libs folder of "entry" module:
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
implementation files('libs/ohos-gif-drawable.har')
}
```
Also add the libpl_droidsonroids_gif.so and libc++.so in sample's /libs/arm64-v8a (Create the folder if not present) in both cases
Add the Relinker dependency in ohos-gif-drawable and include its jar/har in libs in both cases:
```
dependencies {
implementation files('libs/relinker.har')
}
```
3. For using ohos-gif-drawable from a remote repository in separate application, add the below dependencies in build.gradle of "entry" module:
```
dependencies {
implementation 'io.openharmony.tpc.thirdlib:Ohos-Gif-Drawable:1.0.0'
}
```
Add the Relinker dependency in ohos-gif-drawable and include its jar/har in libs:
```
dependencies {
implementation 'io.openharmony.tpc.thirdlib:ReLinker:1.0.1'
}
```
## Version Iteration
v1.0.0
# License
MIT License
See [LICENSE](LICENSE) file.