Hi Silvano,

> I would like to know how I can get the canvas 3D image and to trasform It in a
> image(bmp or jpg)?

Here is the code I use.  Hope it helps.

Hugh


     /**
     * generates a BufferedImage containing the content of the Canvas3D
     *
     * @param Canvas3D canvas
     * @return The BufferedImage
     */
  public static BufferedImage createBufferedImageFromCanvas3D(Canvas3D
canvas)
  {
    canvas.waitForOffScreenRendering();

    GraphicsContext3D  ctx = canvas.getGraphicsContext3D();
    int w = canvas.getWidth();
    int h = canvas.getHeight();

    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);

    ImageComponent2D im = new ImageComponent2D(ImageComponent.FORMAT_RGB, bi);

    Raster ras = new Raster(new Point3f( -1.0f, -1.0f, -1.0f ),
                            Raster.RASTER_COLOR, 0, 0, w, h, im, null );

    ctx.flush(true);

    ctx.readRaster( ras );

    return ras.getImage().getImage();
  }

and then to write the file -

ImageIO.write(image, format, file);

where file is a File object, and format is a string, for example @jpeg"

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to