Is there a way to load image as bitmap to Glide
This solution is working with Glide V4. You can get the bitmap like this:
Bitmap bitmap = Glide
.with(context)
.asBitmap()
.load(uri_File_String_Or_ResourceId)
.submit()
.get();
Note: this will block the current thread to load the image.
A really strange case, but lets try to solve it. I'm using the old and not cool Picasso
, but one day I'll give Glide a try.
Here are some links that could help you :
- Bitmap POC
- Supporting bitmaps topic
- Someone also facing your problem
And actually a cruel but I think efficient way to solve this :
ByteArrayOutputStream stream = new ByteArrayOutputStream();
yourBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
Glide.with(this)
.load(stream.toByteArray())
.asBitmap()
.error(R.drawable.ic_thumb_placeholder)
.transform(new CircleTransform(this))
.into(imageview);
I'm not sure if this will help you, but I hope it can make you a step closer to the solution.
For version 4 you have to call asBitmap()
before load()
GlideApp.with(itemView.getContext())
.asBitmap()
.load(data.getImageUrl())
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {}
});
}
More info: http://bumptech.github.io/glide/doc/targets.html