Rohit Malish
Rohit Malish

Reputation: 3229

Removing specific pixel from Bitmap

I want to remove pixels from Bitmap. Here is my for loop that goes through all pixels in Bitmap:

input and output are both Bitmaps.

for(int x = 0; x<input.getWidth(); x++){
            for(int y = 0; y<input.getHeight(); y++){               
                if(output.getPixel(x, y) == input.getPixel(x, y)){
                    output.setPixel(x, y, Color.WHITE); // changes color to white
                }
            }
        }

but I'd like to remove the pixel and not only change its color. Is that possible? I am later adding shadow to that bitmap based on its shape, so making it transparent doesn't help me in this case.

Upvotes: 0

Views: 1402

Answers (1)

Edward Falk
Edward Falk

Reputation: 10103

You mean make it transparent? Write a color with an alpha value of zero. setPixel(x,y,0) should do nicely.

Upvotes: 2

Related Questions