- Create a new bitmap, with the size and config of the bitmap you wish to change.
- Create a Canvas and prepare it to paint to the new bitmap.
- Paint the new bitmap with your color using the canvas object.
- Draw the old bitmap to the new bitmap through the canvas object.
- Do what you want with the new bitmap
[java]
// Create new bitmap based on the size and config of the old
Bitmap newBitmap = Bitmap.createBitmap(oldBitmap.getWidth(), oldBitmap.getHeight(), oldBitmap.getConfig());
// Instantiate a canvas and prepare it to paint to the new bitmap
Canvas canvas = new Canvas(newBitmap);
// Paint it white (or whatever color you want)
canvas.drawColor(Color.WHITE);
// Draw the old bitmap ontop of the new white one
canvas.drawBitmap(oldBitmap, 0, 0, null);
[/java]
Leave a Reply