< prev index next >

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Print this page

        

*** 21,32 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* ! ********************************************************************** ********************************************************************** ********************************************************************** *** COPYRIGHT (c) Eastman Kodak Company, 1997 *** *** As an unpublished work pursuant to Title 17 of the United *** *** States Code. All rights reserved. *** --- 21,31 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* ******************************************************************** ********************************************************************** ********************************************************************** *** COPYRIGHT (c) Eastman Kodak Company, 1997 *** *** As an unpublished work pursuant to Title 17 of the United *** *** States Code. All rights reserved. ***
*** 34,99 **** ********************************************************************** **********************************************************************/ package java.awt.color; - import sun.java2d.cmm.PCMM; - import sun.java2d.cmm.CMSManager; - import sun.java2d.cmm.Profile; - import sun.java2d.cmm.ProfileDataVerifier; - import sun.java2d.cmm.ProfileDeferralMgr; - import sun.java2d.cmm.ProfileDeferralInfo; - import sun.java2d.cmm.ProfileActivator; - import java.io.File; import java.io.FileInputStream; - import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; import java.io.OutputStream; import java.io.Serializable; - - import java.util.StringTokenizer; - import java.security.AccessController; import java.security.PrivilegedAction; /** ! * A representation of color profile data for device independent and ! * device dependent color spaces based on the International Color ! * Consortium Specification ICC.1:2001-12, File Format for Color Profiles, ! * (see <A href="http://www.color.org"> http://www.color.org</A>). * <p> ! * An ICC_ColorSpace object can be constructed from an appropriate ! * ICC_Profile. ! * Typically, an ICC_ColorSpace would be associated with an ICC ! * Profile which is either an input, display, or output profile (see ! * the ICC specification). There are also device link, abstract, ! * color space conversion, and named color profiles. These are less ! * useful for tagging a color or image, but are useful for other ! * purposes (in particular device link profiles can provide improved ! * performance for converting from one device's color space to ! * another's). * <p> ! * ICC Profiles represent transformations from the color space of ! * the profile (e.g. a monitor) to a Profile Connection Space (PCS). ! * Profiles of interest for tagging images or colors have a PCS ! * which is one of the two specific device independent ! * spaces (one CIEXYZ space and one CIELab space) defined in the ! * ICC Profile Format Specification. Most profiles of interest ! * either have invertible transformations or explicitly specify ! * transformations going both directions. * @see ICC_ColorSpace */ - - public class ICC_Profile implements Serializable { private static final long serialVersionUID = -3938515861990936766L; private transient Profile cmmProfile; --- 33,90 ---- ********************************************************************** **********************************************************************/ package java.awt.color; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; import java.io.OutputStream; import java.io.Serializable; import java.security.AccessController; import java.security.PrivilegedAction; + import java.util.StringTokenizer; + import sun.java2d.cmm.CMSManager; + import sun.java2d.cmm.PCMM; + import sun.java2d.cmm.Profile; + import sun.java2d.cmm.ProfileActivator; + import sun.java2d.cmm.ProfileDataVerifier; + import sun.java2d.cmm.ProfileDeferralInfo; + import sun.java2d.cmm.ProfileDeferralMgr; /** ! * A representation of color profile data for device independent and device ! * dependent color spaces based on the International Color Consortium ! * Specification ICC.1:2001-12, File Format for Color Profiles, (see ! * <a href="http://www.color.org"> http://www.color.org</a>). * <p> ! * An {@code ICC_ColorSpace} object can be constructed from an appropriate ! * {@code ICC_Profile}. Typically, an {@code ICC_ColorSpace} would be associated ! * with an ICC Profile which is either an input, display, or output profile (see ! * the ICC specification). There are also device link, abstract, color space ! * conversion, and named color profiles. These are less useful for tagging a ! * color or image, but are useful for other purposes (in particular device link ! * profiles can provide improved performance for converting from one device's ! * color space to another's). * <p> ! * ICC Profiles represent transformations from the color space of the profile ! * (e.g. a monitor) to a Profile Connection Space (PCS). Profiles of interest ! * for tagging images or colors have a PCS which is one of the two specific ! * device independent spaces (one CIEXYZ space and one CIELab space) defined in ! * the ICC Profile Format Specification. Most profiles of interest either have ! * invertible transformations or explicitly specify transformations going both ! * directions. ! * * @see ICC_ColorSpace */ public class ICC_Profile implements Serializable { private static final long serialVersionUID = -3938515861990936766L; private transient Profile cmmProfile;
*** 108,118 **** private static ICC_Profile XYZprofile; private static ICC_Profile PYCCprofile; private static ICC_Profile GRAYprofile; private static ICC_Profile LINEAR_RGBprofile; - /** * Profile class is input. */ public static final int CLASS_INPUT = 0; --- 99,108 ----
*** 144,154 **** /** * Profile class is named color. */ public static final int CLASS_NAMEDCOLOR = 6; - /** * ICC Profile Color Space Type Signature: 'XYZ '. */ public static final int icSigXYZData = 0x58595A20; /* 'XYZ ' */ --- 134,143 ----
*** 319,328 **** --- 308,318 ---- */ public static final int icRelativeColorimetric = 1; /** * ICC Profile Rendering Intent: Media-RelativeColorimetric. + * * @since 1.5 */ public static final int icMediaRelativeColorimetric = 1; /**
*** 335,344 **** --- 325,335 ---- */ public static final int icAbsoluteColorimetric = 3; /** * ICC Profile Rendering Intent: ICC-AbsoluteColorimetric. + * * @since 1.5 */ public static final int icICCAbsoluteColorimetric = 3;
*** 367,376 **** --- 358,368 ---- */ public static final int icSigBlueColorantTag = 0x6258595A; /* 'bXYZ' */ /** * ICC Profile Tag Signature: 'bXYZ'. + * * @since 1.5 */ public static final int icSigBlueMatrixColumnTag = 0x6258595A; /* 'bXYZ' */ /**
*** 444,453 **** --- 436,446 ---- */ public static final int icSigGreenColorantTag = 0x6758595A; /* 'gXYZ' */ /** * ICC Profile Tag Signature: 'gXYZ'. + * * @since 1.5 */ public static final int icSigGreenMatrixColumnTag = 0x6758595A;/* 'gXYZ' */ /**
*** 548,557 **** --- 541,551 ---- */ public static final int icSigRedColorantTag = 0x7258595A; /* 'rXYZ' */ /** * ICC Profile Tag Signature: 'rXYZ'. + * * @since 1.5 */ public static final int icSigRedMatrixColumnTag = 0x7258595A; /* 'rXYZ' */ /**
*** 594,615 **** --- 588,612 ---- */ public static final int icSigChromaticityTag = 0x6368726d; /* 'chrm' */ /** * ICC Profile Tag Signature: 'chad'. + * * @since 1.5 */ public static final int icSigChromaticAdaptationTag = 0x63686164;/* 'chad' */ /** * ICC Profile Tag Signature: 'clro'. + * * @since 1.5 */ public static final int icSigColorantOrderTag = 0x636C726F; /* 'clro' */ /** * ICC Profile Tag Signature: 'clrt'. + * * @since 1.5 */ public static final int icSigColorantTableTag = 0x636C7274; /* 'clrt' */
*** 693,702 **** --- 690,700 ---- */ public static final int icHdrCreator = 80; /* Profile creator */ /** * ICC Profile Header Location: profile's ID. + * * @since 1.5 */ public static final int icHdrProfileID = 84; /* Profile's ID */
*** 725,743 **** */ public static final int icXYZNumberX = 8; /* XYZNumber X */ /** ! * Constructs an ICC_Profile object with a given ID. */ ICC_Profile(Profile p) { this.cmmProfile = p; } - /** ! * Constructs an ICC_Profile object whose loading will be deferred. * The ID will be 0 until the profile is loaded. */ ICC_Profile(ProfileDeferralInfo pdi) { this.deferralInfo = pdi; this.profileActivator = new ProfileActivator() { --- 723,740 ---- */ public static final int icXYZNumberX = 8; /* XYZNumber X */ /** ! * Constructs an {@code ICC_Profile} object with a given ID. */ ICC_Profile(Profile p) { this.cmmProfile = p; } /** ! * Constructs an {@code ICC_Profile} object whose loading will be deferred. * The ID will be 0 until the profile is loaded. */ ICC_Profile(ProfileDeferralInfo pdi) { this.deferralInfo = pdi; this.profileActivator = new ProfileActivator() {
*** 746,785 **** } }; ProfileDeferralMgr.registerDeferral(this.profileActivator); } - /** ! * Frees the resources associated with an ICC_Profile object. * ! * @deprecated The {@code finalize} method has been deprecated. ! * Subclasses that override {@code finalize} in order to perform cleanup ! * should be modified to use alternative cleanup mechanisms and ! * to remove the overriding {@code finalize} method. ! * When overriding the {@code finalize} method, its implementation must explicitly ! * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. ! * See the specification for {@link Object#finalize()} for further ! * information about migration options. */ @Deprecated(since="9") protected void finalize () { if (cmmProfile != null) { CMSManager.getModule().freeProfile(cmmProfile); } else if (profileActivator != null) { ProfileDeferralMgr.unregisterDeferral(profileActivator); } } - /** ! * Constructs an ICC_Profile object corresponding to the data in ! * a byte array. Throws an IllegalArgumentException if the data ! * does not correspond to a valid ICC Profile. * @param data the specified ICC Profile data ! * @return an {@code ICC_Profile} object corresponding to ! * the data in the specified {@code data} array. */ public static ICC_Profile getInstance(byte[] data) { ICC_Profile thisProfile; Profile p = null; --- 743,782 ---- } }; ProfileDeferralMgr.registerDeferral(this.profileActivator); } /** ! * Frees the resources associated with an {@code ICC_Profile} object. * ! * @deprecated The {@code finalize} method has been deprecated. Subclasses ! * that override {@code finalize} in order to perform cleanup should ! * be modified to use alternative cleanup mechanisms and to remove ! * the overriding {@code finalize} method. When overriding the ! * {@code finalize} method, its implementation must explicitly ! * ensure that {@code super.finalize()} is invoked as described in ! * {@link Object#finalize}. See the specification for {@link ! * Object#finalize()} for further information about migration ! * options. */ @Deprecated(since="9") protected void finalize () { if (cmmProfile != null) { CMSManager.getModule().freeProfile(cmmProfile); } else if (profileActivator != null) { ProfileDeferralMgr.unregisterDeferral(profileActivator); } } /** ! * Constructs an {@code ICC_Profile} object corresponding to the data in a ! * byte array. Throws an {@code IllegalArgumentException} if the data does ! * not correspond to a valid ICC Profile. ! * * @param data the specified ICC Profile data ! * @return an {@code ICC_Profile} object corresponding to the data in the ! * specified {@code data} array */ public static ICC_Profile getInstance(byte[] data) { ICC_Profile thisProfile; Profile p = null;
*** 819,844 **** thisProfile = new ICC_Profile (p); } return thisProfile; } - - /** ! * Constructs an ICC_Profile corresponding to one of the specific color ! * spaces defined by the ColorSpace class (for example CS_sRGB). ! * Throws an IllegalArgumentException if cspace is not one of the ! * defined color spaces. ! * ! * @param cspace the type of color space to create a profile for. ! * The specified type is one of the color ! * space constants defined in the {@code ColorSpace} class. ! * ! * @return an {@code ICC_Profile} object corresponding to ! * the specified {@code ColorSpace} type. ! * @exception IllegalArgumentException If {@code cspace} is not ! * one of the predefined color space types. */ public static ICC_Profile getInstance (int cspace) { ICC_Profile thisProfile = null; String fileName; --- 816,838 ---- thisProfile = new ICC_Profile (p); } return thisProfile; } /** ! * Constructs an {@code ICC_Profile} corresponding to one of the specific ! * color spaces defined by the {@code ColorSpace} class (for example ! * {@code CS_sRGB}). Throws an {@code IllegalArgumentException} if cspace is ! * not one of the defined color spaces. ! * ! * @param cspace the type of color space to create a profile for. The ! * specified type is one of the color space constants defined in the ! * {@code ColorSpace} class. ! * @return an {@code ICC_Profile} object corresponding to the specified ! * {@code ColorSpace} type ! * @throws IllegalArgumentException If {@code cspace} is not one of the ! * predefined color space types */ public static ICC_Profile getInstance (int cspace) { ICC_Profile thisProfile = null; String fileName;
*** 929,983 **** } return thisProfile; } ! /* This asserts system privileges, so is used only for the ! * standard profiles. */ private static ICC_Profile getStandardProfile(final String name) { - return AccessController.doPrivileged( new PrivilegedAction<ICC_Profile>() { public ICC_Profile run() { ICC_Profile p = null; try { ! p = getInstance (name); } catch (IOException ex) { throw new IllegalArgumentException( "Can't load standard profile: " + name); } return p; } }); } /** ! * Constructs an ICC_Profile corresponding to the data in a file. ! * fileName may be an absolute or a relative file specification. ! * Relative file names are looked for in several places: first, relative ! * to any directories specified by the java.iccprofile.path property; ! * second, relative to any directories specified by the java.class.path ! * property; finally, in a directory used to store profiles always ! * available, such as the profile for sRGB. Built-in profiles use .pf as ! * the file name extension for profiles, e.g. sRGB.pf. ! * This method throws an IOException if the specified file cannot be ! * opened or if an I/O error occurs while reading the file. It throws ! * an IllegalArgumentException if the file does not contain valid ICC ! * Profile data. ! * @param fileName The file that contains the data for the profile. ! * ! * @return an {@code ICC_Profile} object corresponding to ! * the data in the specified file. ! * @exception IOException If the specified file cannot be opened or ! * an I/O error occurs while reading the file. ! * ! * @exception IllegalArgumentException If the file does not ! * contain valid ICC Profile data. ! * ! * @exception SecurityException If a security manager is installed ! * and it does not permit read access to the given file. */ public static ICC_Profile getInstance(String fileName) throws IOException { ICC_Profile thisProfile; InputStream is = null; --- 923,975 ---- } return thisProfile; } ! /** ! * This method asserts system privileges, so is used only for the standard ! * profiles. */ private static ICC_Profile getStandardProfile(final String name) { return AccessController.doPrivileged( new PrivilegedAction<ICC_Profile>() { public ICC_Profile run() { ICC_Profile p = null; try { ! p = getInstance(name); } catch (IOException ex) { throw new IllegalArgumentException( "Can't load standard profile: " + name); } return p; } }); } /** ! * Constructs an {@code ICC_Profile} corresponding to the data in a file. ! * {@code fileName} may be an absolute or a relative file specification. ! * Relative file names are looked for in several places: first, relative to ! * any directories specified by the {@code java.iccprofile.path} property; ! * second, relative to any directories specified by the ! * {@code java.class.path} property; finally, in a directory used to store ! * profiles always available, such as the profile for sRGB. Built-in ! * profiles use {@code .pf} as the file name extension for profiles, e.g. ! * {@code sRGB.pf}. This method throws an {@code IOException} if the ! * specified file cannot be opened or if an I/O error occurs while reading ! * the file. It throws an {@code IllegalArgumentException} if the file does ! * not contain valid ICC Profile data. ! * ! * @param fileName the file that contains the data for the profile ! * @return an {@code ICC_Profile} object corresponding to the data in the ! * specified file ! * @throws IOException If the specified file cannot be opened or an I/O ! * error occurs while reading the file ! * @throws IllegalArgumentException If the file does not contain valid ICC ! * Profile data ! * @throws SecurityException If a security manager is installed and it does ! * not permit read access to the given file */ public static ICC_Profile getInstance(String fileName) throws IOException { ICC_Profile thisProfile; InputStream is = null;
*** 997,1021 **** is.close(); /* close the file */ return thisProfile; } - /** ! * Constructs an ICC_Profile corresponding to the data in an InputStream. ! * This method throws an IllegalArgumentException if the stream does not ! * contain valid ICC Profile data. It throws an IOException if an I/O ! * error occurs while reading the stream. ! * @param s The input stream from which to read the profile data. ! * ! * @return an {@code ICC_Profile} object corresponding to the ! * data in the specified {@code InputStream}. ! * ! * @exception IOException If an I/O error occurs while reading the stream. ! * ! * @exception IllegalArgumentException If the stream does not ! * contain valid ICC Profile data. */ public static ICC_Profile getInstance(InputStream s) throws IOException { byte[] profileData; if (s instanceof ProfileDeferralInfo) { --- 989,1011 ---- is.close(); /* close the file */ return thisProfile; } /** ! * Constructs an {@code ICC_Profile} corresponding to the data in an ! * {@code InputStream}. This method throws an ! * {@code IllegalArgumentException} if the stream does not contain valid ICC ! * Profile data. It throws an {@code IOException} if an I/O error occurs ! * while reading the stream. ! * ! * @param s the input stream from which to read the profile data ! * @return an {@code ICC_Profile} object corresponding to the data in the ! * specified {@code InputStream} ! * @throws IOException If an I/O error occurs while reading the stream ! * @throws IllegalArgumentException If the stream does not contain valid ICC ! * Profile data */ public static ICC_Profile getInstance(InputStream s) throws IOException { byte[] profileData; if (s instanceof ProfileDeferralInfo) {
*** 1068,1088 **** } return profileData; } - /** ! * Constructs an ICC_Profile for which the actual loading of the ! * profile data from a file and the initialization of the CMM should ! * be deferred as long as possible. ! * Deferral is only used for standard profiles. ! * If deferring is disabled, then getStandardProfile() ensures ! * that all of the appropriate access privileges are granted ! * when loading this profile. ! * If deferring is enabled, then the deferred activation ! * code will take care of access privileges. * @see #activateDeferredProfile() */ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) { if (!ProfileDeferralMgr.deferring) { return getStandardProfile(pdi.filename); --- 1058,1076 ---- } return profileData; } /** ! * Constructs an {@code ICC_Profile} for which the actual loading of the ! * profile data from a file and the initialization of the CMM should be ! * deferred as long as possible. Deferral is only used for standard ! * profiles. If deferring is disabled, then getStandardProfile() ensures ! * that all of the appropriate access privileges are granted when loading ! * this profile. If deferring is enabled, then the deferred activation code ! * will take care of access privileges. ! * * @see #activateDeferredProfile() */ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) { if (!ProfileDeferralMgr.deferring) { return getStandardProfile(pdi.filename);
*** 1129,1142 **** pde.initCause(c); throw pde; } } - /** * Returns profile major version. ! * @return The major version of the profile. */ public int getMajorVersion() { byte[] theHeader; theHeader = getData(icSigHead); /* getData will activate deferred --- 1117,1130 ---- pde.initCause(c); throw pde; } } /** * Returns profile major version. ! * ! * @return the major version of the profile */ public int getMajorVersion() { byte[] theHeader; theHeader = getData(icSigHead); /* getData will activate deferred
*** 1145,1155 **** return (int) theHeader[8]; } /** * Returns profile minor version. ! * @return The minor version of the profile. */ public int getMinorVersion() { byte[] theHeader; theHeader = getData(icSigHead); /* getData will activate deferred --- 1133,1144 ---- return (int) theHeader[8]; } /** * Returns profile minor version. ! * ! * @return the minor version of the profile */ public int getMinorVersion() { byte[] theHeader; theHeader = getData(icSigHead); /* getData will activate deferred
*** 1158,1168 **** return (int) theHeader[9]; } /** * Returns the profile class. ! * @return One of the predefined profile class constants. */ public int getProfileClass() { byte[] theHeader; int theClassSig, theClass; --- 1147,1158 ---- return (int) theHeader[9]; } /** * Returns the profile class. ! * ! * @return one of the predefined profile class constants */ public int getProfileClass() { byte[] theHeader; int theClassSig, theClass;
*** 1213,1231 **** return theClass; } /** * Returns the color space type. Returns one of the color space type ! * constants defined by the ColorSpace class. This is the ! * "input" color space of the profile. The type defines the ! * number of components of the color space and the interpretation, ! * e.g. TYPE_RGB identifies a color space with three components - red, ! * green, and blue. It does not define the particular color ! * characteristics of the space, e.g. the chromaticities of the ! * primaries. ! * @return One of the color space type constants defined in the ! * {@code ColorSpace} class. */ public int getColorSpaceType() { if (deferralInfo != null) { return deferralInfo.colorSpaceType; /* Need to have this info for ICC_ColorSpace without --- 1203,1221 ---- return theClass; } /** * Returns the color space type. Returns one of the color space type ! * constants defined by the {@code ColorSpace} class. This is the "input" ! * color space of the profile. The type defines the number of components of ! * the color space and the interpretation, e.g. {@code TYPE_RGB} identifies ! * a color space with three components - red, green, and blue. It does not ! * define the particular color characteristics of the space, e.g. the ! * chromaticities of the primaries. ! * ! * @return one of the color space type constants defined in the ! * {@code ColorSpace} class */ public int getColorSpaceType() { if (deferralInfo != null) { return deferralInfo.colorSpaceType; /* Need to have this info for ICC_ColorSpace without
*** 1245,1263 **** return theColorSpace; } /** * Returns the color space type of the Profile Connection Space (PCS). ! * Returns one of the color space type constants defined by the ! * ColorSpace class. This is the "output" color space of the ! * profile. For an input, display, or output profile useful ! * for tagging colors or images, this will be either TYPE_XYZ or ! * TYPE_Lab and should be interpreted as the corresponding specific ! * color space defined in the ICC specification. For a device ! * link profile, this could be any of the color space type constants. ! * @return One of the color space type constants defined in the ! * {@code ColorSpace} class. */ public int getPCSType() { if (ProfileDeferralMgr.deferring) { ProfileDeferralMgr.activateProfiles(); } --- 1235,1254 ---- return theColorSpace; } /** * Returns the color space type of the Profile Connection Space (PCS). ! * Returns one of the color space type constants defined by the ColorSpace ! * class. This is the "output" color space of the profile. For an input, ! * display, or output profile useful for tagging colors or images, this will ! * be either {@code TYPE_XYZ} or {@code TYPE_Lab} and should be interpreted ! * as the corresponding specific color space defined in the ICC ! * specification. For a device link profile, this could be any of the color ! * space type constants. ! * ! * @return one of the color space type constants defined in the ! * {@code ColorSpace} class */ public int getPCSType() { if (ProfileDeferralMgr.deferring) { ProfileDeferralMgr.activateProfiles(); }
*** 1273,1290 **** thePCSSig = intFromBigEndian(theHeader, icHdrPcs); thePCS = iccCStoJCS(thePCSSig); return thePCS; } - /** ! * Write this ICC_Profile to a file. ! * ! * @param fileName The file to write the profile data to. * ! * @exception IOException If the file cannot be opened for writing ! * or an I/O error occurs while writing to the file. */ public void write(String fileName) throws IOException { FileOutputStream outputFile; byte[] profileData; --- 1264,1279 ---- thePCSSig = intFromBigEndian(theHeader, icHdrPcs); thePCS = iccCStoJCS(thePCSSig); return thePCS; } /** ! * Write this {@code ICC_Profile} to a file. * ! * @param fileName the file to write the profile data to ! * @throws IOException If the file cannot be opened for writing or an I/O ! * error occurs while writing to the file */ public void write(String fileName) throws IOException { FileOutputStream outputFile; byte[] profileData;
*** 1293,1323 **** outputFile = new FileOutputStream(fileName); outputFile.write(profileData); outputFile.close (); } - /** ! * Write this ICC_Profile to an OutputStream. * ! * @param s The stream to write the profile data to. ! * ! * @exception IOException If an I/O error occurs while writing to the ! * stream. */ public void write(OutputStream s) throws IOException { byte[] profileData; profileData = getData(); /* this will activate deferred profiles if necessary */ s.write(profileData); } - /** ! * Returns a byte array corresponding to the data of this ICC_Profile. ! * @return A byte array that contains the profile data. * @see #setData(int, byte[]) */ public byte[] getData() { int profileSize; byte[] profileData; --- 1282,1310 ---- outputFile = new FileOutputStream(fileName); outputFile.write(profileData); outputFile.close (); } /** ! * Write this {@code ICC_Profile} to an {@code OutputStream}. * ! * @param s the stream to write the profile data to ! * @throws IOException If an I/O error occurs while writing to the stream */ public void write(OutputStream s) throws IOException { byte[] profileData; profileData = getData(); /* this will activate deferred profiles if necessary */ s.write(profileData); } /** ! * Returns a byte array corresponding to the data of this ! * {@code ICC_Profile}. ! * ! * @return a byte array that contains the profile data * @see #setData(int, byte[]) */ public byte[] getData() { int profileSize; byte[] profileData;
*** 1337,1359 **** mdl.getProfileData(cmmProfile, profileData); return profileData; } - /** ! * Returns a particular tagged data element from the profile as ! * a byte array. Elements are identified by signatures ! * as defined in the ICC specification. The signature ! * icSigHead can be used to get the header. This method is useful ! * for advanced applets or applications which need to access ! * profile data directly. ! * ! * @param tagSignature The ICC tag signature for the data element you ! * want to get. * ! * @return A byte array that contains the tagged data element. Returns * {@code null} if the specified tag doesn't exist. * @see #setData(int, byte[]) */ public byte[] getData(int tagSignature) { --- 1324,1343 ---- mdl.getProfileData(cmmProfile, profileData); return profileData; } /** ! * Returns a particular tagged data element from the profile as a byte ! * array. Elements are identified by signatures as defined in the ICC ! * specification. The signature icSigHead can be used to get the header. ! * This method is useful for advanced applets or applications which need to ! * access profile data directly. * ! * @param tagSignature the ICC tag signature for the data element you want ! * to get ! * @return a byte array that contains the tagged data element. Returns * {@code null} if the specified tag doesn't exist. * @see #setData(int, byte[]) */ public byte[] getData(int tagSignature) {
*** 1385,1408 **** return tagData; } /** ! * Sets a particular tagged data element in the profile from ! * a byte array. The array should contain data in a format, corresponded ! * to the {@code tagSignature} as defined in the ICC specification, section 10. * This method is useful for advanced applets or applications which need to * access profile data directly. * ! * @param tagSignature The ICC tag signature for the data element ! * you want to set. * @param tagData the data to set for the specified tag signature ! * @throws IllegalArgumentException if {@code tagSignature} is not a signature ! * as defined in the ICC specification. * @throws IllegalArgumentException if a content of the {@code tagData} ! * array can not be interpreted as valid tag data, corresponding ! * to the {@code tagSignature}. * @see #getData */ public void setData(int tagSignature, byte[] tagData) { if (ProfileDeferralMgr.deferring) { --- 1369,1392 ---- return tagData; } /** ! * Sets a particular tagged data element in the profile from a byte array. ! * The array should contain data in a format, corresponded to the ! * {@code tagSignature} as defined in the ICC specification, section 10. * This method is useful for advanced applets or applications which need to * access profile data directly. * ! * @param tagSignature the ICC tag signature for the data element you want ! * to set * @param tagData the data to set for the specified tag signature ! * @throws IllegalArgumentException if {@code tagSignature} is not a ! * signature as defined in the ICC specification. * @throws IllegalArgumentException if a content of the {@code tagData} ! * array can not be interpreted as valid tag data, corresponding to ! * the {@code tagSignature} * @see #getData */ public void setData(int tagSignature, byte[] tagData) { if (ProfileDeferralMgr.deferring) {
*** 1411,1438 **** CMSManager.getModule().setTagData(cmmProfile, tagSignature, tagData); } /** ! * Sets the rendering intent of the profile. ! * This is used to select the proper transform from a profile that ! * has multiple transforms. */ void setRenderingIntent(int renderingIntent) { byte[] theHeader = getData(icSigHead);/* getData will activate deferred profiles if necessary */ intToBigEndian (renderingIntent, theHeader, icHdrRenderingIntent); /* set the rendering intent */ setData (icSigHead, theHeader); } - /** ! * Returns the rendering intent of the profile. ! * This is used to select the proper transform from a profile that ! * has multiple transforms. It is typically set in a source profile ! * to select a transform from an output profile. */ int getRenderingIntent() { byte[] theHeader = getData(icSigHead);/* getData will activate deferred profiles if necessary */ --- 1395,1420 ---- CMSManager.getModule().setTagData(cmmProfile, tagSignature, tagData); } /** ! * Sets the rendering intent of the profile. This is used to select the ! * proper transform from a profile that has multiple transforms. */ void setRenderingIntent(int renderingIntent) { byte[] theHeader = getData(icSigHead);/* getData will activate deferred profiles if necessary */ intToBigEndian (renderingIntent, theHeader, icHdrRenderingIntent); /* set the rendering intent */ setData (icSigHead, theHeader); } /** ! * Returns the rendering intent of the profile. This is used to select the ! * proper transform from a profile that has multiple transforms. It is ! * typically set in a source profile to select a transform from an output ! * profile. */ int getRenderingIntent() { byte[] theHeader = getData(icSigHead);/* getData will activate deferred profiles if necessary */
*** 1447,1467 **** * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. */ return (0xffff & renderingIntent); } - /** ! * Returns the number of color components in the "input" color ! * space of this profile. For example if the color space type ! * of this profile is TYPE_RGB, then this method will return 3. ! * ! * @return The number of color components in the profile's input ! * color space. * ! * @throws ProfileDataException if color space is in the profile ! * is invalid */ public int getNumComponents() { byte[] theHeader; int theColorSpaceSig, theNumComponents; --- 1429,1445 ---- * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. */ return (0xffff & renderingIntent); } /** ! * Returns the number of color components in the "input" color space of this ! * profile. For example if the color space type of this profile is ! * {@code TYPE_RGB}, then this method will return 3. * ! * @return the number of color components in the profile's input color space ! * @throws ProfileDataException if color space is in the profile is invalid */ public int getNumComponents() { byte[] theHeader; int theColorSpaceSig, theNumComponents;
*** 1551,1574 **** } return theNumComponents; } - /** ! * Returns a float array of length 3 containing the X, Y, and Z ! * components of the mediaWhitePointTag in the ICC profile. */ float[] getMediaWhitePoint() { return getXYZTag(icSigMediaWhitePointTag); /* get the media white point tag */ } - /** ! * Returns a float array of length 3 containing the X, Y, and Z ! * components encoded in an XYZType tag. */ float[] getXYZTag(int theTagSignature) { byte[] theData; float[] theXYZNumber; int i1, i2, theS15Fixed16; --- 1529,1550 ---- } return theNumComponents; } /** ! * Returns a float array of length 3 containing the X, Y, and Z components ! * of the mediaWhitePointTag in the ICC profile. */ float[] getMediaWhitePoint() { return getXYZTag(icSigMediaWhitePointTag); /* get the media white point tag */ } /** ! * Returns a float array of length 3 containing the X, Y, and Z components ! * encoded in an XYZType tag. */ float[] getXYZTag(int theTagSignature) { byte[] theData; float[] theXYZNumber; int i1, i2, theS15Fixed16;
*** 1585,1605 **** theXYZNumber [i1] = ((float) theS15Fixed16) / 65536.0f; } return theXYZNumber; } - /** ! * Returns a gamma value representing a tone reproduction ! * curve (TRC). If the profile represents the TRC as a table rather ! * than a single gamma value, then an exception is thrown. In this ! * case the actual table can be obtained via getTRC(). ! * theTagSignature should be one of icSigGrayTRCTag, icSigRedTRCTag, ! * icSigGreenTRCTag, or icSigBlueTRCTag. ! * @return the gamma value as a float. ! * @exception ProfileDataException if the profile does not specify ! * the TRC as a single gamma value. */ float getGamma(int theTagSignature) { byte[] theTRCData; float theGamma; int theU8Fixed8; --- 1561,1581 ---- theXYZNumber [i1] = ((float) theS15Fixed16) / 65536.0f; } return theXYZNumber; } /** ! * Returns a gamma value representing a tone reproduction curve (TRC). If ! * the profile represents the TRC as a table rather than a single gamma ! * value, then an exception is thrown. In this case the actual table can be ! * obtained via {@link #getTRC}. {@code theTagSignature} should be one of ! * {@code icSigGrayTRCTag}, {@code icSigRedTRCTag}, ! * {@code icSigGreenTRCTag}, or {@code icSigBlueTRCTag}. ! * ! * @return the gamma value as a float ! * @throws ProfileDataException if the profile does not specify the TRC as a ! * single gamma value */ float getGamma(int theTagSignature) { byte[] theTRCData; float theGamma; int theU8Fixed8;
*** 1618,1647 **** theGamma = ((float) theU8Fixed8) / 256.0f; return theGamma; } - /** ! * Returns the TRC as an array of shorts. If the profile has ! * specified the TRC as linear (gamma = 1.0) or as a simple gamma ! * value, this method throws an exception, and the getGamma() method ! * should be used to get the gamma value. Otherwise the short array ! * returned here represents a lookup table where the input Gray value ! * is conceptually in the range [0.0, 1.0]. Value 0.0 maps ! * to array index 0 and value 1.0 maps to array index length-1. ! * Interpolation may be used to generate output values for ! * input values which do not map exactly to an index in the ! * array. Output values also map linearly to the range [0.0, 1.0]. ! * Value 0.0 is represented by an array value of 0x0000 and ! * value 1.0 by 0xFFFF, i.e. the values are really unsigned ! * short values, although they are returned in a short array. ! * theTagSignature should be one of icSigGrayTRCTag, icSigRedTRCTag, ! * icSigGreenTRCTag, or icSigBlueTRCTag. ! * @return a short array representing the TRC. ! * @exception ProfileDataException if the profile does not specify ! * the TRC as a table. */ short[] getTRC(int theTagSignature) { byte[] theTRCData; short[] theTRC; int i1, i2, nElements, theU8Fixed8; --- 1594,1622 ---- theGamma = ((float) theU8Fixed8) / 256.0f; return theGamma; } /** ! * Returns the TRC as an array of shorts. If the profile has specified the ! * TRC as linear (gamma = 1.0) or as a simple gamma value, this method ! * throws an exception, and the {@link #getGamma} method should be used to ! * get the gamma value. Otherwise the short array returned here represents a ! * lookup table where the input Gray value is conceptually in the range ! * [0.0, 1.0]. Value 0.0 maps to array index 0 and value 1.0 maps to array ! * index length-1. Interpolation may be used to generate output values for ! * input values which do not map exactly to an index in the array. Output ! * values also map linearly to the range [0.0, 1.0]. Value 0.0 is ! * represented by an array value of 0x0000 and value 1.0 by 0xFFFF, i.e. the ! * values are really unsigned short values, although they are returned in a ! * short array. {@code theTagSignature} should be one of ! * {@code icSigGrayTRCTag}, {@code icSigRedTRCTag}, ! * {@code icSigGreenTRCTag}, or {@code icSigBlueTRCTag}. ! * ! * @return a short array representing the TRC ! * @throws ProfileDataException if the profile does not specify the TRC as a ! * table */ short[] getTRC(int theTagSignature) { byte[] theTRCData; short[] theTRC; int i1, i2, nElements, theU8Fixed8;
*** 1664,1675 **** } return theTRC; } ! ! /* convert an ICC color space signature into a Java color space type */ static int iccCStoJCS(int theColorSpaceSig) { int theColorSpace; switch (theColorSpaceSig) { case icSigXYZData: --- 1639,1651 ---- } return theTRC; } ! /** ! * Convert an ICC color space signature into a Java color space type. ! */ static int iccCStoJCS(int theColorSpaceSig) { int theColorSpace; switch (theColorSpaceSig) { case icSigXYZData:
*** 1773,1783 **** break; default: throw new IllegalArgumentException ("Unknown color space"); } - return theColorSpace; } static int intFromBigEndian(byte[] array, int index) { --- 1749,1758 ----
*** 1805,1825 **** static void shortToBigEndian(short value, byte[] array, int index) { array[index] = (byte) (value >> 8); array[index+1] = (byte) (value); } ! ! /* ! * fileName may be an absolute or a relative file specification. ! * Relative file names are looked for in several places: first, relative ! * to any directories specified by the java.iccprofile.path property; ! * second, relative to any directories specified by the java.class.path. ! * The built-in profile files are now loaded as resources, since they ! * may not be individual disk files, and so this method will not find ! * these and on a null return, the caller needs to try as resources. ! * Built-in profiles use .pf as the file name extension for profiles, ! * e.g. sRGB.pf. */ private static File getProfileFile(String fileName) { String path, dir, fullPath; File f = new File(fileName); /* try absolute file name */ --- 1780,1799 ---- static void shortToBigEndian(short value, byte[] array, int index) { array[index] = (byte) (value >> 8); array[index+1] = (byte) (value); } ! /** ! * {@code fileName} may be an absolute or a relative file specification. ! * Relative file names are looked for in several places: first, relative to ! * any directories specified by the {@code java.iccprofile.path} property; ! * second, relative to any directories specified by the ! * {@code java.class.path}. The built-in profile files are now loaded as ! * resources, since they may not be individual disk files, and so this ! * method will not find these and on a {@code null} return, the caller needs ! * to try as resources. Built-in profiles use {@code .pf} as the file name ! * extension for profiles, e.g. {@code sRGB.pf}. */ private static File getProfileFile(String fileName) { String path, dir, fullPath; File f = new File(fileName); /* try absolute file name */
*** 1860,1873 **** } return f; } /** ! * Returns a stream corresponding to a built-in profile ! * specified by fileName. ! * If there is no built-in profile with such name, then the method ! * returns null. */ private static InputStream getStandardProfileInputStream(String fileName) { return AccessController.doPrivileged( new PrivilegedAction<InputStream>() { public InputStream run () { --- 1834,1846 ---- } return f; } /** ! * Returns a stream corresponding to a built-in profile specified by ! * fileName. If there is no built-in profile with such name, then the method ! * returns {@code null}. */ private static InputStream getStandardProfileInputStream(String fileName) { return AccessController.doPrivileged( new PrivilegedAction<InputStream>() { public InputStream run () {
*** 1907,1978 **** return PCMM.class.getResource("profiles/"+fileName) != null; } }); } - /* * Serialization support. * ! * Directly deserialized profiles are useless since they are not ! * registered with CMM. We don't allow constructor to be called ! * directly and instead have clients to call one of getInstance ! * factory methods that will register the profile with CMM. For ! * deserialization we implement readResolve method that will ! * resolve the bogus deserialized profile object with one obtained ! * with getInstance as well. ! * ! * There are two primary factory methods for construction of ICC ! * profiles: getInstance(int cspace) and getInstance(byte[] data). ! * This implementation of ICC_Profile uses the former to return a ! * cached singleton profile object, other implementations will ! * likely use this technique too. To preserve the singleton ! * pattern across serialization we serialize cached singleton ! * profiles in such a way that deserializing VM could call ! * getInstance(int cspace) method that will resolve deserialized ! * object into the corresponding singleton as well. ! * ! * Since the singletons are private to ICC_Profile the readResolve ! * method have to be `protected' instead of `private' so that ! * singletons that are instances of subclasses of ICC_Profile ! * could be correctly deserialized. */ - /** ! * Version of the format of additional serialized data in the ! * stream. Version&nbsp;{@code 1} corresponds to Java&nbsp;2 ! * Platform,&nbsp;v1.3. ! * @since 1.3 * @serial */ private int iccProfileSerializedDataVersion = 1; - /** ! * Writes default serializable fields to the stream. Writes a ! * string and an array of bytes to the stream as additional data. * ! * @param s stream used for serialization. ! * @throws IOException ! * thrown by {@code ObjectInputStream}. ! * @serialData ! * The {@code String} is the name of one of * <code>CS_<var>*</var></code> constants defined in the ! * {@link ColorSpace} class if the profile object is a profile ! * for a predefined color space (for example ! * {@code "CS_sRGB"}). The string is {@code null} ! * otherwise. * <p> ! * The {@code byte[]} array is the profile data for the ! * profile. For predefined color spaces {@code null} is ! * written instead of the profile data. If in the future ! * versions of Java API new predefined color spaces will be ! * added, future versions of this class may choose to write ! * for new predefined color spaces not only the color space ! * name, but the profile data as well so that older versions ! * could still deserialize the object. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); --- 1880,1941 ---- return PCMM.class.getResource("profiles/"+fileName) != null; } }); } /* * Serialization support. * ! * Directly deserialized profiles are useless since they are not registered ! * with CMM. We don't allow constructor to be called directly and instead ! * have clients to call one of getInstance factory methods that will ! * register the profile with CMM. For deserialization we implement ! * readResolve method that will resolve the bogus deserialized profile ! * object with one obtained with getInstance as well. ! * ! * There are two primary factory methods for construction of ICC profiles: ! * getInstance(int cspace) and getInstance(byte[] data). This implementation ! * of ICC_Profile uses the former to return a cached singleton profile ! * object, other implementations will likely use this technique too. To ! * preserve the singleton pattern across serialization we serialize cached ! * singleton profiles in such a way that deserializing VM could call ! * getInstance(int cspace) method that will resolve deserialized object into ! * the corresponding singleton as well. ! * ! * Since the singletons are private to ICC_Profile the readResolve method ! * have to be `protected' instead of `private' so that singletons that are ! * instances of subclasses of ICC_Profile could be correctly deserialized. */ /** ! * Version of the format of additional serialized data in the stream. ! * Version&nbsp;{@code 1} corresponds to Java&nbsp;2 Platform,&nbsp;v1.3. ! * * @serial + * @since 1.3 */ private int iccProfileSerializedDataVersion = 1; /** ! * Writes default serializable fields to the stream. Writes a string and an ! * array of bytes to the stream as additional data. * ! * @param s stream used for serialization ! * @throws IOException thrown by {@code ObjectInputStream} ! * @serialData the {@code String} is the name of one of * <code>CS_<var>*</var></code> constants defined in the ! * {@link ColorSpace} class if the profile object is a profile for a ! * predefined color space (for example {@code "CS_sRGB"}). The ! * string is {@code null} otherwise. * <p> ! * The {@code byte[]} array is the profile data for the profile. For ! * predefined color spaces {@code null} is written instead of the ! * profile data. If in the future versions of Java API new ! * predefined color spaces will be added, future versions of this ! * class may choose to write for new predefined color spaces not ! * only the color space name, but the profile data as well so that ! * older versions could still deserialize the object. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject();
*** 2007,2042 **** // Temporary storage used by readObject to store resolved profile // (obtained with getInstance) for readResolve to return. private transient ICC_Profile resolvedDeserializedProfile; /** ! * Reads default serializable fields from the stream. Reads from ! * the stream a string and an array of bytes as additional data. * ! * @param s stream used for deserialization. ! * @throws IOException ! * thrown by {@code ObjectInputStream}. ! * @throws ClassNotFoundException ! * thrown by {@code ObjectInputStream}. ! * @serialData ! * The {@code String} is the name of one of * <code>CS_<var>*</var></code> constants defined in the ! * {@link ColorSpace} class if the profile object is a profile ! * for a predefined color space (for example ! * {@code "CS_sRGB"}). The string is {@code null} ! * otherwise. * <p> ! * The {@code byte[]} array is the profile data for the ! * profile. It will usually be {@code null} for the ! * predefined profiles. * <p> ! * If the string is recognized as a constant name for ! * predefined color space the object will be resolved into ! * profile obtained with ! * <code>getInstance(int&nbsp;cspace)</code> and the profile ! * data are ignored. Otherwise the object will be resolved ! * into profile obtained with * <code>getInstance(byte[]&nbsp;data)</code>. * @see #readResolve() * @see #getInstance(int) * @see #getInstance(byte[]) */ --- 1970,2002 ---- // Temporary storage used by readObject to store resolved profile // (obtained with getInstance) for readResolve to return. private transient ICC_Profile resolvedDeserializedProfile; /** ! * Reads default serializable fields from the stream. Reads from the stream ! * a string and an array of bytes as additional data. * ! * @param s stream used for deserialization ! * @throws IOException thrown by {@code ObjectInputStream} ! * @throws ClassNotFoundException thrown by {@code ! * ObjectInputStream} ! * @serialData the {@code String} is the name of one of * <code>CS_<var>*</var></code> constants defined in the ! * {@link ColorSpace} class if the profile object is a profile for a ! * predefined color space (for example {@code "CS_sRGB"}). The ! * string is {@code null} otherwise. * <p> ! * The {@code byte[]} array is the profile data for the profile. It ! * will usually be {@code null} for the predefined profiles. * <p> ! * If the string is recognized as a constant name for predefined ! * color space the object will be resolved into profile obtained ! * with ! * <code>getInstance(int&nbsp;cspace)</code> and the profile data ! * are ! * ignored. Otherwise the object will be resolved into profile ! * obtained with * <code>getInstance(byte[]&nbsp;data)</code>. * @see #readResolve() * @see #getInstance(int) * @see #getInstance(byte[]) */
*** 2073,2087 **** resolvedDeserializedProfile = getInstance(data); } } /** ! * Resolves instances being deserialized into instances registered ! * with CMM. ! * @return ICC_Profile object for profile registered with CMM. ! * @throws ObjectStreamException ! * never thrown, but mandated by the serialization spec. * @since 1.3 */ protected Object readResolve() throws ObjectStreamException { return resolvedDeserializedProfile; } --- 2033,2047 ---- resolvedDeserializedProfile = getInstance(data); } } /** ! * Resolves instances being deserialized into instances registered with CMM. ! * ! * @return ICC_Profile object for profile registered with CMM ! * @throws ObjectStreamException never thrown, but mandated by the ! * serialization spec * @since 1.3 */ protected Object readResolve() throws ObjectStreamException { return resolvedDeserializedProfile; }
< prev index next >