-4

I have a JFrame, and periodically I paint a PNG image on screen using paintComponent. The image rotates following the mouse pointer. When the image rotates the quality it's just terrible (in the photo).

The PNG is 20x10 pixels.

Photo Quality

What to do?

//Rotating System
backup = g2d.getTransform();
a = AffineTransform.getRotateInstance(Math.toRadians(turret.angle), turret.x, turret.y);
g2d.setTransform(a);
g2d.drawImage(turret.sprite, (int) turret.x - 6, (int) turret.y - 15, null);
g2d.setTransform(backup);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Dave02
  • 3
  • 1
  • 1) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 2) One way to get image(s) for an example is to hot link to images seen in [this Q&A](http://stackoverflow.com/q/19209650/418556). – Andrew Thompson Mar 10 '18 at 17:35
  • if quality is your concern either use higher resolution images and anti aliasing or use vector graphics instead ... – Spektre Mar 11 '18 at 08:50

1 Answers1

0

Not sure it will help but you can try changing some of the Graphics properties. For example:

g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
camickr
  • 321,443
  • 19
  • 166
  • 288