Pinch Zoom and 2 Finger Rotating ImageView in Android

I have been having a problem from the last 2 days, and I can’t solve it, as I am a newbie. I'm actually working on an Android application that requires scaling and 2-finger rotation on an Android ImageView. I got some guides and solutions that work great for Pinch Zoom, but don't work for 2nd finger rotation. I share the simplest tutorial that is easy to understand, and I want to extend it by 2 fingers. Here is the code snippet:

    public class MainActivity extends Activity {
    private ImageView mImageView;
    private Matrix mMatrix = new Matrix();
    private float mScale = 1f;
    private ScaleGestureDetector mScaleGestureDetector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mImageView = (ImageView) findViewById(R.id.imageView);
        mScaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());
    }

    public boolean onTouchEvent(MotionEvent ev) {
        mScaleGestureDetector.onTouchEvent(ev);
        return true;
    }

    private class ScaleListener extends ScaleGestureDetector.
            SimpleOnScaleGestureListener {
        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            mScale *= detector.getScaleFactor();
            mScale = Math.max(0.1f, Math.min(mScale, 5.0f));
            mMatrix.setScale(mScale, mScale);
            mImageView.setImageMatrix(mMatrix);
            return true;
        }
    }
}

Also I want to use them for GPUImage, I mean, despite Android ImageView, I want to use GPUImage. How to convert GPUImage to ImageView? This is the second. First, I want to implement 2-finger rotation (or in some ways MultiTouch). Thanks

+4
1

, . fooobar.com/questions/200322/... ,

  1. imageView.setRotation(imageView.getRotation() + (-angle)); OnRotation(RotationGestureDetector rotationDetector) , ImageView

.

+1

All Articles