Re: Printing the contents of a display

Hello Shin-ta,

Like Bill, I'm not sure why you are seeing the TYPE_USHORT_565_RGB.
If it helps, here is some code that Ugo Taddei sent me for saving
a display to a JPEG format.  The com.sun.image.codec.jpeg included
in Java 2 has classes for encoding and decoding JPEG images.  You
could always convert the JPEG to GIF if you needed to.

------- Forwarded Message


Hi Don,

not quite what you wanted, but the following fragment will save a
display to a file, using a JfileChooser 

      try{
            
            JFileChooser fc= new JFileChooser();
            fc.setDialogTitle("Save screenshot as Jpeg");
            fc.setCurrentDirectory(new File(curDir) );
            if(fc.showDialog(cframe, "Save") == JFileChooser.APPROVE_OPTION) {
              System.out.println("Saving image..." );
            String cfn = fc.getSelectedFile().getName(); 
            curDir = fc.getCurrentDirectory().getName(); 
            
            BufferedImage image = display1.getImage();
            FileOutputStream fout = new FileOutputStream(cfn);
            JPEGEncodeParam jepar = JPEGCodec.getDefaultJPEGEncodeParam(image);
            jepar.setQuality( 1.0f, true);
            
            JPEGImageEncoder jpege = JPEGCodec.createJPEGEncoder(fout) ;
            jpege.encode(image, jepar);
            fout.close(); 
            System.out.println("Saved "+cfn);
            } else {
                System.out.println("No file was chosen or an error occurred");
            } 
            
           
            } catch (IOException ioe) { System.err.println(ioe.getMessage() );
            }
        
Hope it helps...

Ugo
------- End of Forwarded Message

Thanks, Ugo!

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
*************************************************************
Unidata WWW Server               http://www.unidata.ucar.edu/
McIDAS Demonstration Machine  http://mcdemo.unidata.ucar.edu/
*************************************************************