通过我的调查并阅读了Sun / Oracle 2D教程,我发现了以下内容:
要创建加速图像,可以使用易失性图像(将其创建为pbuffer)。有优点也有缺点,在您尝试获取栅格像素数据之前,VolatileImages很快。在那一刻,它们成为普通的bufferedImage。而且它们是易变的,并且不能保证在渲染结束时将可用。为此,您执行:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();VolatileImage vImage = gc.createCompatibleVolatileImage(width, height, Transparency.TRANSLUCENT);
这将为您提供加速的图像,但是无法使用ImageIO直接将其写入以表示PNG文件。
为了使用普通的BufferedImage,您需要执行以下操作:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();BufferedImage img = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);img.setAccelerationPriority(1);
这将创建一个BufferedImage,它不会被加速,但是您可以通过在setAccelerationPriority中传递1来向JVM提供提示。您可以在Java
Tutorial的2D路径上阅读此内容。



