2017-08-22 1 views
-1

ce code:Comment peut lancer GlideBitmapDrawable à BitmapDrawable reciprocaly

imageView = (ImageView) findViewById(R.id.avatar); 

Bitmap photo = ((GlideBitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap(); 
ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
photo.compress(Bitmap.CompressFormat.PNG,100,bos); 
byte[] bArray = bos.toByteArray(); 

retour cette erreur:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable

Merci pour votre aide :)

+0

avez-vous essayé ce post -> https://stackoverflow.com/questions/37701061/android-graphics-drawable-transitiondrawable-cannot-be-cast-to-com- bumptech-glid – slymnozdmrc

+0

En fait j'ai chargé l'image dans ImageView avec Bitmap.createScaledBitmap (bmp, x, y, bool) et maintenant je voudrais le récupérer avec Glide (GlideBitmapDrawable) pour stocker dans le DB –

+0

C'est en partie ce que je veux et réciprocité –

Répondre

1

changement ceci: -

Bitmap photo = ((GlideBitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap(); 

à cette

Bitmap photo = ((BitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap(); 
+0

avez-vous essayé votre code? Si non, pourquoi êtes-vous surpris des downvotes? – pskink

+0

je donne juste ans basé sur l'erreur que montrer à la question –

+1

[GlideBitmapDrawable] (http://bumptech.github.io/glide/javadocs/360/com/bumptech/glide/load/resource/bitmap/GlideBitmapDrawable.html) a rien à faire avec 'BitmapDrawable' pour que la distribution ne puisse pas être faite – pskink