Class ColorProfiles
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$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final intprivate static final ICCProfileSanitizerWe need special ICC profile handling for KCMS vs LCMS. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]computeMD5(byte[] header, byte[] data) static ICC_ProfilecreateProfile(byte[] input) Reads an ICC Profile from the given byte array, with extra validation.static ICC_ProfilecreateProfileRaw(byte[] input) Creates an ICC Profile from the given byte array, as-is, with no validation.(package private) static voidfixProfile(ICC_Profile profile) private static intgetCsType(byte[] profileHeader) private static ICC_ProfilegetInternalProfile(byte[] profileHeader) (package private) static byte[]getProfileHeaderWithProfileId(byte[] data) (package private) static byte[]getProfileHeaderWithProfileId(ICC_Profile profile) private static intintBigEndian(byte[] data, int index) static booleanisCS_GRAY(ICC_Profile profile) Tests whether an ICC color profile is equal to the default GRAY profile.static booleanisCS_sRGB(ICC_Profile profile) Tests whether an ICC color profile is equal to the default sRGB profile.(package private) static booleanisOffendingColorProfile(ICC_Profile profile) Tests whether an ICC color profile is known to cause problems forColorConvertOp.private static byte[]limit(byte[] input, int size) static ICC_ProfilereadProfile(InputStream input) Reads an ICC Profile from the given input stream, with extra validation.(package private) static ICC_ProfilereadProfileFromClasspathResource(String profilePath) (package private) static ICC_ProfilereadProfileFromPath(String profilePath) static ICC_ProfilereadProfileRaw(InputStream input) Reads an ICC Profile from the given input stream, as-is, with no validation.private static intvalidateAndGetSize(byte[] input) private static intvalidateHeaderAndGetSize(byte[] input) static ICC_ProfilevalidateProfile(ICC_Profile profile) Tests whether an ICC color profile is valid.(package private) static boolean
-
Field Details
-
profileCleaner
We need special ICC profile handling for KCMS vs LCMS. Delegate to specific strategy. -
ICC_PROFILE_MAGIC
static final int ICC_PROFILE_MAGIC- See Also:
-
ICC_PROFILE_HEADER_SIZE
static final int ICC_PROFILE_HEADER_SIZE- See Also:
-
-
Constructor Details
-
ColorProfiles
private ColorProfiles()
-
-
Method Details
-
getProfileHeaderWithProfileId
-
getProfileHeaderWithProfileId
static byte[] getProfileHeaderWithProfileId(byte[] data) -
computeMD5
private static byte[] computeMD5(byte[] header, byte[] data) -
isCS_sRGB
Tests whether an ICC color profile is equal to the default sRGB profile.- Parameters:
profile- the ICC profile to test. May not benull.- Returns:
trueifprofileis equal to the default sRGB profile.- Throws:
IllegalArgumentException- ifprofileisnull- See Also:
-
isCS_GRAY
Tests whether an ICC color profile is equal to the default GRAY profile.- Parameters:
profile- the ICC profile to test. May not benull.- Returns:
trueifprofileis equal to the default GRAY profile.- Throws:
IllegalArgumentException- ifprofileisnull- See Also:
-
isOffendingColorProfile
Tests whether an ICC color profile is 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:
trueif known to be offending,falseotherwise- Throws:
IllegalArgumentException- ifprofileisnull
-
validateProfile
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:
profileif valid.- Throws:
IllegalArgumentException- ifprofileisnullCMMException- ifprofileis invalid.
-
readProfileRaw
Reads an ICC Profile from the given input stream, as-is, with no validation. This method behaves exactly likeICC_Profile.getInstance(input).- Parameters:
input- the input stream to read from, may not benull- Returns:
- an
ICC_Profileobject as read from the input stream. - Throws:
IOException- If an I/O error occurs while reading the stream.IllegalArgumentException- Ifinputisnullor the stream does not contain valid ICC Profile data.- See Also:
-
readProfile
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 benull- Returns:
- an
ICC_Profileobject as read from the input stream. - Throws:
IOException- If an I/O error occurs while reading the stream.IllegalArgumentException- Ifinputisnullor the stream does not contain valid ICC Profile data.- See Also:
-
createProfileRaw
Creates an ICC Profile from the given byte array, as-is, with no validation. This method behaves exactly likeICC_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 benull- Returns:
- an
ICC_Profileobject created from the byte array - Throws:
IllegalArgumentException- Ifinputisnullor the byte array does not contain valid ICC Profile data.- See Also:
-
createProfile
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 benull- Returns:
- an
ICC_Profileobject created from the byte array - Throws:
IllegalArgumentException- Ifinputisnullor the byte array does not contain valid ICC Profile data.- See Also:
-
limit
private static byte[] limit(byte[] input, int size) -
validateAndGetSize
private static int validateAndGetSize(byte[] input) -
validateHeaderAndGetSize
private static int validateHeaderAndGetSize(byte[] input) -
getInternalProfile
-
intBigEndian
private static int intBigEndian(byte[] data, int index) -
getCsType
private static int getCsType(byte[] profileHeader) -
readProfileFromClasspathResource
-
readProfileFromPath
-
fixProfile
-
validationAltersProfileHeader
static boolean validationAltersProfileHeader()
-