我从下面的代码中沿着路径创建了一个动画。
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()方法绘制位图时旋转代码中的位图。提前感谢罪过。
发布于 2012-05-24 16:27:03
对于旋转图像,您可以使用以下代码
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/
https://stackoverflow.com/questions/10732994
复制相似问题