Class ImageUtil


  • public class ImageUtil
    extends Object
    Utilities for dealing with images.
    • Method Detail

      • flipImageVertically

        public static void flipImageVertically​(BufferedImage image)
        Flips the supplied BufferedImage vertically. This is often a necessary conversion step to display a Java2D image correctly with OpenGL and vice versa.
      • createCompatibleImage

        public static BufferedImage createCompatibleImage​(int width,
                                                          int height)
        Creates a BufferedImage with a pixel format compatible with the graphics environment. The returned image can thus benefit from hardware accelerated operations in Java2D API.
        Parameters:
        width - The width of the image to be created
        height - The height of the image to be created
        Returns:
        A instance of BufferedImage with a type compatible with the graphics card.
      • createThumbnail

        public static BufferedImage createThumbnail​(BufferedImage image,
                                                    int thumbWidth)
        Creates a thumbnail from an image. A thumbnail is a scaled down version of the original picture. This method will retain the width to height ratio of the original picture and return a new instance of BufferedImage. The original picture is not modified.
        Parameters:
        image - The original image to sample down
        thumbWidth - The width of the thumbnail to be created
        Returns:
        A thumbnail with the requested width or the original picture if thumbWidth = image.getWidth()
        Throws:
        IllegalArgumentException - If thumbWidth is greater than image.getWidth()