Performance in Collecting one buffered Image of the canvas 3d
843799Oct 1 2003 — edited Oct 2 2003Hi,
I have rewrited the postswap() of a canvas 3d to collect a bufferedImage of the scenario and then sent it to another aplication.
The program is working but im having a problem with the performance:
I discovered that the method readRaster(Raster r) from graphicsContext3d takes 200ms in Suse Linux 1,8Ghz to retrieve the raster image and that is to slow for the application.
I would like to know if someone knows why these method is so slow, if i can make it faster or if someone knows a better and fast way to get a bufferedImage of one canvas 3d?
this is the code :
public void postSwap()
{
GraphicsContext3D ctx = getGraphicsContext3D();
Rectangle rect = this.getBounds();
BufferedImage img = new BufferedImage(rect.width,rect.height,
BufferedImage.TYPE_INT_RGB);
ImageComponent2D comp =
new ImageComponent2D(ImageComponent.FORMAT_RGB, img, true, false);
Raster ras = new Raster(new Point3f(-1.0f,-1.0f,-1.0f),
Raster.RASTER_COLOR,
0,
0,
rect.width,
rect.height,
comp,
null);
ctx.readRaster(ras);
// Now strip out the image info
BufferedImage output_img = ras.getImage().getImage();
SendImage(output_img);
}