Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 任意点上的尺度和中心矩阵_Android_Matrix_Android Imageview_Interpolation_Scaletransform - Fatal编程技术网

Android 任意点上的尺度和中心矩阵

Android 任意点上的尺度和中心矩阵,android,matrix,android-imageview,interpolation,scaletransform,Android,Matrix,Android Imageview,Interpolation,Scaletransform,我使用一个自定义的ImageView来显示一个相当大的位图。位图显示由一个矩阵处理,该矩阵将位图转换为用户看到的内容。我试图实现“双击缩放”,但我不能完全正确。我试着让图像在用户接触到的点上缩放,最后在屏幕的中心 我做了很多矩阵数学和变换,基本上下面的变换就是我需要做的 float dx = centerX - focusX; float dy = centerY - focusY; Matrix m = new Matrix( baseMatrix ); m.postTranslate( -

我使用一个自定义的ImageView来显示一个相当大的位图。位图显示由一个矩阵处理,该矩阵将位图转换为用户看到的内容。我试图实现“双击缩放”,但我不能完全正确。我试着让图像在用户接触到的点上缩放,最后在屏幕的中心

我做了很多矩阵数学和变换,基本上下面的变换就是我需要做的

float dx = centerX - focusX;
float dy = centerY - focusY;

Matrix m = new Matrix( baseMatrix );
m.postTranslate( -focusX, -focusY );
m.postScale( scale, scale );
m.postTranslate( focusX + dx, focusY + dy );
如果我只是交换矩阵就可以了,但我需要从baseMatrix到这个新矩阵进行动画制作。有没有办法在这两个矩阵之间插值

我试着分别插入音阶和翻译,但效果不太好(很可能是我做错了,这是正确的方法)。我目前仅为比例插值的方式如下。我也尝试过在处理程序中添加一个翻译插值,但没有成功

mHandler.post( new Runnable() {

  @Override
  public void run() {
    mZooming = true;

    long now = System.currentTimeMillis();
    float currentMs = Math.min( durationMs, now - startTime );
    float newScale = (float) mEasing.easeInOut( currentMs, 0, deltaScale, durationMs );

    zoomTo( oldScale + newScale, destX, destY );

    if ( currentMs < durationMs ) {
      mHandler.post( this );
    } else {
      onZoomAnimationCompleted( getScale() );
      scrollBy( dx, dy, durationMs )
    }
  }
});
mHandler.post(新的Runnable(){
@凌驾
公开募捐{
mZooming=真;
long now=System.currentTimeMillis();
float currentMs=Math.min(持续时间ms,现在-开始时间);
float newScale=(float)mEasing.easeInOut(currentMs,0,deltaScale,durationMs);
zoomTo(旧刻度+新刻度、destX、destY);
如果(当前毫秒<持续毫秒){
mHandler.post(本);
}否则{
已完成动物模型化(getScale());
滚动比(dx、dy、持续时间ms)
}
}
});
以前有人做过这样的事吗?我完全错了吗

提前谢谢