androidpdfbitmapbitmapdrawable

Convert BitmapDrawable to Bitmap


In my project a bitmap gets filled with text and another bitmap, the method to add the text to the bitmap returns a BitmapDrawable.

I want to save this BitmapDrawable as a pdf file, so I can email the original bitmap, with text and other image(s) added.

For this, I'll need a regular Bitmap instead of a BitmapDrawable. I can't seem to find any answers on this, because I don't have a reference to a drawable in a drawable folder, I just have a BitmapDrawable to work with.

Any ideas on this?


Solution

  • BitmapDrawables support a getter for the bitmap.

    Bitmap bitmap = bitmapDrawable.getBitmap();