常用 Android 圖片處理架構的比較

來源:互聯網
上載者:User

標籤:檔案   custom   nec   員工   成本   erb   操作   需求   bsp   

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://    FileInputStreamContentProvidercontent://    ContentResolverasset目錄下的資源asset://    AssetManagerres目錄下的資源res://    Resources.openRawResourceUri中指定圖片資料data:mime/type;base64    資料類型必須符合 rfc2397規定 (僅支援 UTF-8)
總結
  • 優點:支援映像漸進式呈現,大公司出品,後期維護有保障
  • 缺點:架構體積較大,3M左右會增大apk的大小;操作方式不是特別簡單,有一定學習成本
  • 特點:有兩級記憶體一級檔案的緩衝機制,並且有自己特別的記憶體地區來處理緩衝,避免oom

Glide 14,408星星https://github.com/bumptech/glide
Google員工出品,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

常用 Android 圖片處理架構的比較

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.