GithubHelp home page GithubHelp logo

liuxi0314 / apng4android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from penfeizhou/apng4android

0.0 0.0 0.0 31.36 MB

Android animation support for APNG & Animated WebP & Gif,High performance

License: Apache License 2.0

C++ 5.11% C 0.22% Java 94.50% CMake 0.17%

apng4android's Introduction

Animation Android

  • Support APNG & Animated Webp & Gif in Android
  • Efficient decoder
  • Support Drawable usage and glide library module
  • Support animation play control
  • Support still image
  • Low memory usage

Usages

Add dependency in build.gradle

repositories {
    mavenCentral()
}

Animated WebP

dependencies {
    implementation 'com.github.penfeizhou.android.animation:awebp:${VERSION}'
}

APNG

dependencies {
    implementation 'com.github.penfeizhou.android.animation:apng:${VERSION}'
}

Gif

dependencies {
    implementation 'com.github.penfeizhou.android.animation:gif:${VERSION}'
}

Notice Before Use!

Don't put APNG resources in your drawable or mipmap directory! During the process of release building of an Android app, the aapt tool will zip & modify the frame info of the APNG file, which will lead to an abnormal behavior when playing it. Thus, please put the APNG resources in raw or assets folder instead.

Use

// Load from asset file
AssetStreamLoader assetLoader = new AssetStreamLoader(context, "wheel.png");


// Load form Resource
ResourceStreamLoader resourceLoader = new ResourceStreamLoader(context, R.drawable.sample);


// Load from file
FileStreamLoader fileLoader = new FileStreamLoader("/sdcard/Pictures/1.webp");


// Create APNG Drawable
APNGDrawable apngDrawable = new APNGDrawable(assetLoader);

//Create Animated webp drawable
WebPDrawable webpDrawable = new WebPDrawable(assetLoader);

// Auto play
imageView.setImageDrawable(apngDrawable);


// Not needed.default controlled by content
apngDrawable.setLoopLimit(10);


// Implement Animatable2Compat
drawable.registerAnimationCallback(new Animatable2Compat.AnimationCallback() {
    @Override
    public void onAnimationStart(Drawable drawable) {
        super.onAnimationStart(drawable);
    }
});

Glide support

Add dependency in build.gradle

repositories {
    ...
    mavenCentral()
}
dependencies {
    implementation 'com.github.penfeizhou.android.animation:glide-plugin:${VERSION}'
}

Direct use

Glide.with(imageView).load("https://misc.aotu.io/ONE-SUNDAY/SteamEngine.png").into(imageView);
Glide.with(imageView).load("https://isparta.github.io/compare-webp/image/gif_webp/webp/2.webp").into(imageView);

Welcome to join the talk

image

apng4android's People

Contributors

penfeizhou avatar jingpeng avatar showmethe avatar insofan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.