Class JImageLoader

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

public final class JImageLoader
extends java.lang.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 Summary

    Modifier and Type Method Description
    static java.awt.image.BufferedImage convertImageToBufferedImage​(java.awt.Image image)
    Converts a given Image into a BufferedImage
    static java.awt.image.BufferedImage loadImage​(java.lang.String filename)
    Helper method to load an image from a specified file.
    static javax.swing.ImageIcon loadImageIcon​(java.lang.String filename, java.awt.Component caller)
    Helper method to load an image from a specified file.
    static java.awt.image.BufferedImage rescaleImageH​(java.awt.image.BufferedImage image, double heightFactor)
    Helper method to efficiently rescale an image with an arbitrary height factor and keeping the aspect ratio for the width.
    static java.awt.image.BufferedImage rescaleImageH​(java.awt.image.BufferedImage image, int height)
    Helper method to efficiently rescale an image to an arbitrary height and keeping the aspect ratio for the width.
    static java.awt.image.BufferedImage rescaleImageW​(java.awt.image.BufferedImage image, double widthFactor)
    Helper method to efficiently rescale an image with an arbitrary width factor and keeping the aspect ratio for the height.
    static java.awt.image.BufferedImage rescaleImageW​(java.awt.image.BufferedImage image, int width)
    Helper method to efficiently rescale an image to an arbitrary width and keeping the aspect ratio for the height.
    static java.awt.image.BufferedImage rescaleImageWH​(java.awt.image.BufferedImage image, double widthFactor, double heightFactor)
    Helper method to efficiently rescale an image with arbitrary width and height factors.
    static java.awt.image.BufferedImage rescaleImageWH​(java.awt.image.BufferedImage image, int width, int height)
    Helper method to efficiently rescale an image to an arbitrary width and height.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • loadImageIcon

      public static javax.swing.ImageIcon loadImageIcon​(java.lang.String filename, java.awt.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 java.awt.image.BufferedImage loadImage​(java.lang.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 java.awt.image.BufferedImage rescaleImageWH​(java.awt.image.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 java.awt.image.BufferedImage rescaleImageW​(java.awt.image.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 java.awt.image.BufferedImage rescaleImageH​(java.awt.image.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 java.awt.image.BufferedImage rescaleImageWH​(java.awt.image.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 java.awt.image.BufferedImage rescaleImageW​(java.awt.image.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 java.awt.image.BufferedImage rescaleImageH​(java.awt.image.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 java.awt.image.BufferedImage convertImageToBufferedImage​(java.awt.Image image)
      Converts a given Image into a BufferedImage
      Parameters:
      image - the image to be converted
      Returns:
      the converted BufferedImage