0

I would like to read a drawable image from an external package into a bitmap. For example, in package com.test.images I have an image called image1.png under the drawable-hdpi folder. I would like to read that image into a Bitmap object from another package, for example com.test.reader. Can someone give a solution?

I can use the getResourcesForApplication(packageName) to get access to the resources of the external package, but the resources object I get only has a getDrawable method; I want to get a Bitmap for the image.

Thanks

a.p.
  • 3,248
  • 7
  • 30
  • 48

1 Answers1

0

Once you get the Drawable object you'll have to convert it to a Bitmap Object.

Refer to this question to see one possible way to achieve this.

Community
  • 1
  • 1
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • I have tried that but I get the error, 'BitmapDrawable cannot be resolved to a type'. This is strange. – a.p. Aug 25 '11 at 05:05
  • 1
    Ok, I manually imported the android.graphics.drawable.BitmapDrawable class (Eclipse wouldn't suggest it for me) and it compiles. – a.p. Aug 25 '11 at 05:17
  • Weird. I wonder why auto import wouldn't find it. Good to know though. – FoamyGuy Aug 25 '11 at 13:11