常用 Android 图片处理框架的比较

Fresco 12,324星星

https://github.com/facebook/fresco

FaceBook出品,支持Android 2.3 (Gingerbread)及以上

尼玛,他竟然有专门的中文文档:https://www.fresco-cn.org/docs/index.html

添加依赖

  1. //添加依赖
  2. compile ‘com.facebook.fresco:fresco:1.2.0‘
  3. //**************下面的依赖需要根据需求添加******************//
  4. // 在 API < 14 上的机器支持 WebP 时,需要添加
  5. compile ‘com.facebook.fresco:animated-base-support:1.2.0‘
  6. // 支持 GIF 动图,需要添加
  7. compile ‘com.facebook.fresco:animated-gif:1.2.0‘
  8. // 支持 WebP (静态图+动图),需要添加
  9. compile ‘com.facebook.fresco:animated-webp:1.2.0‘
  10. compile ‘com.facebook.fresco:webpsupport:1.2.0‘
  11. // 仅支持 WebP 静态图,需要添加
  12. compile ‘com.facebook.fresco:webpsupport:1.2.0‘

GitHub上的介绍:

Fresco is a powerful system for displaying images in Android applications.

Fresco takes care of image loading and display, so you don‘t have to. It will load images from the network, local storage, or local resources, and display a placeholder占位符 until the image has arrived. It has two levels of cache; one in memory and another in internal storage.

In Android 4.x and lower, Fresco puts images in a special region of Android memory. This lets your application run faster - and suffer the dreaded OutOfMemoryError much less often.

Fresco also supports:

  • streaming of progressive JPEGs
  • display of animated GIFs and WebPs
  • extensive广阔的 customization of image loading and display
  • and much more!

Fresco 支持许多URI格式,但 Fresco 不支持 相对路径的URI。所有的 URI 都必须是绝对路径,并且带上该 URI 的 scheme。如下:

类型                         SCHEME     示例

远程图片                 http://     HttpURLConnection 或者参考 使用其他网络加载方案

本地文件                 file://     FileInputStream

ContentProvider content://    ContentResolver

asset目录下的资源 asset://     AssetManager

res目录下的资源 res://     Resources.openRawResource

Uri中指定图片数据 data:mime/type;base64     数据类型必须符合 rfc2397规定 (仅支持 UTF-8)

总结

  • 优点:支持图像渐进式呈现,大公司出品,后期维护有保障
  • 缺点:框架体积较大,3M左右会增大apk的大小;操作方式不是特别简单,有一定学习成本
  • 特点:有两级内存一级文件的缓存机制,并且有自己特别的内存区域来处理缓存,避免oom

Glide 14,408星星

https://github.com/bumptech/glide

谷歌员工出品,Google推荐的图片加载库,专注于流畅的滚动

添加依赖

  1. repositories {
  2. mavenCentral() // jcenter() works as well because it pulls from Maven Central
  3. }
  4. dependencies {
  5. compile ‘com.github.bumptech.glide:glide:3.7.0‘
  6. compile ‘com.android.support:support-v4:19.1.0‘
  7. }

GitHub上的介绍:

An image loading and caching library for Android focused on smooth scrolling

Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.

Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible API that allows developers to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based stack, but also includes utility libraries plug in to Google‘s Volley project or Square‘s OkHttp library instead.

Glide‘s primary首要的 focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image.

总结

  • 优点:加载速度极快,框架体积小,四五百KB
  • 缺点:因为机制的选择不同,速度快了,但是图片质量低了,RGB565
  • 特点:根据ImageView大小来进行缓存,也就是说一张图片可能根据展示情况来缓存不同尺寸的几份

Picasso 13,035星星

https://github.com/square/picasso

Square出品,算是一个出来时间比较长的框架了

添加依赖

  1. compile ‘com.squareup.picasso:picasso:2.5.2‘

GitHub上的介绍就一句话:

A powerful image downloading and caching library for Android

优点:图片质量高

缺点:加载速度一般

特点:只缓存一个全尺寸的图片,根据需求的大小在压缩转换

Universal-Image-Loader 15,053星星

https://github.com/nostra13/Android-Universal-Image-Loader

尼玛,这个虽然最近基本更新了,而且还不提供Gradle的支持,但依然是星星最多的一个图片处理库

jar包下载

Powerful and flexible library for loading, caching and displaying images on Android.

优点:丰富的配置选项

缺点:最近一次维护在15年底,后期有不维护的趋势,可能被当前图片框架替代

特点:三级缓存的策略

总结:如果对图片质量要求不是太高的话,个人推荐Glide,其次推荐Fresco

null

时间: 2024-08-24 00:22:22

常用 Android 图片处理框架的比较的相关文章

android图片缓存框架Android-Universal-Image-Loader(二)

这篇打算直接告诉大家怎么用吧,其实这个也不是很难的框架,大致使用过程如下: // 获取缓存图片目录 File cacheDir = StorageUtils.getOwnCacheDirectory(activity, "imageloader/Cache"); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( activity).memoryCacheExtraOptions(800, 76

android图片缓存框架Android-Universal-Image-Loader

最近跟同学们做了一个创业项目,其实跟以前做项目不同,以前大多数都是做web网站,对内存管理这些不太关注,因为是pc机,做android的话也就是一些小列子,现在到了做产品阶段吧,只能把项目做到最优.不扯了,先来说这个框架是做什么的,Android-Universal-Image-Loader主要是一个图片的缓存框架,根据官方解释就是,它提供了一个异步处理图片的方案.它提供两种获取图片方式async or sync,并且提供了一个可定制化的组件(thread executors, download

图片会说话系列之Android图片缓存框架

前言:看过很多精彩的文章,作者写的非常好,但总觉得文字描述没有图片或图表说明来得直观,因为图片可以化抽象为具体.语言是有区域性的,而图片则是全世界通用的,即使语言不通,却能通过图片了解一切.因此想做一个系列的简博客,内容就是一张图附带一些必要的说明,这样就能迅速抓住重点,而不需要做太多的阅读,便能了解框架性的东西.文章所涉及到的图片有的可能来自官方网站,有的来自名家博客,或者是自己绘制的,都会一一说明. 切入正题,先来第一发,上图: 上图来自:https://github.com/nostra1

Android 图片裁切框架 uCrop 的用法

1 uCrop简介 最近项目中用到了图片裁剪功能,于是百度了一下,发现了uCrop这个框架,这个框架的星星数很多,就决定使用这个框架 uCrop的Github地址:https://github.com/Yalantis/uCrop uCrop的特点: 裁剪框不动,图片动 图片可以旋转,缩放 支持各种比例裁剪框 uCrop的效果图(来自其Github): 2 集成uCrop (1) uCrop集成方法: compile 'com.yalantis:ucrop:1.4.1' (2) 修改当前项目的b

详细讲解Android图片下载框架UniversialImageLoader之内存缓存扩展(四)

内存缓存的扩展还是蛮重要的,无论是数据结构还是具体的实现还是值得我们进行细细的品味,下面咱们就一起能品味这里面的趣味吧. 内存缓存的扩展主要学习下面的几个类:FIFOLimitedMemoryCache.FuzzyKeyMemoryCache. LargestLimitedMemoryCache.LimitedAgeMemoryCache.LRULimitedMemoryCache. LruMemoryCache.UsingFreqLimitedMemoryCache以及WeakMemoryCa

具体解说Android图片下载框架UniversialImageLoader之内存缓存(三)

前面的两篇文章着重介绍的是磁盘缓存,这篇文章主要是解说一下内存缓存.对于内存缓存.也打算分两篇文章来进行解说.在这一篇文章中,我们主要是关注三个类, MemoryCache.BaseMemoryCache以及LimitedMemoryCache. 首先我们先看一下内存缓存的接口MemoryCache. put(String key, Bitmap value); Bitmap get(String key); Bitmap remove(String key); Collection<Strin

详细讲解Android图片下载框架UniversialImageLoader之内存缓存(三)

前面的两篇文章着重介绍的是磁盘缓存,这篇文章主要是讲解一下内存缓存.对于内存缓存,也打算分两篇文章来进行讲解.在这一篇文章中,我们主要是关注三个类, MemoryCache.BaseMemoryCache以及LimitedMemoryCache. 首先我们先看一下内存缓存的接口MemoryCache. [java] view plaincopyprint? put(String key, Bitmap value); Bitmap get(String key); Bitmap remove(S

一起写一个Android图片加载框架

本文会从内部原理到具体实现来详细介绍如何开发一个简洁而实用的Android图片加载缓存框架,并在内存占用与加载图片所需时间这两个方面与主流图片加载框架之一Universal Image Loader做出比较,来帮助我们量化这个框架的性能.通过开发这个框架,我们可以进一步深入了解Android中的Bitmap操作.LruCache.LruDiskCache,让我们以后与Bitmap打交道能够更加得心应手.若对Bitmap的大小计算及inSampleSize计算还不太熟悉,请参考这里:高效加载Bit

Android常用的图片加载库

 Android常用的图片加载库 前言:图片加载涉及到图片的缓存.图片的处理.图片的显示等.四种常用的图片加载框架,分别是Fresco.ImageLoader. Picasso. Glide. Universal Image Loader:ImageLoader是比较老的框架,一个强大的图片加载库,包含各种各样的配置,最老牌,使用也最广泛. ImageLoader开源库存哪些特征: 1.多线程下载图片,图片可以来源于网络,文件系统,项目文件夹assets中以及drawable中等 2.支持随意的