Class ImageScaler


  • public final class ImageScaler
    extends Object
    Allows to scale images efficiently and with high quality.
    • Method Detail

      • scale

        public static BufferedImage scale​(Image sourceImage,
                                          int targetWidth,
                                          int targetHeight)
        Convenience method that returns a scaled instance of the provided image. Uses a multi-step approach for best results.
        Parameters:
        sourceImage - the original image to be scaled
        targetWidth - the desired width of the scaled instance, in pixels
        targetHeight - the desired height of the scaled instance, in pixels
        Returns:
        a scaled version of the original image
      • scale

        public static BufferedImage scale​(BufferedImage sourceImage,
                                          int targetWidth,
                                          int targetHeight,
                                          Object hint,
                                          boolean progressiveBilinear)
        Convenience method that returns a scaled instance of the provided BufferedImage.
        Parameters:
        sourceImage - the original image to be scaled
        targetWidth - the desired width of the scaled instance, in pixels
        targetHeight - the desired height of the scaled instance, in pixels
        hint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)
        progressiveBilinear - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in down-scaling cases, where targetWidth or targetHeight is smaller than the original dimensions)
        Returns:
        a scaled version of the original BufferedImage