[英]Rotating a imageView around a point to some degrees
我想围绕一个点旋转imageview。 imageview指的是可绘制资源。
然后我将imageview转换为位图,以便可以在画布上绘制它。
借助于此,我能够在画布上绘制可绘制对象
imageView = new ImageView(this);
imageView.setImageResource(drawable);
imageView.setDrawingCacheEnabled(true);
imageView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
imageView.layout(0, 0, imageView.getMeasuredWidth(), imageView.getMeasuredHeight());
imageView.buildDrawingCache(true);
Matrix matrix = new Matrix();
matrix.setRotate(30,x, y);
canvas.drawBitmap(imageView.getDrawingCache(), matrix, paint);
矩阵不起作用。 图像在点x,y处没有旋转。
谁能告诉我代码中缺少的内容?
首先平移(固定)点上的矩阵,然后分别旋转到该点。
Matrix matrix = new Matrix();
matrix.setTranslate(x,y);
matrix.postRotate(30,x, y);
canvas.drawBitmap(imageView.getDrawingCache(), matrix, paint);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.