Re: off-screen rendering

Hi Ramesh,

I ran your program and it produced a good visadImage.png file
on my Sparc Solaris machine. It is possible that your difficulty
is related to the problem with offscreen rendering on Linux that
Luke Matthews is working on. When he reports the reults of his
work that may also solve your problem.

Cheers,
Bill

On Mon, 22 Sep 2003, Mantri, Mr. Ramesh wrote:

> I am a newbie to VisAD. I am trying out one of the first examples with a 
> slight
> modification. I am trying to render the image off-scrren, that is write out 
> the
> image to a file. I tried a bunch of things but could not get it to work 
> completely.
> The image is written to file, but apparently it isn't complete. Please find 
> the code
> below. Appreciate any help. (Also, please CC your reply to 
> rsm0001@xxxxxxxxxxxx).
> sincerely,
> Ramesh Mantri
>
> import visad.*;
> import visad.java2d.DisplayImplJ2D;
> import java.rmi.RemoteException;
> import java.awt.*;
> import javax.swing.*;
>
> import com.sun.image.codec.jpeg.*;
> import java.io.*;
> import javax.imageio.ImageIO;
> import java.awt.image.BufferedImage;
>
> public class WriteImage {
>    private RealType time, height;
>    private FunctionType func_time_height;
>
>    private Set time_set;
>    private FlatField vals_ff;
>    private DataReferenceImpl data_ref;
>
>    private DisplayImpl display;
>    private ScalarMap timeMap, heightMap;
>
> public WriteImage(String[] args) throws RemoteException, VisADException {
>       time = new RealType("time");
>       height = new RealType("height");
>
>       func_time_height = new FunctionType(time, height);
>       time_set = new Integer1DSet(time, 5);
>
>       float[][] h_vals = new float[][] {{0.0f, 13.75f, 45.0f, 33.75f, 0.0f,}};
>
>       vals_ff = new FlatField(func_time_height, time_set);
>       vals_ff.setSamples(h_vals);
>
>       //display = new DisplayImplJ2D("display1");
>       display = new DisplayImplJ2D("display1", 450, 450);
>
>       timeMap = new ScalarMap(time, Display.XAxis);
>       heightMap = new ScalarMap(height, Display.YAxis);
>
>       display.addMap(timeMap);
>       display.addMap(heightMap);
>
>       data_ref = new DataReferenceImpl("data_ref");
>       data_ref.setData(vals_ff);
>
>       display.addReference(data_ref);
>    }
>
>    public void writeToFile() throws IOException {
>       BufferedImage image = display.getImage(true);
>       File file = new File("visadImage.png");
>       ImageIO.write(image, "PNG", file);
>    }
>
>    public static void main(String[] args) {
>       try {
>          WriteImage imgObj = new WriteImage(args);
>          imgObj.writeToFile();
>          //System.exit(0);
>       } catch (Exception e) {
>          e.printStackTrace();
>       }
>    }
> }
>
>


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