5 Star 5 Fork 1

HarmonyOS-TPC / ohos-gif-drawable

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
Apache-2.0

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

	<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);

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'
}
  1. 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')
}
  1. 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 file.

MIT License Copyright (c) 2013 - present Karol Wrótniak, Droids on Roids LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SKIA: // Copyright (c) 2011 Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. GIFLIB: The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond ReLinker: Copyright 2015 KeepSafe Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. memset.arm.S: Copyright (C) 2010 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Views and Drawable for animated GIFs, Bundled GIFLib via JNI is used to render frames. expand collapse
Java and 5 more languages
Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HarmonyOS-tpc/ohos-gif-drawable.git
git@gitee.com:HarmonyOS-tpc/ohos-gif-drawable.git
HarmonyOS-tpc
ohos-gif-drawable
ohos-gif-drawable
master

Search

344bd9b3 5694891 D2dac590 5694891