private void translateMatrixAfterRotate(int axis,float trans,float prevImageSize,float imageSize,int prevViewSize,int viewSize,int drawableSize){
  if (imageSize < viewSize) {
    m[axis]=(viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
  }
 else   if (trans > 0) {
    m[axis]=-((imageSize - viewSize) * 0.5f);
  }
 else {
    float percentage=(Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
    m[axis]=-((percentage * imageSize) - (viewSize * 0.5f));
  }
}

private void translateMatrixAfterRotate ( int axis , float trans , float prevImageSize , float imageSize , int prevViewSize , int viewSize , int drawableSize ) { if ( imageSize < viewSize ) { m [ axis ] = ( viewSize - ( drawableSize * m [ Matrix . MSCALE_X ] ) ) * 0.5f ; } else if ( trans > 0 ) { m [ axis ] = - ( ( imageSize - viewSize ) * 0.5f ) ; } else { float percentage = ( Math . abs ( trans ) + ( 0.5f * prevViewSize ) ) / prevImageSize ; m [ axis ] = - ( ( percentage * imageSize ) - ( viewSize * 0.5f ) ) ; } }
after rotating , the matrix needs to be translated . this function finds the area of image which was previously centered and adjusts translations so that is again the center , post - rotation .
