public static BufferedImage createImage(ImageProducer producer){
  PixelGrabber pg=new PixelGrabber(producer,0,0,-1,-1,null,0,0);
  try {
    pg.grabPixels();
  }
 catch (  InterruptedException e) {
    throw new RuntimeException("Image fetch interrupted");
  }
  if ((pg.status() & ImageObserver.ABORT) != 0)   throw new RuntimeException("Image fetch aborted");
  if ((pg.status() & ImageObserver.ERROR) != 0)   throw new RuntimeException("Image fetch error");
  BufferedImage p=new BufferedImage(pg.getWidth(),pg.getHeight(),BufferedImage.TYPE_INT_ARGB);
  p.setRGB(0,0,pg.getWidth(),pg.getHeight(),(int[])pg.getPixels(),0,pg.getWidth());
  return p;
}

public static BufferedImage createImage ( ImageProducer producer ) { PixelGrabber pg = new PixelGrabber ( producer , 0 , 0 , - 1 , - 1 , null , 0 , 0 ) ; try { pg . grabPixels ( ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "Image fetch interrupted" ) ; } if ( ( pg . status ( ) & ImageObserver . ABORT ) != 0 ) throw new RuntimeException ( "Image fetch aborted" ) ; if ( ( pg . status ( ) & ImageObserver . ERROR ) != 0 ) throw new RuntimeException ( "Image fetch error" ) ; BufferedImage p = new BufferedImage ( pg . getWidth ( ) , pg . getHeight ( ) , BufferedImage . TYPE_INT_ARGB ) ; p . setRGB ( 0 , 0 , pg . getWidth ( ) , pg . getHeight ( ) , ( int [ ] ) pg . getPixels ( ) , 0 , pg . getWidth ( ) ) ; return p ; }
cretae a bufferedimage from an imageproducer .
