public static BufferedImage convertToBufferedImage(Image awtImg,int type){
  BufferedImage bimg;
  if (awtImg instanceof BufferedImage) {
    bimg=(BufferedImage)awtImg;
  }
 else {
    bimg=createCompatibleBufferedImage(awtImg.getWidth(null),awtImg.getHeight(null),type);
    Graphics2D g=bimg.createGraphics();
    g.drawImage(awtImg,0,0,null,null);
    g.dispose();
  }
  return bimg;
}

public static BufferedImage convertToBufferedImage ( Image awtImg , int type ) { BufferedImage bimg ; if ( awtImg instanceof BufferedImage ) { bimg = ( BufferedImage ) awtImg ; } else { bimg = createCompatibleBufferedImage ( awtImg . getWidth ( null ) , awtImg . getHeight ( null ) , type ) ; Graphics2D g = bimg . createGraphics ( ) ; g . drawImage ( awtImg , 0 , 0 , null , null ) ; g . dispose ( ) ; } return bimg ; }
utility method to convert an awt image to a bufferedimage . size is preserved , bufferedimage is compatible with current display device .
