public static BufferedImage createCompatibleImage (BufferedImage source, int width, int height)
    {
        WritableRaster raster = source.getRaster().createCompatibleWritableRaster(width, height);
        return new BufferedImage(source.getColorModel(), raster, false, null);
    }
public static BufferedImage createCompatibleImage ( BufferedImage source , int width , int height ) { WritableRaster raster = source . getRaster ( ) . createCompatibleWritableRaster ( width , height ) ; return new BufferedImage ( source . getColorModel ( ) , raster , false , null ) ; }
Creates a new buffered image with the same sample model and color model as the source image
but with the new width and height.