標籤:檔案 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
添加依賴
//添加依賴
compile ‘com.facebook.fresco:fresco:1.2.0‘
//**************下面的依賴需要根據需求添加******************//
// 在 API < 14 上的機器支援 WebP 時,需要添加
compile ‘com.facebook.fresco:animated-base-support:1.2.0‘
// 支援 GIF 動圖,需要添加
compile ‘com.facebook.fresco:animated-gif:1.2.0‘
// 支援 WebP (靜態圖+動圖),需要添加
compile ‘com.facebook.fresco:animated-webp:1.2.0‘
compile ‘com.facebook.fresco:webpsupport:1.2.0‘
// 僅支援 WebP 靜態圖,需要添加
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推薦的圖片載入庫,專註於流暢的滾動
添加依賴
repositories {
mavenCentral() // jcenter() works as well because it pulls from Maven Central
}
dependencies {
compile ‘com.github.bumptech.glide:glide:3.7.0‘
compile ‘com.android.support:support-v4:19.1.0‘
}
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出品,算是一個出來時間比較長的架構了
添加依賴
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 圖片處理架構的比較