0

I would like to add an image (Bitmap) over another one. For that I am only using Bitmaps (fot the image I draw in and the image I add), but the Bitmap I am using is actually a resource in my drawable resource. So Is there a way to create a Bitmap that contains my drawable ?

akari
  • 617
  • 1
  • 11
  • 32

2 Answers2

2

Use decodeResource() of BitmapFactory to convert drawable resource into Bitmap as follows...

Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.your_drawable);
Hamid Shatu
  • 9,664
  • 4
  • 30
  • 41
1

Try this:

Bitmap bitmap= BitmapFactory.decodeResource(context.getResources(), 
    R.drawable.icon_name);
jyomin
  • 1,957
  • 2
  • 11
  • 27