Glideを使用してSdカードに保存された画像のビットマップを取得しようとしていますが、動作しません。Glideを使用してSDカードからビットマップを取得
Bitmap bitmapByGlide = Glide.with(this).load(imagePath).asBitmap().into(100, 100).get();
Glideを使用してSdカードに保存された画像のビットマップを取得しようとしていますが、動作しません。Glideを使用してSDカードからビットマップを取得
Bitmap bitmapByGlide = Glide.with(this).load(imagePath).asBitmap().into(100, 100).get();
https://futurestud.io/tutorials/glide-callbacks-simpletarget-and-viewtarget-for-custom-view-classes:
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;
}
});
これを試してください。
Glide.with(this)
.load(url)
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
}
});
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);
}
出典:あなたがこの方法を試すことができます
これを試してみてください(Uri.formFileは()これのトリックで使用):
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);