Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crop image ala Google Goggles

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?

like image 362
Komi Avatar asked Mar 19 '11 22:03

Komi


People also ask

Can you crop images in Google drawings?

Cropping To crop an image: Select it and click on the crop image icon in the toolbar. Then drag the corners to your desired crop size and hit enter to make the crop.

Where is the crop button on Google drawings?

To crop an image, select it and click on the crop image icon in the toolbar.


1 Answers

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;
}
like image 119
Komi Avatar answered Oct 24 '22 13:10

Komi