Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android canvas change some pixels color

I have a Canvas object at start. I need to change color of some pixels depending on their current color. How can I do that in a proper way?

Details:

I have my own class extended from ImageView. In onDraw(Canvas canvas) method I draw something with third party class and have only Canvas object with result. I need after that change color of some pixels depending on their current color.

like image 423
Dmytro Zarezenko Avatar asked Sep 28 '12 17:09

Dmytro Zarezenko


1 Answers

Assuming that you have android.graphics.Canvas object called canvas and X & Y are points where you want to change pixel, so here you go

Call :

canvas.drawPoint(X, Y, paint);

Here is how you initalize Object of class android.graphics.Paint i.e paint

Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);

Search more on this Link to change multiple pixels at different positions, there are lot many functions that will help you achieve what you want. Best luck :-)

like image 136
Amandeep Jiddewar Avatar answered Sep 27 '22 18:09

Amandeep Jiddewar