NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: converting display to jpeg or gif file

  • To: "Tom Whittaker" <tomw@xxxxxxxxxxxxx>, "Yakup Bayram" <ybayram@xxxxxxxx> via smtpd (for tecsun1.tec.army.mil [199.123.87.41]) with SMTP; 8 Feb 2002 00:00:14 UT
  • Subject: Re: converting display to jpeg or gif file
  • From: "Luke Catania \(TEC\)" <lcatania@xxxxxxxxxxxx>
  • Date: Thu, 7 Feb 2002 19:09:54 -0500
Using the the visad.util.Util.captureDisplay(DisplayImpl disp, String
filename)  routine seems a heck of a lot simpler than the way I was informed
when I had a similar question several months back.  Is the captureDisplay
utility new???  I did the following in my code.

Luke


 public void captureDialog(String file) {
        final File f = new File(file);
        if (f == null) return;
        Runnable captureImage = new Runnable() {
            public void run() {
                String msg = "Could not save image snapshot to file \"" +
f.getName() +
                "\" in JPEG format. ";
                    saveAsJPEG(f);
            }
        };
        Thread t = new Thread(captureImage);
        t.start();
    }

void saveAsJPEG(File f) {
        BufferedImage image = display.getImage();
        FileOutputStream fout;
        try {
            JPEGEncodeParam param
JPEGCodec.getDefaultJPEGEncodeParam(image);
            param.setQuality((float)1.0, true);
            fout = new FileOutputStream(f);
            JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(fout);
            encoder.encode(image, param);
           fout.close();
        }
        catch (RemoteException err) {
        }
        catch (FileNotFoundException err) {
        }
        catch (IOException err) {
        }
  }
----- Original Message -----
From: "Tom Whittaker" <tomw@xxxxxxxxxxxxx>
To: "Yakup Bayram" <ybayram@xxxxxxxx>
Sent: Wednesday, February 06, 2002 9:55 AM
Subject: Re: converting display to jpeg or gif file


> On Wed, 6 Feb 2002, Yakup Bayram wrote:
>
> > Hello,
> > I am using Visad to display Antenna Array pattern.
> > I need to save the array pattern display as gif , jpeg or bmp. Is there
any way of doing this in java?
> > Thanks
>
> The static method:
>
> visad.util.Util.captureDisplay(DisplayImpl disp, String filename)
>
> will take the contents of the 'disp' and save it to 'filename' in
> JPEG format.
>
> tom
>
> --
> Tom Whittaker
> University of Wisconsin-Madison
> Space Science and Eng. Center
> ph:  608.262.2759
>
>


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