用于离屏渲染的最有用的java.awt.image.BufferedImage类型是什么?

时间:2021-03-06 16:34:04

I am creating a buffered image that is going to be a snapshot of a JComponent (via paint()) and rendered inside an ImageIcon. There are a large amount of types in the BufferedImage(int width, int height, int imageType) constructor, but which one should I use?

我正在创建一个缓冲的图像,它将成为JComponent的快照(通过paint())并在ImageIcon中呈现。 BufferedImage(int width,int height,int imageType)构造函数中有大量类型,但我应该使用哪一种?

I am sure that any of them would work, but which ones are better than the others? How should I pick one? And Why?

我相信他们中的任何一个都会奏效,但哪些比其他更好?我该怎么选一个?为什么?

1 个解决方案

#1


6  

See GraphicsConfiguration.createCompatibleImage(int, int) for a helper to create a BufferedImage of a "good" type among the many available types.

请参阅GraphicsConfiguration.createCompatibleImage(int,int),以便帮助程序在许多可用类型中创建“良好”类型的BufferedImage。

How to get your hands on a GraphicsConfiguration instance to make this call? It depends on where your code is executing. See the many methods for getting your hands on a GraphicsConfiguration via methods like getGraphicsConfiguration() or getDeviceConfiguration().

如何使用GraphicsConfiguration实例进行此调用?这取决于代码的执行位置。通过getGraphicsConfiguration()或getDeviceConfiguration()等方法,了解使用GraphicsConfiguration的许多方法。

#1


6  

See GraphicsConfiguration.createCompatibleImage(int, int) for a helper to create a BufferedImage of a "good" type among the many available types.

请参阅GraphicsConfiguration.createCompatibleImage(int,int),以便帮助程序在许多可用类型中创建“良好”类型的BufferedImage。

How to get your hands on a GraphicsConfiguration instance to make this call? It depends on where your code is executing. See the many methods for getting your hands on a GraphicsConfiguration via methods like getGraphicsConfiguration() or getDeviceConfiguration().

如何使用GraphicsConfiguration实例进行此调用?这取决于代码的执行位置。通过getGraphicsConfiguration()或getDeviceConfiguration()等方法,了解使用GraphicsConfiguration的许多方法。