1. /*
  2. * @(#)ICC_ProfileGray.java 1.17 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. /**********************************************************************
  11. **********************************************************************
  12. **********************************************************************
  13. *** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
  14. *** As an unpublished work pursuant to Title 17 of the United ***
  15. *** States Code. All rights reserved. ***
  16. **********************************************************************
  17. **********************************************************************
  18. **********************************************************************/
  19. package java.awt.color;
  20. import java.awt.image.LookupTable;
  21. import sun.awt.color.ProfileDeferralInfo;
  22. /**
  23. *
  24. * A subclass of the ICC_Profile class which represents profiles
  25. * which meet the following criteria: the color space type of the
  26. * profile is TYPE_GRAY and the profile includes the grayTRCTag and
  27. * mediaWhitePointTag tags. Examples of this kind of profile are
  28. * monochrome input profiles, monochrome display profiles, and
  29. * monochrome output profiles. The getInstance methods in the
  30. * ICC_Profile class will
  31. * return an ICC_ProfileGray object when the above conditions are
  32. * met. The advantage of this class is that it provides a lookup
  33. * table that Java or native methods may be able to use directly to
  34. * optimize color conversion in some cases.
  35. * <p>
  36. * To transform from a GRAY device profile color space to the CIEXYZ Profile
  37. * Connection Space, the device gray component is transformed by
  38. * a lookup through the tone reproduction curve (TRC). The result is
  39. * treated as the achromatic component of the PCS.
  40. <pre>
  41.   PCSY = grayTRC[deviceGray]
  42. </pre>
  43. * The inverse transform is done by converting the PCS Y components to
  44. * device Gray via the inverse of the grayTRC.
  45. * <p>
  46. */
  47. public class ICC_ProfileGray
  48. extends ICC_Profile {
  49. /**
  50. * Constructs a new ICC_ProfileGray from a CMM ID.
  51. */
  52. ICC_ProfileGray(long ID) {
  53. super(ID);
  54. }
  55. /**
  56. * Constructs a new ICC_ProfileGray from a ProfileDeferralInfo object.
  57. */
  58. ICC_ProfileGray(ProfileDeferralInfo pdi) {
  59. super(pdi);
  60. }
  61. /**
  62. * Returns a float array of length 3 containing the X, Y, and Z
  63. * components of the mediaWhitePointTag in the ICC profile.
  64. */
  65. public float[] getMediaWhitePoint() {
  66. return super.getMediaWhitePoint();
  67. }
  68. /**
  69. * Returns a gamma value representing the tone reproduction
  70. * curve (TRC). If the profile represents the TRC as a table rather
  71. * than a single gamma value, then an exception is thrown. In this
  72. * case the actual table can be obtained via getTRC(). When
  73. * using a gamma value, the PCS Y component is computed as follows:
  74. <pre>
  75.   gamma
  76.   PCSY = deviceGray
  77. </pre>
  78. * @return the gamma value as a float.
  79. * @exception ProfileDataException if the profile does not specify
  80. * the TRC as a single gamma value.
  81. */
  82. public float getGamma() {
  83. float theGamma;
  84. theGamma = super.getGamma(ICC_Profile.icSigGrayTRCTag);
  85. return theGamma;
  86. }
  87. /**
  88. * Returns the TRC as an array of shorts. If the profile has
  89. * specified the TRC as linear (gamma = 1.0) or as a simple gamma
  90. * value, this method throws an exception, and the getGamma() method
  91. * should be used to get the gamma value. Otherwise the short array
  92. * returned here represents a lookup table where the input Gray value
  93. * is conceptually in the range [0.0, 1.0]. Value 0.0 maps
  94. * to array index 0 and value 1.0 maps to array index length-1.
  95. * Interpolation may be used to generate output values for
  96. * input values which do not map exactly to an index in the
  97. * array. Output values also map linearly to the range [0.0, 1.0].
  98. * Value 0.0 is represented by an array value of 0x0000 and
  99. * value 1.0 by 0xFFFF, i.e. the values are really unsigned
  100. * short values, although they are returned in a short array.
  101. * @return a short array representing the TRC.
  102. * @exception ProfileDataException if the profile does not specify
  103. * the TRC as a table.
  104. */
  105. public short[] getTRC() {
  106. short[] theTRC;
  107. theTRC = super.getTRC(ICC_Profile.icSigGrayTRCTag);
  108. return theTRC;
  109. }
  110. }