Re: Export the Display

Hi Larsson,

>How can i export the display to ps (postscript),eps
>and my data that draw the display to a ascii file

VisAD does not currently have built-in support for PS or EPS,
and its ASCII support is limited to import only.  However,
there are many other formats that it does support (see for a
complete list).  Among those that support data export are
netCDF, TIFF, Bio-Rad, QuickTime and VisAD binary format.

If you wish to take a snapshot of the display itself, you
can use DisplayImpl.getImage() to obtain an Image object,
which you can export to a JPEG (or other image file format).

Here is some code to export a display snapshot to JPEG:

    import com.sun.image.codec.jpeg.*;
    DisplayImpl display = ...;
    BufferedImage image = display.getImage();
    JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(image);
    param.setQuality(1.0f, true);
    FileOutputStream fout = new FileOutputStream(f);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fout);
    encoder.encode(image, param);

If you would prefer to save your actual data rather than
a display snapshot, you could export your data to TIFF format:

    DataImpl d = ...;
    TiffForm saver = new TiffForm();
    saver.write("data.tiff", d, false);

In either case, you could then use an image editor/viewer program
to convert the TIFF or JPEG file to PS or EPS.

Lastly, if you want VisAD to directly support PS or EPS, you could
find some Java code to read and write these formats and write a
file form adapter.  Subpackages of provide many examples
of such implementations.


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