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
>
>