【发布时间】:2014-01-29 09:06:25
【问题描述】:
我正在使用以下代码来旋转我的图像
public class Field extends Canvas implements ActionListener {
@Override
public void paint(Graphics grphcs) {
super.paint(grphcs);
Graphics2D g2d = (Graphics2D) grphcs;
AffineTransform affine = new AffineTransform();
int angle = car.getAngle();
Image image = car.getCarImage();
int x = (int) car.getX();
int y = (int) car.getY();
affine.rotate(Math.toRadians(angle), x + image.getWidth(null) / 2,
y + image.getHeight(null) / 2);
g2d.setTransform(affine);
g2d.drawImage(image, x, y, null);
}
....
如果角度等于,例如 5,图像质量会丢失。
有什么问题?
【问题讨论】:
-
这可能是一个别名问题。要解决此问题,您可以启用各种类型的抗锯齿。看看这个,应该会有所帮助:weblogs.java.net/blog/campbell/archive/2007/03/….
-
1) 为了尽快获得更好的帮助,请发帖 MCVE。 2) 例如,获取图像的一种方法是热链接到this answer 中看到的图像。
标签: java image rotation awt paint