Class Images

java.lang.Object
org.monte.media.image.Images

public class Images extends Object
Image processing methods for buffered images.
Author:
Werner Randelshofer, Karl von Randow
  • Method Details

    • createImage

      public static Image createImage(Class<?> baseClass, String location)
    • createImage

      public static Image createImage(URL resource)
    • toRGBImage

      public static BufferedImage toRGBImage(Image img)
      Converts the image to a buffered image into the sRGB color space. Preserves the alpha channel of the input image.
      Parameters:
      img - img
      Returns:
      img
    • toImageWithColorModel_usingColorConvertOp

      public static BufferedImage toImageWithColorModel_usingColorConvertOp(Image img, ColorModel cm)
      Converts the image into a buffered image with an RGB color model. This method returns the same image, if no conversion is needed.

      This method should be run with "KCMS" (Kodak Color Management System). The "Little CMS" which is the default in JVMs is 4 times slower.

      Start the VM with the following options:

       -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
       
      Parameters:
      img - an image
      cm - the destination color model
      Returns:
      the converted image, may be the same as the source image
    • toImageWithColorModel_usingDrawImage

      public static BufferedImage toImageWithColorModel_usingDrawImage(Image img, ColorModel cm)
      Converts the image into a buffered image with an RGB color model. This method returns the same image, if no conversion is needed.
      Parameters:
      img - an image
      cm - cm destination color model
      Returns:
      the converted image, may be the same as the source image
    • toBufferedImage

      public static BufferedImage toBufferedImage(RenderedImage rImg)
      Converts the image to a buffered image. Returns the same image, if the image is already a buffered image.
    • cloneImage

      public static BufferedImage cloneImage(RenderedImage rImg)
      Clone the image.
    • toBufferedImage

      public static BufferedImage toBufferedImage(Image image)
    • hasAlpha

      public static boolean hasAlpha(Image image)
      This method returns true if the specified image has transparent pixels

      Code taken from the Java Developers Almanac 1.4 http://javaalmanac.com/egs/java.awt.image/HasAlpha.html

    • split

      public static BufferedImage[] split(Image image, int count, boolean isHorizontal)
      Splits an image into count subimages.
    • toIntImage

      public static BufferedImage toIntImage(BufferedImage img)
      Converts the image into a format that can be handled easier.
    • toPixels

      public static int[] toPixels(BufferedImage img)
      Converts an image into an array of integer pixels. If the image has an integer data buffer, the internal pixel array is returned.
    • toImage

      public static BufferedImage toImage(int[] pixels, int width, int height)
      Converts an array of integer pixels into an image. The array is referenced by the image.