2017-02-15 102 views
0

我試圖獲取使用滑翔存儲在SD卡上的圖像的位圖,但它不是爲我工作從SD卡獲取位圖。使用滑翔機器人

Bitmap bitmapByGlide = Glide.with(this).load(imagePath).asBitmap().into(100, 100).get(); 

回答

1

你可以試試這個方法:

Glide.with(this) 
     .load(Uri.fromFile(new File(url))) 
     .asBitmap() 
     .into(new SimpleTarget<Bitmap>() { 
      @Override 
      public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { 
      bitmapByGlide = resource; 
      } 
     }); 

(使用Uri.formFile()是這一招)

0

試試這個。

Glide.with(this) 
      .load(url) 
      .asBitmap() 
      .into(new SimpleTarget<Bitmap>() { 
       @Override 
       public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { 

       } 
      }); 
0
private SimpleTarget target = new SimpleTarget<Bitmap>() { 
    @Override 
    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) { 
     // do something with the bitmap 
     // for demonstration purposes, let's just set it to an ImageView 
     imageView1.setImageBitmap(bitmap); 
    } 
}; 

private void loadImageSimpleTarget() { 
    Glide 
     .with(context) // could be an issue! 
     .load(eatFoodyImages[0]) 
     .asBitmap() 
     .into(target); 
} 

來源:https://futurestud.io/tutorials/glide-callbacks-simpletarget-and-viewtarget-for-custom-view-classes

0

試試這個:

File b = new File(Environment.getExternalStorageDirectory(), "DCIM/Camera/IMG_20150828_174009.jpg"); 

 Glide.with(MainActivity.this).load(b).error(R.drawable.empty_pic).placeholder(R.drawable.empty_pic).into(image2);