Class ImageUtils

java.lang.Object
com.blackrook.gloop.opengl.util.ImageUtils

public final class ImageUtils extends Object
Image utility class.

All of these methods can be called outside of the graphics thread.

Author:
Matthew Tropiano
  • Method Details

    • performResize

      public static BufferedImage performResize(BufferedImage source, ImageUtils.ResizeQuality quality, int newWidth, int newHeight)
      Resizes an image using nearest filtering.
      Parameters:
      source - the source image.
      quality - the rendering quality to use.
      newWidth - the new image width.
      newHeight - the new image height.
      Returns:
      the resized image.
    • performFlip

      public static BufferedImage performFlip(BufferedImage source, boolean flipX, boolean flipY)
      Flips an image across one or two axes.
      Parameters:
      source - the source image.
      flipX - if true, flips horizontally.
      flipY - if true, flips vertically.
      Returns:
      an output image where the contents are flipped according to parameters.
    • createMipMaps

      public static BufferedImage[] createMipMaps(BufferedImage source, ImageUtils.ResizeQuality quality)
      Creates a series of texture mipmaps from an original image. The first image returned is the original, and each subsequent image is a smaller map. Best used with square images whose width and height are powers of two.
      Parameters:
      source - the source image.
      quality - the resize quality.
      Returns:
      the array of images in texture mipmap level ordering (largest to smallest).
    • createMipMapImage

      public static BufferedImage createMipMapImage(BufferedImage source, ImageUtils.ResizeQuality quality)
      Creates an image that contains the source image and all of its mipmap levels. The first image returned is the original, and each subsequent image is a smaller map. Best used with square images whose width and height are powers of two.
      Parameters:
      source - the source image.
      quality - the resize quality.
      Returns:
      the resultant image.
      See Also:
    • splitMipMapImage

      public static BufferedImage[] splitMipMapImage(BufferedImage source)
      Creates a series of images from an image that contains a primary image and all of its mipmap levels.

      This assumes a composition pattern as though it were created with createMipMapImage(BufferedImage, ResizeQuality).

      Parameters:
      source - the source image.
      Returns:
      the resultant image.
    • splitTextureGrid

      public static BufferedImage[] splitTextureGrid(BufferedImage source, int rows, int columns)
      Creates a series of images from a larger image, such that the resultant images are made from dividing up the source image into a grid of equally-sized images.
      Parameters:
      source - the source image.
      rows - the amount of grid rows.
      columns - the amount of grid columns.
      Returns:
      the resultant images, in row-major order.