Hi Karan,
> I have a grid created and i want to save it to the
> file which is of either *.gif or *.jpeg format and
> then open it when required.
>
> I have created a grid on canvas which is added to the
> JDialog. I want to save it either in *.gif or *.jpeg
> format. I tried to do something like this.
>
> public void convertGridToImage() {
> BufferedImage image = display.getImage();
> try {
> JPEGEncodeParam param
> JPEGCodec.getDefaultJPEGEncodeParam(image);
> param.setQuality(1.0f, true);
> FileOutputStream fout = new
> FileOutputStream("c:/newtry.gif");
> JPEGImageEncoder encoder
> JPEGCodec.createJPEGEncoder(fout);
> encoder.encode(image, param);
> fout.close();
> }
> catch (NoClassDefFoundError err) {
> throw new VisADException("JPEG codec not
> found");
> }
>
> }
>
> it gives the exception at this place
> display.getImage();
What Exception??? Is it "VisADError: cannot call getImage() from Thread: ..."?
Always be as specific as possible.
> I checked the captureImage() method in BasicSSCell
> class, but these examples are too complicated for a
> person who is still learning VisAD.
Its not so hard. If you are calling getImage() from a callback,
you need to put it in its own thread, as seen in the
FancySSCell.captureDialog() method.
Good luck,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html