6

I'm trying to do some ROI (region of interest) selection in my app, but I don´t know, how to create some kind of resizable (by fingers) rectangle like you can see in Google Goggles. Can you help me? Is there any source code example?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Komi
  • 330
  • 3
  • 13

2 Answers2

2

My final solution is to draw and rectangle in the midle of a view and implement onTouchEvent() in my activity to set new corners coordinates like this:

@Override
public boolean onTouchEvent(MotionEvent me) {
    if(SETTING_ROI == true){
        if (me.getAction() == MotionEvent.ACTION_DOWN) {
            START_DRAGGING = true;
            myView.selectCorner((int) me.getRawX(), (int) me.getRawY()); // selecst nearest corner
        }
        if (me.getAction() == MotionEvent.ACTION_MOVE){
            Log.d(TAG, "ACTION_MOVE");
            myView.moveCorner((int) me.getRawX(), (int) me.getRawY()); // move selected corner continuously
        }
        if (me.getAction() == MotionEvent.ACTION_UP){
            if (START_DRAGGING == true) {
                START_DRAGGING = false;
                myView.moveCorner((int) me.getRawX(), (int) me.getRawY()); // final selected corner move
            }
        }
    }
    return false;
}
Komi
  • 330
  • 3
  • 13
0

Could you reuse code from the Gallery-Cropper?

The CropImage class source code is available here.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Nick
  • 3,504
  • 2
  • 39
  • 78
  • It seems too complex. I will better appreciate just an example of How to create an rectangle and move its corners to all directions to create an custom selection. – Komi Mar 22 '11 at 21:44