📜  在 android 绘图中旋转位图 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:05.993000             🧑  作者: Mango

代码示例1
Matrix rotator = new Matrix();

// rotate around (0,0)
rotator.postRotate(90);

// or, rotate around x,y
// NOTE: coords in bitmap-space!
int xRotate = ...
int yRotate = ...
rotator.postRotate(90, xRotate, yRotate);

// to set the position in canvas where the bitmap should be drawn to;
// NOTE: coords in canvas-space!
int xTranslate = ...
int yTranslate = ...
rotator.postTranslate(xTranslate, yTranslate);

canvas.drawBitmap(bitmap, rotator, paint);