java.lang.Object
com.jackmeng.halcyoninae.halcyon.utils.DeImage

public final class DeImage extends Object
This is a class that modifies images that are fed to it. It is primarily used to handle resources that are in image form.

This is a general utility class and is licensed under GPL-3.0.

Since:
2.0
Author:
Jack Meng
  • Constructor Details

    • DeImage

      private DeImage()
  • Method Details

    • imagetoBI

      public static BufferedImage imagetoBI(Image image)
      Turns an Image read raw from a stream to be enwrapped by a BufferedImage object.
      Parameters:
      image - An Image from a stream.
      Returns:
      BufferedImage A modified image that has been converted and held in a BufferedImage object.
    • applyMask

      public static BufferedImage applyMask(BufferedImage sourceImage, BufferedImage maskImage, int method)
      Combines a mask between a source image and a mask image.
      Parameters:
      sourceImage - The image to be masked.
      maskImage - The image to be used as a mask.
      method - The method to be used to combine the images.
      Returns:
      BufferedImage The combined image.
    • write

      public static void write(BufferedImage r, String path)
      Writes a BufferedImage to a file.
      Parameters:
      r - The BufferedImage to be written.
      path - The path to the file to be written.
    • resizeNoDistort

      public static BufferedImage resizeNoDistort(BufferedImage img, int newW, int newH)
      Resizes a BufferedImage by preserving the aspect ratio.
      Parameters:
      img - The BufferedImage to be resized.
      newW - The new width of the image.
      newH - The new height of the image.
      Returns:
      BufferedImage The resized image.
    • zoomToCenter

      public static BufferedImage zoomToCenter(BufferedImage img, double scaleFactor)
      Scales up an image to it's center
      Parameters:
      img - The image to be scaled up.
      scaleFactor - The scale factor.
      Returns:
      BufferedImage The scaled up image.
    • createRoundedBorder

      public static BufferedImage createRoundedBorder(BufferedImage r, int arc, Color someColor)
      Generates a rounded image with borders
      Parameters:
      r - The image to be rounded
      arc - The arc radius of the rounded corners
      someColor - The Color of the border
      Returns:
      BufferedImage The rounded image
    • imageIconToBI

      public static BufferedImage imageIconToBI(ImageIcon icon)
      Converts an ImageIcon to a BufferedImage
      Parameters:
      icon - The ImageIcon to be converted
      Returns:
      BufferedImage The converted BufferedImage
    • resize

      public static BufferedImage resize(BufferedImage img, int newW, int newH)
      Resizes a BufferedImage
      Parameters:
      img - The BufferedImage to be resized
      newW - The new width
      newH - The new height
      Returns:
      BufferedImage The resized BufferedImage
    • createGradientVertical

      public static BufferedImage createGradientVertical(BufferedImage img, int startOpacity, int endOpacity)
      Makes a gradient from top to bottom.
      Parameters:
      img - The source image
      startOpacity - The begin opacity of the gradient.
      endOpacity - The end opacity of the gradient.
      Returns:
      BufferedImage The gradient image.
    • createGradient

      public static BufferedImage createGradient(BufferedImage img, int startOpacity, int endOpacity, DeImage.Directional opacityStartDirection)
      Creates a gradient from a certain side.
      Parameters:
      img - The source image
      startOpacity - The begin opacity of the gradient.
      endOpacity - The end opacity of the gradient.
      opacityStartDirection - The direction of the gradient.
      Returns:
      BufferedImage The gradient image.
    • resizeImage

      public static ImageIcon resizeImage(ImageIcon image, int width, int height)
      Parameters:
      image - An ImageIcon from a stream.
      width - The width to scale down to
      height - The height to scale down to
      Returns:
      ImageIcon A modified image that has been scaled to width and height.