Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有图像的 RGB 数据,IntBuffer并希望通过绘画将其显示到JPanel. 最有效的方法是什么?
IntBuffer
JPanel
编辑
我目前正在通过以下代码将数据绘制到 aBufferedImage上,但想知道是否存在更快的方法:
BufferedImage
Raster raster= image.getData(); intBuffer.get( ((DataBufferInt) raster.getDataBuffer()).getData() ); image.setData(raster);
BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB); int[] rgb = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();
然后只需将 IntBuffer 的内容复制到 rgb 数组中并绘制 BufferedImage。对数组的任何更改都会直接更改图像。当然,图像需要具有正确的尺寸。