我正在尝试使用以下方法围绕点进行缩放:
- 将图像移动到想要缩放的点(捏合缩放)
- 进行缩放
- 将图像移回原位
具体实现如下:
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scaleFactor = detector.getScaleFactor();
float focusX = detector.getFocusX();
float focusY = detector.getFocusY();
Matrix.translateM(modelMatrix, 0, -focusX, -focusY, 0);
Matrix.scaleM(modelMatrix, 0, scaleFactor, scaleFactor, 0);
Matrix.translateM(modelMatrix, 0, focusX, focusY, 0);
但是当我创建结果MVP矩阵时,像这样:
Matrix.multiplyMM(MVPmatrix, 0,
projectionMatrix, 0,
modelMatrix, 0);
我得到了错误的缩放,它会进行缩放但不能正确地围绕点进行缩放。
请问可能的原因是什么,如何才能正确地围绕该点进行缩放?