It's simple, GlideBitmapDrawable is not a BitmapDrawable:
But it has a getBitmap() method, so if you really want to access the bitmap this way:
Bitmap bmp = ((GlideBitmapDrawable)imgDisplay.getDrawable()).getBitmap();
However I wouldn't recommend that, you can get the Bitmap in many waysin Glide, here's one (I let you extract classes/methods as you see fit):
//noinspection unchecked
new AsyncTask<FutureTarget<Bitmap>, Void, Bitmap>() {
@Override protected Bitmap doInBackground(FutureTarget<Bitmap>... params) {
try {
return params[0].get(); // get needs to be called on background thread
} catch (Exception ex) {
return null;
}
}
@Override protected void onPostExecute(Bitmap bitmap) {
if(bitmap == null) return;
MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "Titel", "Beschrijving");
}
}.execute(Glide.with(this).load(url).asBitmap().into(width, height)); // into needs to be called on main thread