GithubHelp home page GithubHelp logo

sweetsalts / apng4android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from penfeizhou/apng4android

0.0 0.0 0.0 30.67 MB

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

License: Apache License 2.0

Java 93.29% CMake 0.17% C++ 5.27% C 0.24% Kotlin 1.02%

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 {
    jcenter()
}

Animated WebP

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

APNG

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

Gif

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

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 {
    maven {
        url "https://dl.bintray.com/osborn/Android"
    }
}
dependencies {
    implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.1.0'
}

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

apng4android's People

Contributors

penfeizhou avatar jingpeng 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.