Matrix m = new Matrix(); m.postRotate(90); bmp = Bitmap.createBitmap(orgBmp, 0, 0, w, h, m, true);
我觉得,用Bitmp和Matrix来旋转的话是一样的,用Matrix的setRotate来旋转有两种方式 public void setRotate (float degrees)Set the matrix to rotate about (0,0) by the specified number of degrees. //以(0,0)为原点旋转 public void setRotate (float degrees, float px, float py)Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation. //以(px,py)为原点旋转就是那方法是一样的,第一个Rotate 公式 :X'=x*cos(n)+y*sin(n) Y'=-x*sin(n)+y*cos(n) 第二个Rotate和我上面说的计算方式是一样的
canvas.rotate(angle, getCenterX(),getCenterY());
Image.setBounds(bounds);
Image.draw(canvas); 这是旋转画布来实现图片旋转,以图片中心来旋转,任意一点A(ax,ay),按旋转中心点(x,y)“顺时针”旋转任意角度k度后A'的坐标计算公式
解: x'=(ax-x)*cos(k) + (ay-y)*sin(k) + x; 此为最后的横坐标
y'=-(ax-x)*sin(k) + (ay-y)*cos(k) + y; 此为最后的纵坐标
我旋转用的是Bitmap和matrix.
m.postRotate(90);
bmp = Bitmap.createBitmap(orgBmp, 0, 0, w, h, m, true);
public void setRotate (float degrees)Set the matrix to rotate about (0,0) by the specified number of degrees.
//以(0,0)为原点旋转
public void setRotate (float degrees, float px, float py)Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation.
//以(px,py)为原点旋转就是那方法是一样的,第一个Rotate
公式 :X'=x*cos(n)+y*sin(n)
Y'=-x*sin(n)+y*cos(n)
第二个Rotate和我上面说的计算方式是一样的