2016-12-21 12 views

答えて

0

私は、脳のストーミングが大量になった後、望ましい行動を達成しました。アイデアは、画像の前のマトリックスとズームスケールを保存し、画像に以前に保存されたマトリックスを設定することです。 以前の値の取得:

@Override 
public boolean onPreDraw() 
{ 
    photoView.getViewTreeObserver().removeOnPreDrawListener(this); 
    Matrix theMatrix = photoView.getDisplayMatrix(); 
    Log.d("***", "onPreDraw: TransX = " + previousValues[2] + "TransY = " + previousValues[5]); 
    float[] matrixValues = new float[9]; 
    matrixValues[0] = previousZoomLevel; // 0 and 4 store the scaleX and scaleY 
    matrixValues[4] = previousZoomLevel; 
    if (previousZoomLevel == MIN_ZOOM_LEVEL) // Zoom Level starts from 1.0 to 16.0 
    { 
     matrixValues[2] = 0; //2 and 5 store store TransX and TransY 
     matrixValues[5] = 0; 
    } else 
    { 
     matrixValues[2] = previousValues[2]; 
     matrixValues[5] = previousValues[5]; 
    } 

    Log.d("***", "onPreDraw: NEW.. TransX = " + matrixValues[2] + "TransY = " + matrixValues[5]); 
    matrixValues[8] = 1.0f; 
    theMatrix.setValues(matrixValues); 
    prescription.setDisplayMatrix(theMatrix); 

    Matrix theImageViewMatrix = photoView.getDisplayMatrix(); 
    prescription.setImageMatrix(theImageViewMatrix); 
    return true; 
} 

・ホープこれは誰かに役立ちます:

Matrix previousImageMatrix = photoView.getDisplayMatrix(); 
previousImageMatrix.getValues(previousValues); 
previousZoomLevel = prescription.getScale(); 

今すぐphotoView.getViewTreeObserver().addOnPreDrawListener(this);を添付した画像は、このようなonPreDraw()方法ズームされたときに上記の行列を読み込みます。

関連する問題