public boolean saveImage(OutputStream output,String format,double scale){
  try {
    Dimension d=new Dimension((int)(scale * getWidth()),(int)(scale * getHeight()));
    BufferedImage img=getNewOffscreenBuffer(d.width,d.height);
    Graphics2D g=(Graphics2D)img.getGraphics();
    Point2D p=new Point2D.Double(0,0);
    zoom(p,scale);
    boolean q=isHighQuality();
    setHighQuality(true);
    paintDisplay(g,d);
    setHighQuality(q);
    zoom(p,1 / scale);
    ImageIO.write(img,format,output);
    return true;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return false;
  }
}

public boolean saveImage ( OutputStream output , String format , double scale ) { try { Dimension d = new Dimension ( ( int ) ( scale * getWidth ( ) ) , ( int ) ( scale * getHeight ( ) ) ) ; BufferedImage img = getNewOffscreenBuffer ( d . width , d . height ) ; Graphics2D g = ( Graphics2D ) img . getGraphics ( ) ; Point2D p = new Point2D . Double ( 0 , 0 ) ; zoom ( p , scale ) ; boolean q = isHighQuality ( ) ; setHighQuality ( true ) ; paintDisplay ( g , d ) ; setHighQuality ( q ) ; zoom ( p , 1 / scale ) ; ImageIO . write ( img , format , output ) ; return true ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } }
saves a copy of this display as an image to the specified output stream .
