Class JImageLoader

java.lang.Object
org.sm.smtools.swing.util.JImageLoader

public final class JImageLoader extends Object
The JImageLoader helper class provides functionality for loading images.

Note that a valid I18NL10N database must be available!

Note that this class cannot be subclassed!

Version:
13/03/2020
Author:
Sven Maerivoet
  • Method Details

    • loadImageIcon

      public static ImageIcon loadImageIcon(String filename, Component caller) throws FileReadException
      Helper method to load an image from a specified file.
      Parameters:
      filename - the name of the image file to load
      caller - the object that called this method
      Returns:
      an ImageIcon object containing the loaded image
      Throws:
      FileReadException - if an error occurred during the loading of the image
    • loadImage

      public static BufferedImage loadImage(String filename) throws FileReadException
      Helper method to load an image from a specified file.
      Parameters:
      filename - the name of the image file to load
      Returns:
      an BufferedImage object containing the loaded image
      Throws:
      FileReadException - if an error occurred during the loading of the image
    • rescaleImageWH

      public static BufferedImage rescaleImageWH(BufferedImage image, int width, int height)
      Helper method to efficiently rescale an image to an arbitrary width and height.
      Parameters:
      image - the image to rescale
      width - the new width of the image
      height - the new height of the image
      Returns:
      a rescaled version of the original image
    • rescaleImageW

      public static BufferedImage rescaleImageW(BufferedImage image, int width)
      Helper method to efficiently rescale an image to an arbitrary width and keeping the aspect ratio for the height.
      Parameters:
      image - the image to rescale
      width - the new width of the image (its new height is automatically calculated)
      Returns:
      a rescaled version of the original image
    • rescaleImageH

      public static BufferedImage rescaleImageH(BufferedImage image, int height)
      Helper method to efficiently rescale an image to an arbitrary height and keeping the aspect ratio for the width.
      Parameters:
      image - the image to rescale
      height - the new height of the image (its new width is automatically calculated)
      Returns:
      a rescaled version of the original image
    • rescaleImageWH

      public static BufferedImage rescaleImageWH(BufferedImage image, double widthFactor, double heightFactor)
      Helper method to efficiently rescale an image with arbitrary width and height factors.
      Parameters:
      image - the image to rescale
      widthFactor - the width factor of the image
      heightFactor - the height factor of the image
      Returns:
      a rescaled version of the original image
    • rescaleImageW

      public static BufferedImage rescaleImageW(BufferedImage image, double widthFactor)
      Helper method to efficiently rescale an image with an arbitrary width factor and keeping the aspect ratio for the height.
      Parameters:
      image - the image to rescale
      widthFactor - the width factor of the image (its new height is automatically calculated)
      Returns:
      a rescaled version of the original image
    • rescaleImageH

      public static BufferedImage rescaleImageH(BufferedImage image, double heightFactor)
      Helper method to efficiently rescale an image with an arbitrary height factor and keeping the aspect ratio for the width.
      Parameters:
      image - the image to rescale
      heightFactor - the height factor of the image (its new width is automatically calculated)
      Returns:
      a rescaled version of the original image
    • convertImageToBufferedImage

      public static BufferedImage convertImageToBufferedImage(Image image)
      Converts a given Image into a BufferedImage
      Parameters:
      image - the image to be converted
      Returns:
      the converted BufferedImage