
As you can see above, I have an image of a game I've been working on using Java. Using AWT I added the following:
public static void drawImageRotated(
Graphics2D g2d, BufferedImage img, double x, double y, int scale, double angle) {
BufferedImage image = new BufferedImage(
(int)(img.getWidth() * 1.5D),
(int)(img.getHeight() * 1.5D),
2);
Graphics2D g = (Graphics2D)image.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.rotate(Math.toRadians(angle), image.getWidth() / 2, image.getHeight() / 2);
g.drawImage(img,
image.getWidth() / 2 - img.getWidth() / 2,
image.getHeight() / 2 - image.getHeight() / 2,
null);
g2d.drawImage(image,
(int)x-(image.getWidth()*scale/2),
(int)y-(image.getHeight()*scale/2),
image.getWidth()*scale,
image.getHeight()*scale,
null);
g.dispose();
}
This is the code which draws the ships onto the screen. As you can see there is a blue and a cyan ship on the screen, the blue ship's rotation being 0 and the cyan having a rotation of just over 270 degrees. The cyan ship is distorted and that's what I want to get rid of. Is there an anti-aliasing for small images like that one (16x16)?
g.drawImagecall. Shouldn't the y position beimage.getHeight()/2 - img.getHeight()/2? – mmyers Feb 1 at 17:00