-1

Bitmap picture = BitmapFactory.decodeResource(getResources(),R.drawable.phscale);

apart from above code any other ways to get the bitmap from drawables

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Sivaganesan.r
  • 261
  • 1
  • 5
  • 13

3 Answers3

1

If you get your png name as string, you could use the following:

int resID = getResources().getIdentifier("bug", "drawable",   "org.anddev.android.testproject");

source

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
Beasly
  • 1,517
  • 4
  • 20
  • 30
0

If you would like to have full control over resource bits, you'd better put it either in res/asset or res/raw folders and then get access to them as:

InputStream is=this.getResources().getAssets().open("drawable.png");
//
is=this.getResources().openRawResource(R.raw.myDrawable);
Barmaley
  • 16,638
  • 18
  • 73
  • 146
0

See th link How to convert a Drawable to a Bitmap?

Community
  • 1
  • 1
Vivek
  • 4,170
  • 6
  • 36
  • 50