Class ColorProfiles


  • public final class ColorProfiles
    extends java.lang.Object
    A helper class for working with ICC color profiles.

    Standard ICC color profiles are read from system-specific locations for known operating systems.

    Color profiles may be configured by placing a property-file com/twelvemonkeys/imageio/color/icc_profiles.properties on the classpath, specifying the full path to the profiles. ICC color profiles are probably already present on your system, or can be downloaded from ICC, Adobe or other places. *

    Example property file:

     # icc_profiles.properties
     ADOBE_RGB_1998=/path/to/Adobe RGB 1998.icc
     GENERIC_CMYK=/path/to/Generic CMYK.icc
     
    Version:
    $Id: ColorSpaces.java,v 1.0 24.01.11 17.51 haraldk Exp$
    Author:
    Harald Kuhr, last modified by $Author: haraldk$
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.color.ICC_Profile createProfile​(byte[] input)
      Reads an ICC Profile from the given byte array, with extra validation.
      static java.awt.color.ICC_Profile createProfileRaw​(byte[] input)
      Creates an ICC Profile from the given byte array, as-is, with no validation.
      static boolean isCS_GRAY​(java.awt.color.ICC_Profile profile)
      Tests whether an ICC color profile is equal to the default GRAY profile.
      static boolean isCS_sRGB​(java.awt.color.ICC_Profile profile)
      Tests whether an ICC color profile is equal to the default sRGB profile.
      static java.awt.color.ICC_Profile readProfile​(java.io.InputStream input)
      Reads an ICC Profile from the given input stream, with extra validation.
      static java.awt.color.ICC_Profile readProfileRaw​(java.io.InputStream input)
      Reads an ICC Profile from the given input stream, as-is, with no validation.
      static java.awt.color.ICC_Profile validateProfile​(java.awt.color.ICC_Profile profile)
      Tests whether an ICC color profile is valid.
      • Methods inherited from class java.lang.Object

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

      • isCS_sRGB

        public static boolean isCS_sRGB​(java.awt.color.ICC_Profile profile)
        Tests whether an ICC color profile is equal to the default sRGB profile.
        Parameters:
        profile - the ICC profile to test. May not be null.
        Returns:
        true if profile is equal to the default sRGB profile.
        Throws:
        java.lang.IllegalArgumentException - if profile is null
        See Also:
        ColorSpace.CS_sRGB, ColorSpace.isCS_sRGB()
      • isCS_GRAY

        public static boolean isCS_GRAY​(java.awt.color.ICC_Profile profile)
        Tests whether an ICC color profile is equal to the default GRAY profile.
        Parameters:
        profile - the ICC profile to test. May not be null.
        Returns:
        true if profile is equal to the default GRAY profile.
        Throws:
        java.lang.IllegalArgumentException - if profile is null
        See Also:
        ColorSpace.CS_GRAY
      • validateProfile

        public static java.awt.color.ICC_Profile validateProfile​(java.awt.color.ICC_Profile profile)
        Tests whether an ICC color profile is valid. Invalid profiles are known to cause problems for ColorConvertOp.

        Note that this method only tests if a color conversion using this profile is known to fail. There's no guarantee that the color conversion will succeed even if this method returns false.

        Parameters:
        profile - the ICC color profile. May not be null.
        Returns:
        profile if valid.
        Throws:
        java.lang.IllegalArgumentException - if profile is null
        java.awt.color.CMMException - if profile is invalid.
      • readProfileRaw

        public static java.awt.color.ICC_Profile readProfileRaw​(java.io.InputStream input)
                                                         throws java.io.IOException
        Reads an ICC Profile from the given input stream, as-is, with no validation. This method behaves exactly like ICC_Profile.getInstance(input).
        Parameters:
        input - the input stream to read from, may not be null
        Returns:
        an ICC_Profile object as read from the input stream.
        Throws:
        java.io.IOException - If an I/O error occurs while reading the stream.
        java.lang.IllegalArgumentException - If input is null or the stream does not contain valid ICC Profile data.
        See Also:
        ICC_Profile.getInstance(InputStream), readProfile(InputStream)
      • readProfile

        public static java.awt.color.ICC_Profile readProfile​(java.io.InputStream input)
                                                      throws java.io.IOException
        Reads an ICC Profile from the given input stream, with extra validation. If a matching profile already exists in cache, the cached instance is returned.
        Parameters:
        input - the input stream to read from, may not be null
        Returns:
        an ICC_Profile object as read from the input stream.
        Throws:
        java.io.IOException - If an I/O error occurs while reading the stream.
        java.lang.IllegalArgumentException - If input is null or the stream does not contain valid ICC Profile data.
        See Also:
        ICC_Profile.getInstance(InputStream)
      • createProfileRaw

        public static java.awt.color.ICC_Profile createProfileRaw​(byte[] input)
        Creates an ICC Profile from the given byte array, as-is, with no validation. This method behaves exactly like ICC_Profile.getInstance(input), except that extraneous bytes at the end of the array is ignored.
        Parameters:
        input - the byte array to create a profile from, may not be null
        Returns:
        an ICC_Profile object created from the byte array
        Throws:
        java.lang.IllegalArgumentException - If input is null or the byte array does not contain valid ICC Profile data.
        See Also:
        ICC_Profile.getInstance(byte[]), createProfile(byte[])
      • createProfile

        public static java.awt.color.ICC_Profile createProfile​(byte[] input)
        Reads an ICC Profile from the given byte array, with extra validation. Extraneous bytes at the end of the array are ignored. If a matching profile already exists in cache, the cached instance is returned.
        Parameters:
        input - the byte array to create a profile from, may not be null
        Returns:
        an ICC_Profile object created from the byte array
        Throws:
        java.lang.IllegalArgumentException - If input is null or the byte array does not contain valid ICC Profile data.
        See Also:
        ICC_Profile.getInstance(byte[])