0

I would like to get a few hints on how to do something like a brush of the paint windows application.

There will be a image that has touchable areas (how to define touchable areas on a image?), when the user touch those touchable areas I want to draw like a brush with a different color (how to draw on android? which widget should I use? imageview?)

Here are some images to help.

Before Touching:

Before Touching

After Touching:

After Touching

I am not looking for the entire solution, I am looking for some hints and maybe a few snippets. Thanks alot in advance ;)

EDIT: Advanced question: I would also like to measure how good was the touching above the letter, if was not good enough I would like to know, maybe doing touchable areas and not touchable areas, and counting which one and making a percentage? Thanks

TiagoM
  • 3,458
  • 4
  • 42
  • 83

1 Answers1

1
One way is use get the color where user touched and compare that with the touchable area here (gray) in your case. If the pixel color is gray means user is touching at right spot if white that means untouchable area 

You can get the pixel color like this-

imageView.setOnTouchListener(new OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event){
        int x = (int)event.getX();
        int y = (int)event.getY();
        int pixel = bitmap.getPixel(x,y);

        //then do what you want with the pixel data, e.g
        int redValue = Color.red(pixel);
        int blueValue = Color.blue(pixel);
        int greenValue = Color.green(pixel);        
        return false;
        }
   });


Hope this helps
Pramod
  • 1,123
  • 2
  • 12
  • 33