ohos-gif-drawable : Views and Drawable for animated GIFs, Bundled GIFLib via JNI is used to render frames.
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
<pl.droidsonroids.gif.GifImageView
ohos:id="$+id:gif"
ohos:height="90vp"
ohos:width="90vp"/>
The simplest way is to use GifTextView
<pl.droidsonroids.gif.GifTextView
ohos:id="$+id:gif1"
ohos:height="60vp"
ohos:width="90vp"
ohos:text_alignment="center"
ohos:text="Background"/>
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);
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
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
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'
}
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')
}
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'
}
v1.0.0
MIT License See LICENSE file.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. Open source ecosystem
2. Collaboration, People, Software
3. Evaluation model