设置位图的旋转和位置 [英] Set rotation and position of bitmap

查看:104
本文介绍了设置位图的旋转和位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何既可以更改位图的位置又可以同时旋转位图.我在画布上画画.

I would like to know how i both can change the position of a bitmap and at the same time rotate it. Im drawing at a canvas.

我当前正在使用以下代码行:

Im currently using this line of code:

canvas.drawBitmap(bitmap, posX, posY, paint);

我认为使用矩阵旋转是最好的选择? 问题在于上面发布的代码行并没有矩阵,而是一个位置.

and I think using a matrix for rotation is the best option? The problem is that the line of code, posted above, doesn't take a matrix but a position.

也有类似的代码行:

canvas.drawBitmap(bitmap, matrix, paint);

这需要一个矩阵,而不是一个位置.

This one takes a matrix but not a position.

我应该怎么做?

推荐答案

Matrix matrix = new Matrix();
matrix.SetRotate(90,pivotX,pivotY);
matrix.PostTranslate(positionX,positionY);
canvas.drawBitmap(bitmap, matrix , null);

以文字显示-旋转后设置位置.

In words - set the position after rotating.

这篇关于设置位图的旋转和位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆