0

I have simple drawing canvas like this:

public class DrawingCanvas extends JPanel

    private BufferedImage image;

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);


            image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB);

            Graphics2D g2 = (Graphics2D) image.getGraphics();

            // draw some items....                

            g2.dispose();
            g.drawImage(image, 0, 0, null);
   }
}

I want to ask you, if I can set some render quality?

For example Antialiasing.. I want use BEST render quality.

How ?

chelocre
  • 73
  • 1
  • 2
  • 9
  • There's no reason to draw to a BufferedImage. JPanel is already double-buffered. – VGR Mar 30 '16 at 19:44
  • *"I want use BEST render quality."* - That's actually depended on a number of factors and the rendering hints on one machine won't always work on others :P – MadProgrammer Mar 30 '16 at 20:59
  • For [example](http://stackoverflow.com/questions/13906687/how-can-i-smooth-my-jframe-shape/13906713#13906713) and [example](http://stackoverflow.com/questions/25577856/rotating-ball-loses-sharpness-and-colors/25581053#25581053) – MadProgrammer Mar 30 '16 at 21:01

1 Answers1

1

Have a look at RenderingHints. You can set them with calling g2.setRenderingHint(RenderingHints.Key hintKey, Object hintValue).

With this you can alter different settings for the render quality, like (text)anti-aliasing, alpha-interpolation etc.

For anti-aliasing:

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)

The other keys and values are pretty self-explanatory.

Yodabyte
  • 36
  • 3