Class ImageUtils


  • public class ImageUtils
    extends java.lang.Object
    A utility class providing a set of static functions frequently used when working with images.

    All functions have been implemented with extreme caution in order to provide a maximum performance.

    Version:
    $Revision$ $Date$
    Author:
    Norman Fomferra
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.image.BufferedImage convertImage​(java.awt.image.RenderedImage image, int imageType)
      Converts the given rendered image into an image of the given {#link java.awt.image.BufferedImage} type.
      static java.awt.image.ColorModel create8BitGreyscaleColorModel()  
      static java.lang.Object createDataBufferArray​(int dataBufferType, int size)  
      static java.awt.image.BufferedImage createGreyscaleColorModelImage​(int width, int height, byte[] data)  
      static java.awt.image.BufferedImage createIndexedImage​(int width, int height, byte[] data, java.awt.image.IndexColorModel cm)  
      static java.awt.image.SampleModel createSingleBandedSampleModel​(int dataBufferType, int width, int height)  
      static double[] getDataTypeMinMax​(int dataType, double[] minmax)
      Returns an array containing the minimum and maximum value of the native data type used to store pixel values in the given image.
      static java.lang.Object getPrimitiveArray​(java.awt.image.DataBuffer dataBuffer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageUtils

        public ImageUtils()
    • Method Detail

      • convertImage

        public static java.awt.image.BufferedImage convertImage​(java.awt.image.RenderedImage image,
                                                                int imageType)
        Converts the given rendered image into an image of the given {#link java.awt.image.BufferedImage} type.
        Parameters:
        image - the source image
        imageType - the {#link java.awt.image.BufferedImage} type
        Returns:
        the buffered image of the given type
      • getDataTypeMinMax

        public static double[] getDataTypeMinMax​(int dataType,
                                                 double[] minmax)
        Returns an array containing the minimum and maximum value of the native data type used to store pixel values in the given image.
        Parameters:
        dataType - a data type as defined in DataBuffer
        See Also:
        DataBuffer
      • createGreyscaleColorModelImage

        public static java.awt.image.BufferedImage createGreyscaleColorModelImage​(int width,
                                                                                  int height,
                                                                                  byte[] data)
      • createIndexedImage

        public static java.awt.image.BufferedImage createIndexedImage​(int width,
                                                                      int height,
                                                                      byte[] data,
                                                                      java.awt.image.IndexColorModel cm)
      • create8BitGreyscaleColorModel

        public static java.awt.image.ColorModel create8BitGreyscaleColorModel()
      • getPrimitiveArray

        public static java.lang.Object getPrimitiveArray​(java.awt.image.DataBuffer dataBuffer)
      • createDataBufferArray

        public static java.lang.Object createDataBufferArray​(int dataBufferType,
                                                             int size)
      • createSingleBandedSampleModel

        public static java.awt.image.SampleModel createSingleBandedSampleModel​(int dataBufferType,
                                                                               int width,
                                                                               int height)