Java Utililty Methods Image Scale

List of utility methods to do Image Scale

Description

The list of methods to do Image Scale are organized into topic(s).

Method

BufferedImagescaleImage(Image sourceImage, int width, int height)
scale Image
if (sourceImage == null)
    return null;
ImageFilter filter = new ReplicateScaleFilter(width, height);
ImageProducer producer = new FilteredImageSource(sourceImage.getSource(), filter);
Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);
return toBufferedImage(resizedImage);
ImagescaleImage(Image src, int width, int height)
scale Image
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) img.getGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(src, 0, 0, width, height, null);
g.dispose();
return img;
BufferedImageScaleToSize(Image srcImg, int w, int h)
Scale To Size
if (w == -1)
    w = srcImg.getWidth(null);
if (h == -1)
    h = srcImg.getHeight(null);
if (w == -1 || h == -1) {
    srcImg = new ImageIcon(srcImg).getImage();
    w = srcImg.getWidth(null);
    h = srcImg.getHeight(null);
...