public static void writeAsPNG(Drawable drawable,int w,int h,File file) throws FileNotFoundException, IOException {
  BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2=image.createGraphics();
  drawable.draw(g2,new Rectangle(w,h));
  OutputStream out=new BufferedOutputStream(new FileOutputStream(file));
  try {
    ImageIO.write(image,"png",out);
  }
  finally {
    out.close();
  }
}

public static void writeAsPNG ( Drawable drawable , int w , int h , File file ) throws FileNotFoundException , IOException { BufferedImage image = new BufferedImage ( w , h , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g2 = image . createGraphics ( ) ; drawable . draw ( g2 , new Rectangle ( w , h ) ) ; OutputStream out = new BufferedOutputStream ( new FileOutputStream ( file ) ) ; try { ImageIO . write ( image , "png" , out ) ; } finally { out . close ( ) ; } }
writes the current content to the specified file in png format .
