From bc7b5069f6287b8797765ce4d56fc6dac947c175 Mon Sep 17 00:00:00 2001 From: SimFG <1142838399@qq.com> Date: Fri, 5 Mar 2021 15:13:04 +0800 Subject: [PATCH] SetZoom update the method to calculate the trans --- touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt b/touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt index 194bf89c..ca2b205c 100644 --- a/touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt +++ b/touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt @@ -405,8 +405,8 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att resetZoom() scaleImage(scale.toDouble(), viewWidth / 2.toFloat(), viewHeight / 2.toFloat(), true) touchMatrix!!.getValues(floatMatrix) - floatMatrix!![Matrix.MTRANS_X] = -(focusX * imageWidth - viewWidth * 0.5f) - floatMatrix!![Matrix.MTRANS_Y] = -(focusY * imageHeight - viewHeight * 0.5f) + floatMatrix!![Matrix.MTRANS_X] = (viewWidth - matchViewWidth) / 2 - focusX * (scale - 1) * matchViewWidth + floatMatrix!![Matrix.MTRANS_Y] = (viewHeight - matchViewHeight) / 2 - focusY * (scale - 1) * matchViewHeight touchMatrix!!.setValues(floatMatrix) fixTrans() savePreviousImageValues()