我是靠谱客的博主 闪闪鼠标,最近开发中收集的这篇文章主要介绍webp解码 android,GlideWebpDecoder一个Glide WebpDecoder集成库用于解码和显示webp图像,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

GlideWebpDecoder

687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865322e302d627269676874677265656e2e7376673f7374796c653d666c617468747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d312e382d7265642e73766768747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e737667

GlideWebpDecoder is a Glide integration library for decoding and displaying webp images on Android platforms. It is based on libwebp project and takes some implementation from Fresco and GlideWebpSupport as references.

Features

play animated webp images on all Android versions

show transparent or lossless webp images on Android devices lower than 4.2.1 (BitmapFactory support webp decode on 4.2+ android system so we have no need to handle)

Dependency Integration

Library is available in jcenter. If you build with Gradle, just add the following dependencies to your build.gradle file. Different Glide version is corresponding to different GlideWebpDecoder due to the annotation processor compatibility. The version rule of GlideWebpDecoder is "{major_version}.{glide_version}". For example, if you use glide 4.11.0, the corresponding version of GlideWebpDecoder should be 1.7.4.11.0

Library will only follow the latest three version of Glide. If you use a lower version glide, please clone the project and modify it yourself.

Notice

Since Glide 4.10.0 has migrate to AndroidX, so your project must use AndroidX with Glide 4.10.0+.

WebpDecoder with AndroidX support starts from version 1.6.{GLIDE_VERSION} and won't support glide version below 4.10.0 anymore.

If your project use glide version below 4.10.0, you can only use webpdecoder 1.6 version or below.

def GLIDE_VERSION = "4.11.0"

// webpdecoder

implementation "com.zlc.glide:webpdecoder:1.8.${GLIDE_VERSION}"

// glide 4.10.0+

implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"

annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"

Then you are free to use GlideWebpDecoder just like using other Glide integration library.

Usage

Basic usage see Glide API documents

If you want to use BitmapTransformation or library glide-transformations, please use WebpDrawableTransformation to wrap your original BitmapTransformation when loading image with Glide request.

Code Snippet as follow. Run sample project to see other Glide built-in transformation effect.

Transformation circleCrop = new CircleCrop();

GlideApp.with(mContext)

.load(url)

.optionalTransform(circleCrop)

.optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(circleCrop))

.into(imageView);

Proguard

The library use native code to decode webp, so you should put the following lines to your proguard.cfg and keep the jni interface.

-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }

-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }

-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }

Acknowledgement

License

The Library is Apache-2.0-licensed, part code is MIT-licensed see Fresco for detail.

最后

以上就是闪闪鼠标为你收集整理的webp解码 android,GlideWebpDecoder一个Glide WebpDecoder集成库用于解码和显示webp图像的全部内容,希望文章能够帮你解决webp解码 android,GlideWebpDecoder一个Glide WebpDecoder集成库用于解码和显示webp图像所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部