src/share/classes/java/awt/color/ICC_ColorSpace.java

Print this page




 132     * @return the ICC_Profile for this ICC_ColorSpace.
 133     */
 134     public ICC_Profile getProfile() {
 135         return thisProfile;
 136     }
 137 
 138     /**
 139      * Transforms a color value assumed to be in this ColorSpace
 140      * into a value in the default CS_sRGB color space.
 141      * <p>
 142      * This method transforms color values using algorithms designed
 143      * to produce the best perceptual match between input and output
 144      * colors.  In order to do colorimetric conversion of color values,
 145      * you should use the <code>toCIEXYZ</code>
 146      * method of this color space to first convert from the input
 147      * color space to the CS_CIEXYZ color space, and then use the
 148      * <code>fromCIEXYZ</code> method of the CS_sRGB color space to
 149      * convert from CS_CIEXYZ to the output color space.
 150      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
 151      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
 152      * <p>
 153      * @param colorvalue a float array with length of at least the number
 154      *      of components in this ColorSpace.
 155      * @return a float array of length 3.
 156      * @throws ArrayIndexOutOfBoundsException if array length is not
 157      * at least the number of components in this ColorSpace.
 158      */
 159     public float[]    toRGB (float[] colorvalue) {
 160 
 161         if (this2srgb == null) {
 162             ColorTransform[] transformList = new ColorTransform [2];
 163             ICC_ColorSpace srgbCS =
 164                 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB);
 165             PCMM mdl = CMSManager.getModule();
 166             transformList[0] = mdl.createTransform(
 167                 thisProfile, ColorTransform.Any, ColorTransform.In);
 168             transformList[1] = mdl.createTransform(
 169                 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.Out);
 170             this2srgb = mdl.createTransform(transformList);
 171             if (needScaleInit) {
 172                 setComponentScaling();


 184         for (int i = 0; i < 3; i++) {
 185             result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f;
 186         }
 187         return result;
 188     }
 189 
 190     /**
 191      * Transforms a color value assumed to be in the default CS_sRGB
 192      * color space into this ColorSpace.
 193      * <p>
 194      * This method transforms color values using algorithms designed
 195      * to produce the best perceptual match between input and output
 196      * colors.  In order to do colorimetric conversion of color values,
 197      * you should use the <code>toCIEXYZ</code>
 198      * method of the CS_sRGB color space to first convert from the input
 199      * color space to the CS_CIEXYZ color space, and then use the
 200      * <code>fromCIEXYZ</code> method of this color space to
 201      * convert from CS_CIEXYZ to the output color space.
 202      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
 203      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
 204      * <p>
 205      * @param rgbvalue a float array with length of at least 3.
 206      * @return a float array with length equal to the number of
 207      *       components in this ColorSpace.
 208      * @throws ArrayIndexOutOfBoundsException if array length is not
 209      * at least 3.
 210      */
 211     public float[]    fromRGB(float[] rgbvalue) {
 212 
 213         if (srgb2this == null) {
 214             ColorTransform[] transformList = new ColorTransform [2];
 215             ICC_ColorSpace srgbCS =
 216                 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB);
 217             PCMM mdl = CMSManager.getModule();
 218             transformList[0] = mdl.createTransform(
 219                 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.In);
 220             transformList[1] = mdl.createTransform(
 221                 thisProfile, ColorTransform.Any, ColorTransform.Out);
 222             srgb2this = mdl.createTransform(transformList);
 223             if (needScaleInit) {
 224                 setComponentScaling();


 319      * Conversion from the PCS to the device would be done by inverting these
 320      * equations:
 321      * <pre>
 322      *
 323      * Xd = Xp * (Xdw / Xd50)
 324      * Yd = Yp * (Ydw / Yd50)
 325      * Zd = Zp * (Zdw / Zd50)
 326      *
 327      * </pre>
 328      * <p>
 329      * Note that the media white point tag in an ICC profile is not the same
 330      * as the device white point.  The media white point tag is expressed in
 331      * PCS values and is used to represent the difference between the XYZ of
 332      * device illuminant and the XYZ of the device media when measured under
 333      * that illuminant.  The device white point is expressed as the device
 334      * XYZ values corresponding to white displayed on the device.  For
 335      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
 336      * will result in a measured device XYZ value of D65.  This will not
 337      * be the same as the media white point tag XYZ value in the ICC
 338      * profile for an sRGB device.
 339      * <p>
 340      * @param colorvalue a float array with length of at least the number
 341      *        of components in this ColorSpace.
 342      * @return a float array of length 3.
 343      * @throws ArrayIndexOutOfBoundsException if array length is not
 344      * at least the number of components in this ColorSpace.
 345      */
 346     public float[]    toCIEXYZ(float[] colorvalue) {
 347 
 348         if (this2xyz == null) {
 349             ColorTransform[] transformList = new ColorTransform [2];
 350             ICC_ColorSpace xyzCS =
 351                 (ICC_ColorSpace) ColorSpace.getInstance (CS_CIEXYZ);
 352             PCMM mdl = CMSManager.getModule();
 353             try {
 354                 transformList[0] = mdl.createTransform(
 355                     thisProfile, ICC_Profile.icRelativeColorimetric,
 356                     ColorTransform.In);
 357             } catch (CMMException e) {
 358                 transformList[0] = mdl.createTransform(
 359                     thisProfile, ColorTransform.Any, ColorTransform.In);


 463      * Conversion from the PCS to the device would be done by inverting these
 464      * equations:
 465      * <pre>
 466      *
 467      * Xd = Xp * (Xdw / Xd50)
 468      * Yd = Yp * (Ydw / Yd50)
 469      * Zd = Zp * (Zdw / Zd50)
 470      *
 471      * </pre>
 472      * <p>
 473      * Note that the media white point tag in an ICC profile is not the same
 474      * as the device white point.  The media white point tag is expressed in
 475      * PCS values and is used to represent the difference between the XYZ of
 476      * device illuminant and the XYZ of the device media when measured under
 477      * that illuminant.  The device white point is expressed as the device
 478      * XYZ values corresponding to white displayed on the device.  For
 479      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
 480      * will result in a measured device XYZ value of D65.  This will not
 481      * be the same as the media white point tag XYZ value in the ICC
 482      * profile for an sRGB device.
 483      * <p>
 484      * @param colorvalue a float array with length of at least 3.
 485      * @return a float array with length equal to the number of
 486      *         components in this ColorSpace.
 487      * @throws ArrayIndexOutOfBoundsException if array length is not
 488      * at least 3.
 489      */
 490     public float[]    fromCIEXYZ(float[] colorvalue) {
 491 
 492         if (xyz2this == null) {
 493             ColorTransform[] transformList = new ColorTransform [2];
 494             ICC_ColorSpace xyzCS =
 495                 (ICC_ColorSpace) ColorSpace.getInstance (CS_CIEXYZ);
 496             PCMM mdl = CMSManager.getModule();
 497             transformList[0] = mdl.createTransform (
 498                 xyzCS.getProfile(), ColorTransform.Any, ColorTransform.In);
 499             try {
 500                 transformList[1] = mdl.createTransform(
 501                     thisProfile, ICC_Profile.icRelativeColorimetric,
 502                     ColorTransform.Out);
 503             } catch (CMMException e) {




 132     * @return the ICC_Profile for this ICC_ColorSpace.
 133     */
 134     public ICC_Profile getProfile() {
 135         return thisProfile;
 136     }
 137 
 138     /**
 139      * Transforms a color value assumed to be in this ColorSpace
 140      * into a value in the default CS_sRGB color space.
 141      * <p>
 142      * This method transforms color values using algorithms designed
 143      * to produce the best perceptual match between input and output
 144      * colors.  In order to do colorimetric conversion of color values,
 145      * you should use the <code>toCIEXYZ</code>
 146      * method of this color space to first convert from the input
 147      * color space to the CS_CIEXYZ color space, and then use the
 148      * <code>fromCIEXYZ</code> method of the CS_sRGB color space to
 149      * convert from CS_CIEXYZ to the output color space.
 150      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
 151      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
 152      *
 153      * @param colorvalue a float array with length of at least the number
 154      *      of components in this ColorSpace.
 155      * @return a float array of length 3.
 156      * @throws ArrayIndexOutOfBoundsException if array length is not
 157      * at least the number of components in this ColorSpace.
 158      */
 159     public float[]    toRGB (float[] colorvalue) {
 160 
 161         if (this2srgb == null) {
 162             ColorTransform[] transformList = new ColorTransform [2];
 163             ICC_ColorSpace srgbCS =
 164                 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB);
 165             PCMM mdl = CMSManager.getModule();
 166             transformList[0] = mdl.createTransform(
 167                 thisProfile, ColorTransform.Any, ColorTransform.In);
 168             transformList[1] = mdl.createTransform(
 169                 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.Out);
 170             this2srgb = mdl.createTransform(transformList);
 171             if (needScaleInit) {
 172                 setComponentScaling();


 184         for (int i = 0; i < 3; i++) {
 185             result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f;
 186         }
 187         return result;
 188     }
 189 
 190     /**
 191      * Transforms a color value assumed to be in the default CS_sRGB
 192      * color space into this ColorSpace.
 193      * <p>
 194      * This method transforms color values using algorithms designed
 195      * to produce the best perceptual match between input and output
 196      * colors.  In order to do colorimetric conversion of color values,
 197      * you should use the <code>toCIEXYZ</code>
 198      * method of the CS_sRGB color space to first convert from the input
 199      * color space to the CS_CIEXYZ color space, and then use the
 200      * <code>fromCIEXYZ</code> method of this color space to
 201      * convert from CS_CIEXYZ to the output color space.
 202      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
 203      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
 204      *
 205      * @param rgbvalue a float array with length of at least 3.
 206      * @return a float array with length equal to the number of
 207      *       components in this ColorSpace.
 208      * @throws ArrayIndexOutOfBoundsException if array length is not
 209      * at least 3.
 210      */
 211     public float[]    fromRGB(float[] rgbvalue) {
 212 
 213         if (srgb2this == null) {
 214             ColorTransform[] transformList = new ColorTransform [2];
 215             ICC_ColorSpace srgbCS =
 216                 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB);
 217             PCMM mdl = CMSManager.getModule();
 218             transformList[0] = mdl.createTransform(
 219                 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.In);
 220             transformList[1] = mdl.createTransform(
 221                 thisProfile, ColorTransform.Any, ColorTransform.Out);
 222             srgb2this = mdl.createTransform(transformList);
 223             if (needScaleInit) {
 224                 setComponentScaling();


 319      * Conversion from the PCS to the device would be done by inverting these
 320      * equations:
 321      * <pre>
 322      *
 323      * Xd = Xp * (Xdw / Xd50)
 324      * Yd = Yp * (Ydw / Yd50)
 325      * Zd = Zp * (Zdw / Zd50)
 326      *
 327      * </pre>
 328      * <p>
 329      * Note that the media white point tag in an ICC profile is not the same
 330      * as the device white point.  The media white point tag is expressed in
 331      * PCS values and is used to represent the difference between the XYZ of
 332      * device illuminant and the XYZ of the device media when measured under
 333      * that illuminant.  The device white point is expressed as the device
 334      * XYZ values corresponding to white displayed on the device.  For
 335      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
 336      * will result in a measured device XYZ value of D65.  This will not
 337      * be the same as the media white point tag XYZ value in the ICC
 338      * profile for an sRGB device.
 339      *
 340      * @param colorvalue a float array with length of at least the number
 341      *        of components in this ColorSpace.
 342      * @return a float array of length 3.
 343      * @throws ArrayIndexOutOfBoundsException if array length is not
 344      * at least the number of components in this ColorSpace.
 345      */
 346     public float[]    toCIEXYZ(float[] colorvalue) {
 347 
 348         if (this2xyz == null) {
 349             ColorTransform[] transformList = new ColorTransform [2];
 350             ICC_ColorSpace xyzCS =
 351                 (ICC_ColorSpace) ColorSpace.getInstance (CS_CIEXYZ);
 352             PCMM mdl = CMSManager.getModule();
 353             try {
 354                 transformList[0] = mdl.createTransform(
 355                     thisProfile, ICC_Profile.icRelativeColorimetric,
 356                     ColorTransform.In);
 357             } catch (CMMException e) {
 358                 transformList[0] = mdl.createTransform(
 359                     thisProfile, ColorTransform.Any, ColorTransform.In);


 463      * Conversion from the PCS to the device would be done by inverting these
 464      * equations:
 465      * <pre>
 466      *
 467      * Xd = Xp * (Xdw / Xd50)
 468      * Yd = Yp * (Ydw / Yd50)
 469      * Zd = Zp * (Zdw / Zd50)
 470      *
 471      * </pre>
 472      * <p>
 473      * Note that the media white point tag in an ICC profile is not the same
 474      * as the device white point.  The media white point tag is expressed in
 475      * PCS values and is used to represent the difference between the XYZ of
 476      * device illuminant and the XYZ of the device media when measured under
 477      * that illuminant.  The device white point is expressed as the device
 478      * XYZ values corresponding to white displayed on the device.  For
 479      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
 480      * will result in a measured device XYZ value of D65.  This will not
 481      * be the same as the media white point tag XYZ value in the ICC
 482      * profile for an sRGB device.
 483      *
 484      * @param colorvalue a float array with length of at least 3.
 485      * @return a float array with length equal to the number of
 486      *         components in this ColorSpace.
 487      * @throws ArrayIndexOutOfBoundsException if array length is not
 488      * at least 3.
 489      */
 490     public float[]    fromCIEXYZ(float[] colorvalue) {
 491 
 492         if (xyz2this == null) {
 493             ColorTransform[] transformList = new ColorTransform [2];
 494             ICC_ColorSpace xyzCS =
 495                 (ICC_ColorSpace) ColorSpace.getInstance (CS_CIEXYZ);
 496             PCMM mdl = CMSManager.getModule();
 497             transformList[0] = mdl.createTransform (
 498                 xyzCS.getProfile(), ColorTransform.Any, ColorTransform.In);
 499             try {
 500                 transformList[1] = mdl.createTransform(
 501                     thisProfile, ICC_Profile.icRelativeColorimetric,
 502                     ColorTransform.Out);
 503             } catch (CMMException e) {