Android 图片加载[常见开源项目汇总]

    该文主要是讲一下目前有哪些使用比较多的 图片加载开源项目,并简单介绍该如果使用 以及各开源项目之间有什么区别

我们该如何去选择适合的开源项目应用到我们的项目中?

一、Android-Universal-Image-Loader

  项目地址:https://github.com/nostra13/Android-Universal-Image-Loader

如何使用?

  Acceptable URIs examples(可接受的Uri 例子 )

"http://site.com/image.png" // from Web  从网址上加载
"file:///mnt/sdcard/image.png" // from SD card  从SD 卡上加载
"file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)    
"content://media/external/images/media/13" // from content provider  从内容提供者上加载
"content://media/external/video/media/13" // from content provider (video thumbnail)  
"assets://image.png" // from assets  //从资源文件中加载
"drawable://" + R.drawable.img // from drawables (non-9patch images)
注: 建议使用 ImageView.setImageResource(); 代替 ImageLoader

  使用示例(Sample):

ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance 获取实例

// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view // which implements ImageAware interface) imageLoader.displayImage(imageUri, imageView);
// Load image, decode it to Bitmap and return Bitmap to callback imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // Do whatever you want with Bitmap } });
// Load image, decode it to Bitmap and return Bitmap synchronously Bitmap bmp = imageLoader.loadImageSync(imageUri);

  

二、picasso

  项目地址:https://github.com/square/picasso

使用示例:

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView); 

 

三、fresco

  项目地址:https://github.com/facebook/fresco

 

四、glide

  项目地址:https://github.com/bumptech/glide

 

五、ion

  项目地址:https://github.com/koush/ion

 

posted @ 2016-06-23 11:51  AnglusWang  阅读(673)  评论(0编辑  收藏  举报