1. /*
  2. * @(#)ICC_ProfileGray.java 1.16 01/11/29
  3. *
  4. * Copyright 2002 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. */
  62. public float[] getMediaWhitePoint() {
  63. return super.getMediaWhitePoint();
  64. }
  65. /**
  66. * Returns a gamma value representing the tone reproduction
  67. * curve (TRC). If the profile represents the TRC as a table rather
  68. * than a single gamma value, then an exception is thrown. In this
  69. * case the actual table can be obtained via getTRC(). When
  70. * using a gamma value, the PCS Y component is computed as follows:
  71. <pre>
  72.   gamma
  73.   PCSY = deviceGray
  74. </pre>
  75. * @return the gamma value as a float.
  76. * @exception ProfileDataException if the profile does not specify
  77. * the TRC as a single gamma value.
  78. */
  79. public float getGamma() {
  80. float theGamma;
  81. theGamma = super.getGamma(ICC_Profile.icSigGrayTRCTag);
  82. return theGamma;
  83. }
  84. /**
  85. * Returns the TRC as an array of shorts. If the profile has
  86. * specified the TRC as linear (gamma = 1.0) or as a simple gamma
  87. * value, this method throws an exception, and the getGamma() method
  88. * should be used to get the gamma value. Otherwise the short array
  89. * returned here represents a lookup table where the input Gray value
  90. * is conceptually in the range [0.0, 1.0]. Value 0.0 maps
  91. * to array index 0 and value 1.0 maps to array index length-1.
  92. * Interpolation may be used to generate output values for
  93. * input values which do not map exactly to an index in the
  94. * array. Output values also map linearly to the range [0.0, 1.0].
  95. * Value 0.0 is represented by an array value of 0x0000 and
  96. * value 1.0 by 0xFFFF, i.e. the values are really unsigned
  97. * short values, although they are returned in a short array.
  98. * @return a short array representing the TRC.
  99. * @exception ProfileDataException if the profile does not specify
  100. * the TRC as a table.
  101. */
  102. public short[] getTRC() {
  103. short[] theTRC;
  104. theTRC = super.getTRC(ICC_Profile.icSigGrayTRCTag);
  105. return theTRC;
  106. }
  107. }