private ImageProcessor zoom ( ImageProcessor ip , String zoomAmt ) { if ( zoomAmt != null ) { try { float zoom = Float . parseFloat ( zoomAmt ) ; if ( zoom < 0 ) { return ip ; } ip . scale ( zoom , zoom ) ; // if the image is being zoomed out, trim the extra whitespace around the image if ( zoom < 1 ) { int imgWidth = ip . getWidth ( ) ; int imgHeight = ip . getHeight ( ) ; // set a ROI around the image, minus the extra whitespace ip . setRoi ( Math . round ( imgWidth / 2 - imgWidth * zoom / 2 ) , Math . round ( imgHeight / 2 - imgHeight * zoom / 2 ) , Math . round ( imgWidth * zoom ) , Math . round ( imgHeight * zoom ) ) ; ip = ip . crop ( ) ; } } // no need to do anything with number format exception since the servlet // returns only images; just return the original image catch ( NumberFormatException e ) { } } return ip ; }
Zooms either in or out of an image by a supplied amount . The zooming occurs from the center of the image .