在动画下旋转位图

我沿着以下代码的路径创建了一个动画。

    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
额外 编辑
意见: 1
你确实需要什么?
额外 作者 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);
}

if you want more explanation means refer this link http://xjaphx.wordpress.com/2011/06/22/image-processing-rotate-image-on-the-fly/

0
额外