Reputation: 361
I have an image containing arrow drawn on white color background. I'm decoding it as follows.
Drawable drawable = context.getResources().getDrawable(R.drawable.arrow);
Bitmap bm;
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
bm = bitmap;
When bitmap 'bm' is drawn on canvas, I can still see white color background. Where as in case of normal png, it works just fine.
Can anybody tell me what is wrong with this image?
Upvotes: 0
Views: 713
Reputation: 11151
The PNG format supports the transparency channel while BMP doesn't. So if you are using a .bmp or .jpeg file as your arrow drawable, you will get a full rectangular copy of it drawn on the canvas. So my advice is to find a .png version of an arrow.
Upvotes: 1