Class ColorSpaces
- java.lang.Object
-
- com.twelvemonkeys.imageio.color.ColorSpaces
-
public final class ColorSpaces extends java.lang.Object
A helper class for working with ICC color profiles and color spaces.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$
-
-
Field Summary
Fields Modifier and Type Field Description static int
CS_ADOBE_RGB_1998
The Adobe RGB 1998 (or compatible) color space.static int
CS_GENERIC_CMYK
A best-effort "generic" CMYK color space.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.color.ICC_ColorSpace
createColorSpace(java.awt.color.ICC_Profile profile)
Creates an ICC color space from the given ICC color profile.static java.awt.color.ColorSpace
getColorSpace(int colorSpace)
Returns the color space specified by the given color space constant.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
validateProfile(java.awt.color.ICC_Profile profile)
Tests whether an ICC color profile is valid.
-
-
-
Field Detail
-
CS_ADOBE_RGB_1998
public static final int CS_ADOBE_RGB_1998
The Adobe RGB 1998 (or compatible) color space. Either read from disk or built-in.- See Also:
- Constant Field Values
-
CS_GENERIC_CMYK
public static final int CS_GENERIC_CMYK
A best-effort "generic" CMYK color space. Either read from disk or built-in.- See Also:
- Constant Field Values
-
-
Method Detail
-
createColorSpace
public static java.awt.color.ICC_ColorSpace createColorSpace(java.awt.color.ICC_Profile profile)
Creates an ICC color space from the given ICC color profile.For standard Java color spaces, the built-in instance is returned. Otherwise, color spaces are looked up from cache and created on demand.
- Parameters:
profile
- the ICC color profile. May not benull
.- Returns:
- an ICC color space
- Throws:
java.lang.IllegalArgumentException
- ifprofile
isnull
.java.awt.color.CMMException
- ifprofile
is invalid.
-
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 benull
.- Returns:
true
ifprofile
is equal to the default sRGB profile.- Throws:
java.lang.IllegalArgumentException
- ifprofile
isnull
- See Also:
ColorSpace.isCS_sRGB()
-
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 forColorConvertOp
.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 benull
.- Returns:
profile
if valid.- Throws:
java.lang.IllegalArgumentException
- ifprofile
isnull
java.awt.color.CMMException
- ifprofile
is invalid.
-
getColorSpace
public static java.awt.color.ColorSpace getColorSpace(int colorSpace)
Returns the color space specified by the given color space constant.For standard Java color spaces, the built-in instance is returned. Otherwise, color spaces are looked up from cache and created on demand.
- Parameters:
colorSpace
- the color space constant.- Returns:
- the
ColorSpace
specified by the color space constant. - Throws:
java.lang.IllegalArgumentException
- ifcolorSpace
is not one of the defined color spaces (CS_*
).- See Also:
ColorSpace
,CS_ADOBE_RGB_1998
,CS_GENERIC_CMYK
-
-