问题
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 ?
回答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.
来源:https://stackoverflow.com/questions/36316412/how-to-control-rendering-quality-using-java