旋转位图在Android画布 [英] Rotate Bitmap on Android Canvas

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

问题描述

我有我画到画布作为SurfaceView的一部分某些对象。我希望能够以编程方式旋转这些,例如: myParticle.setRotation(90); 这是我的(简化)code绘制粒子的那一刻:

 公共类粒子{

  公共无效画(油画画布){
    image.setBounds((int)的(XPOS),(int)的(yPos),(int)的(XPOS +半径),(int)的(+ yPos半径));
    image.draw(画布);
  }

}
 

解决方案

您只需要调用

canvas.rotate(90):) // 90度。

I have some objects which I draw onto a Canvas as part of a SurfaceView. I want to be able to rotate these programmatically, e.g. myParticle.setRotation(90); Here's my (simplified) code to draw the Particle at the moment:

public class Particle {

  public void draw(Canvas canvas){
    image.setBounds((int)(xPos), (int)(yPos), (int)(xPos+radius), (int)(yPos+radius));
    image.draw(canvas);
  }

}

解决方案

You just have to call

canvas.rotate(90) :) // 90 is degree.

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

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