I have a JPanel that paints an Image
of a dice (java.awt.Image). I would like to rotate this image, but whenever it is rotated its edges become pixelated:
Rotated and not rotated images. The pixelation is even more visible than these images show.
Here is the paintComponent
method:
public void paintComponent(Graphics g) {
Graphics2D dicePainter = (Graphics2D) g;
dicePainter.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int width = getWidth() / 2;
int height = getHeight() / 2;
dicePainter.rotate(-Math.PI / 3, width, height);
super.paintComponent(g);
dicePainter.drawImage(diceImage, 30, 15, ViewConstants.DICE_IMAGE_WIDTH, ViewConstants.DICE_IMAGE_WIDTH, this);
}
Is there anyway to improve the rendering when the image is rotated? I am thinking it is actually due to my screen resolution, rather than the Java image rendering as the more angled lines in the map also appear more pixelated than others.