Class Imaging

java.lang.Object
de.gurkenlabs.litiengine.util.Imaging

public final class Imaging extends Object
  • Field Details

  • Method Details

    • addShadow

      public static BufferedImage addShadow(BufferedImage image, int xOffset, int yOffset)
      Adds a shadow effect by executing the following steps: 1. Transform visible pixels to a semi-transparent black 2. Flip the image vertically 3. Scale it down 4. Render original image and shadow on a buffered image

      TODO: Add support for different shadow types. Add an ellipse shadow, etc..

      Parameters:
      image - the image
      xOffset - the x offset
      yOffset - the y offset
      Returns:
      the buffered image
    • applyAlphaChannel

      public static BufferedImage applyAlphaChannel(BufferedImage img, Color color)
      All pixels that have the specified color are rendered transparent.
      Parameters:
      img - the img
      color - the color
      Returns:
      the image
    • borderAlpha

      public static BufferedImage borderAlpha(BufferedImage image, Color strokeColor, boolean borderOnly)
    • isEmpty

      public static boolean isEmpty(BufferedImage image)
    • areEqual

      public static boolean areEqual(BufferedImage image1, BufferedImage image2)
    • crop

      public static BufferedImage crop(BufferedImage image, int cropAlignment, int cropVerticlaAlignment, int width, int height)
      Crops a sub image from the specified image.
      Parameters:
      image - The image to crop the sub-image from.
      cropAlignment - use the following consts:
      cropVerticlaAlignment - use the following consts:
      width - The width to crop.
      height - The height to crop.
      Returns:
      The cropped image or the original image if it is smaller than the specified dimensions.
    • flashVisiblePixels

      public static BufferedImage flashVisiblePixels(Image image, Color flashColor)
      All pixels that are not transparent are replaced by a pixel of the specified flashColor.
      Parameters:
      image - the image
      flashColor - the flash color
      Returns:
      the buffered image
    • flipSpritesHorizontally

      public static BufferedImage flipSpritesHorizontally(Spritesheet sprite)
    • flipSpritesVertically

      public static BufferedImage flipSpritesVertically(Spritesheet sprite)
    • copy

      public static BufferedImage copy(BufferedImage image)
      Creates a new BufferedImage instance from the specified image.
      Parameters:
      image - The image to be copied.
      Returns:
      A copy of the specified image.
    • getCompatibleImage

      public static BufferedImage getCompatibleImage(int width, int height)
    • getSubImages

      public static BufferedImage[][] getSubImages(BufferedImage image, int rows, int columns)
      Gets a two dimensional grid that contains parts of the specified image. Splits up the specified image into a grid with the defined number of rows and columns.
      Parameters:
      image - The base image that will be split up.
      rows - The number of rows.
      columns - The number or columns.
      Returns:
      A two dimensional array with all the sub-images.
    • horizontalFlip

      public static BufferedImage horizontalFlip(BufferedImage img)
      Flips the specified image horizontally.
      Parameters:
      img - The image to be flipped.
      Returns:
      The flipped image.
    • verticalFlip

      public static BufferedImage verticalFlip(BufferedImage img)
      Flips the specified image vertically.
      Parameters:
      img - The image to be flipped.
      Returns:
      The flipped image.
    • replaceColors

      public static BufferedImage replaceColors(BufferedImage bufferedImage, Map<Color,Color> colorMappings)
      Replace colors in an image according to a Map containing source colors and target colors, then return the result.
      Parameters:
      bufferedImage - the original image
      colorMappings - a Map with source colors as keys and target colors as values
      Returns:
      a new version of the original image, where the source colors are replaced with the target colors.
    • rotate

      public static BufferedImage rotate(BufferedImage bufferedImage, Rotation rotation)
    • rotate

      public static BufferedImage rotate(BufferedImage bufferedImage, double radians)
    • scale

      public static BufferedImage scale(BufferedImage image, int max)
    • scale

      public static BufferedImage scale(BufferedImage image, double factor)
    • scale

      public static BufferedImage scale(BufferedImage image, double factor, boolean keepRatio)
    • scale

      public static BufferedImage scale(BufferedImage image, int width, int height)
      The specified image is scaled to a new dimension with the specified width and height. This method doesn't use anti aliasing for this process to keep the indy look.
      Parameters:
      image - the image
      width - the width
      height - the height
      Returns:
      the buffered image
    • scale

      public static BufferedImage scale(BufferedImage image, int width, int height, boolean keepRatio)
    • scale

      public static BufferedImage scale(BufferedImage image, int width, int height, boolean keepRatio, boolean fill)
    • setOpacity

      public static BufferedImage setOpacity(Image img, float opacity)
    • toBufferedImage

      public static BufferedImage toBufferedImage(Image img)
    • toCompatibleImage

      public static BufferedImage toCompatibleImage(BufferedImage image)