• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Background image color detection with Android Paint

Aown Raza

Lurker
Jan 6, 2015
1
0
round image color detection with Android Paint
up vote 1 down vote favorite
When i start painting , it colors the whole background , i mean it should only paint the white spots. Application screenshot is as follows. Using Android Paint , i want to paint only white spots on background-drawable[Panda] and skip any other color.

onDraw() function is:

protectedvoid onDraw(Canvas canvas){

canvas.drawPath(path, paint);
canvas.drawPath(circlePath, circlePaint);

for(Pair<Path,Integer> path_clr : path_color_list ){
paint.setColor(path_clr.second);
canvas.drawPath( path_clr.first, paint);}

for(Pair<Path,Integer> path_clr : circular_path_color_list ){
circlePaint.setColor(path_clr.second);
canvas.drawPath( path_clr.first, paint);}}
and onTouchEvent function is:

publicboolean onTouchEvent(MotionEventevent){

float pointX =event.getX();float pointY =event.getY();switch(event.getAction()){caseMotionEvent.ACTION_DOWN:
circlePath.reset();
path.moveTo(pointX, pointY);

returntrue;caseMotionEvent.ACTION_MOVE:
path.lineTo(pointX, pointY);
circlePath.reset();
circlePath.addCircle(pointX, pointY,10,Path.Direction.CW);

break;

caseMotionEvent.ACTION_UP:
circlePath.reset();

break;default:returnfalse;}

postInvalidate();returntrue;}
 

Attachments

  • color.png
    color.png
    38.2 KB · Views: 66

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones