I have loaded remote image to ImageView
using below code
Glide.with(context)
.load(imageUrl)
.placeholder(R.drawable.placeholderImage)
.into(holder.wallPaperImageView);
Now I want to get the bitmap from imageview
Bitmap bitmap = ((GlideBitmapDrawable)holder.wallPaperImageView.getDrawable()).getBitmap();
but above line of code throws below exception:
java.lang.ClassCastException: android.graphics.drawable.TransitionDrawable cannot be cast to com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable
How to resolve this?
Use this instead of that:
Bitmap bmp = ((GlideBitmapDrawable)holder.wallPaperImageView.getDrawable().getCurrent()).getBitmap();
or
Glide
.with(this)
.load(a.getAlbum_artwork())
.asBitmap()
.into(new SimpleTarget<Bitmap>(300,300) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
setBackgroundImage(resource);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With