Re: Problem with off-screen render

If I create a JFrame and make it visible, then the off-screen
render works, i.e. if I add these two lines before the getImage(true) call:
   new javax.swing.JFrame().setVisible(true);
then, the program runs to completion.

Does VisAD *require* a visible component
in order to do an off-screen render?


Valliappa Lakshmanan wrote:

I'm not able to get off-screen rendering to work consistently.

I modified the main() method in the 3D canvas class.
The following code hangs on the line "display.getImage(true)".
Interestingly, it worked once, and then started to hang on subsequent
runs of the same program, so I'm wondering if there is some
resource that I need to get rid of properly.

I'm doing this on Windows with Java 1.4 and Java3D 1.3.1 and
the latest pre-compiled visad.jar file from the SSEC website.



package gov.noaa.nssl.wdssii.display;

import visad.*;

import visad.java3d.DisplayImplJ3D;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;

public class TestOffScreen {

        public static void main(String[] args) throws Exception {
            DisplayImplJ3D display = new DisplayImplJ3D("offscreen", 300, 300);

            RealType[] types = {RealType.Latitude, RealType.Longitude};
            RealTupleType earth_location = new RealTupleType(types);
            RealType vis_radiance = RealType.getRealType("vis_radiance");
            RealType ir_radiance = RealType.getRealType("ir_radiance");
            RealType[] types2 = {vis_radiance, ir_radiance};
            RealTupleType radiance = new RealTupleType(types2);
            FunctionType image_tuple = new FunctionType(earth_location, 

            int size = 32;
            FlatField imaget1 = FlatField.makeField(image_tuple, size, false);

            display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
            display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
            display.addMap(new ScalarMap(vis_radiance, Display.RGB));

            DataReferenceImpl ref_imaget1 = new 
            display.addReference(ref_imaget1, null);
System.out.println("set up the display okay"); // get image with sync
            BufferedImage image = display.getImage(true);
            System.out.println("Got image from display");
// write image ImageWriter writer = (ImageWriter) ImageIO.getImageWritersByFormatName("jpg").next();
       of = new"test.jpg");
                writer.setOutput( ImageIO.createImageOutputStream(of) );
                System.out.println("File test.jpg written out.");

  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: