• 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
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: 105
Back
Top Bottom