Tuesday, 25 November 2014

Converting drawable resource to Bitmap Android



Hello I am Building an Npuzzle App for an independent project to learn basics of app programming. The current issue i face is bringing a drawable object into my Activity so that i can covert it to a bitmap for splitting. I have found and attempted to use this Approach:



Drawable hold = Puzzle.this.getResources().getDrawable(R.drawable.img1);
BitmapDrawable hold2 = (BitmapDrawable) hold;
Bitmap bitPhoto = hold2.getBitmap();


when i run my app i get a null pointer exception in the first line of code. any suggestions on how to fix this problem?


No comments:

Post a Comment