question: BufferedImage scaleImage ( BufferedImage orig , double scale ) { if ( scale > 0.5 ) { int width = ( int ) ( scale * orig . getWidth ( ) ) ; int height = ( int ) ( scale * orig . getHeight ( ) ) ; BufferedImage copy = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = copy . createGraphics ( ) ; g . setRenderingHint ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BICUBIC ) ; g . drawImage ( orig , 0 , 0 , width , height , null ) ; g . dispose ( ) ; return copy ; } else if ( scale <= 0 ) { throw new IllegalArgumentException ( "Scale must be > 0, was " + scale ) ; } else { int width = orig . getWidth ( ) / 2 ; int height = orig . getHeight ( ) / 2 ; BufferedImage copy = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = copy . createGraphics ( ) ; g . setRenderingHint ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BILINEAR ) ; g . drawImage ( orig , 0 , 0 , width , height , null ) ; g . dispose ( ) ; return scaleImage ( copy , 2 * scale ) ; } }
target:  Scale an image. Downscaling is done using a multi-stage method.