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