2012-05-24 35 views
1

我沿着以下代码的路径创建了一个动画。在动画下旋转位图

public void doAnimation(){ 
     Matrix mxTransform=new Matrix(); 
     PathMeasure pm=new PathMeasure(path,false); 
     float fSegmentLen = (float)((pm.getLength())/50); 
     if(iCurStep<=50){ 
      pm.getMatrix(fSegmentLen * iCurStep, mxTransform, 
        PathMeasure.POSITION_MATRIX_FLAG + PathMeasure.TANGENT_MATRIX_FLAG); 
      canvas.drawBitmap(bt, mxTransform, null); 
      iCurStep++; 
      invalidate(); 
     } 
     else{    
      iCurStep=0; 
      animate=0; 
      canvas.drawPoint((float)range-10,0f,forPoint); 
     } 
    } 

现在我想在使用drawBitmap()方法绘制它时旋转代码中的位图。提前致谢。

+0

什么是你的确切需要什么? – Aerrow

回答

1

对于旋转图像,你可以使用下面的代码

public static Bitmap rotate(Bitmap src, float degree) { 
    // create new matrix 
    Matrix matrix = new Matrix(); 
    // setup rotation degree 
    matrix.postRotate(degree); 

    // return new bitmap rotated using matrix 
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); 
} 

如果你想要更多的解释意思是指该链接http://xjaphx.wordpress.com/2011/06/22/image-processing-rotate-image-on-the-fly/