Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.WHITE);
BitmapFactory.Options options = new BitmapFactory.Options(); options.inMutable = true; Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image, options); bitmap.eraseColor(Color.BLACK);In this example, we first create a BitmapFactory.Options object and set its inMutable property to true, which allows the bitmap to be edited after creation. We then load an image resource into a new Bitmap object using the BitmapFactory.decodeResource() method. We then call the eraseColor() method on the bitmap object passing in the Color.BLACK value which fills the entire bitmap with the color black. Package library: android.graphics