Search code examples
androidbitmapontouch

Android Bitmap setPixel not working when used with onTouch


I am trying to change a row of pixels to the color black.

for (int i = 0; i < bmp.getWidth(); i++)
                bmp.setPixel(i, 150, Color.BLACK);

this code works just fine when called in onCreate or from a button onClick

But for some reason i can't explain, when this code is called from an onTouch event (this exact same code), it just does not change the pixels color


Solution

  • Since you didn't say, I'm going to assume you've placed the bitmap into an ImageView. Try calling invalidate on the ImageView containing the Bitmap after you make all your changes.