PinchToZoom icon indicating copy to clipboard operation
PinchToZoom copied to clipboard

How to reset scaling to the original?

Open OstapenkoYevgeniy opened this issue 5 years ago • 4 comments

Hi! Thanks for the great library.

There is one problem.

  1. I do imgViev.setImageBitmap(bitmap)
  2. Enlarge the image, but do not reduce it.
  3. Upload the next image in imgView
  4. It is immediately on an enlarged scale, and I want it to be in the original. How to finish this?

Thank you!

P.S. I found a solution!

        try {
            imageMatrixTouchHandler.animateZoom(0, 0);
        } catch (Exception ignore) {
        }

try/catch need, because there may be an exception

W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Matrix.getValues(float[])' on a null object reference at com.bogdwellers.pinchtozoom.MatrixCorrector.getValues(MatrixCorrector.java:96)

OstapenkoYevgeniy avatar Oct 09 '18 18:10 OstapenkoYevgeniy

See if the answer in #6 works for you and please post back.

martinwithaar avatar Oct 18 '18 11:10 martinwithaar

See if the answer in #6 works for you and please post back.

Answer # 6 did not work for me, after the reset, I had indents on the left and above

OstapenkoYevgeniy avatar Oct 18 '18 12:10 OstapenkoYevgeniy

Hi! Thanks for the great library.

There is one problem.

  1. I do imgViev.setImageBitmap(bitmap)
  2. Enlarge the image, but do not reduce it.
  3. Upload the next image in imgView
  4. It is immediately on an enlarged scale, and I want it to be in the original. How to finish this?

Thank you!

P.S. I found a solution!

        try {
            imageMatrixTouchHandler.animateZoom(0, 0);
        } catch (Exception ignore) {
        }

try/catch need, because there may be an exception

W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Matrix.getValues(float[])' on a null object reference at com.bogdwellers.pinchtozoom.MatrixCorrector.getValues(MatrixCorrector.java:96)

where to put this code if using setOnTouchListener

DilumD avatar Nov 28 '18 13:11 DilumD

@DilumD

 imageMatrixTouchHandler = new ImageMatrixTouchHandler(mContext, corrector) {
            @Override
            public boolean onTouch(View view, final MotionEvent event) {
                        super.onTouch(view, event);
            }
};
TouchImageView.super.setOnTouchListener(imageMatrixTouchHandler);

        try {
            imageMatrixTouchHandler.animateZoom(0, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }

ndubbaka avatar Jun 27 '19 17:06 ndubbaka