Eclipse Java旋转画布问题

时间:2018-08-27 10:19:56

标签: java android eclipse canvas image-rotation

我正在用JAVA编写android应用程序。该应用程序需要拍照并旋转画布。编写代码后,画布会奇怪地旋转。

旋转前: enter image description here

旋转后: enter image description here

我的代码如下:

Canvas canvas = new Canvas(bm);

Paint p = new Paint();   
p.setColor(Color.RED);   
p.setTextSize(24);   
canvas.drawText(TimeString, bm.getWidth()-220, bm.getHeight()-10, p); 
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.rotate(90, bm.getWidth() / 2, bm.getHeight() / 2);
canvas.drawBitmap(bm, 0, 0, null);

canvas.restore();   

预期画布旋转正确: enter image description here

我不知道为什么画布会在画布中出现多位图。请问如何修改代码以显示上面的画布?

0 个答案:

没有答案