本文介绍了如何使用JAVA控制渲染质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的简单绘图画布:
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?
例如Antialiasing ..我要使用 BEST 渲染质量.
For example Antialiasing.. I want use BEST render quality.
如何?
推荐答案
看看 RenderingHints .您可以通过调用g2.setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
进行设置.
Have a look at RenderingHints.You can set them with calling g2.setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
.
以此,您可以更改渲染质量的不同设置,例如(文本)抗锯齿,alpha插值等.
With this you can alter different settings for the render quality, like (text)anti-aliasing, alpha-interpolation etc.
对于抗锯齿:
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
其他键和值很不言自明.
The other keys and values are pretty self-explanatory.
这篇关于如何使用JAVA控制渲染质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!