0
我想在surfaceview上绘制图像(从相机获取)。在绘制图像后,我想减小图像的大小,在触摸的情况下更改表面视图上的图像位置。旋转图像。目前我在表面视图上绘制图像,但剩余任务未完成。请一些身体帮助我。SurfaceView,绘制图像并缩小尺寸,旋转图像
感谢
我想在surfaceview上绘制图像(从相机获取)。在绘制图像后,我想减小图像的大小,在触摸的情况下更改表面视图上的图像位置。旋转图像。目前我在表面视图上绘制图像,但剩余任务未完成。请一些身体帮助我。SurfaceView,绘制图像并缩小尺寸,旋转图像
感谢
public void drawImage(Canvas canvas, Bitmap bitmap, int x, int y, int rotationAngle, float scalingfactor){
Matrix matrix = new Matrix();
matrix.postRotate(rotationAngle, bitmap.getWidth()/2, bitmap.getHeight()/2);
matrix.postScale(scalingfactor, scalingfactor, bitmap.getWidth()/2, bitmap.getHeight()/2);
matrix.postTranslate(x, y);
canvas.drawBitmap(bitmap, matrix, null);
}
使用上面的代码,以旋转和缩放surfaceview图像。 如果scalingfactor 1.0f表示图像大小相同。如果你想减小尺寸使用像0.5f。 rotationAngle是0到360