1 /* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /* 27 ********************************************************************** 28 ********************************************************************** 29 ********************************************************************** 30 *** COPYRIGHT (c) Eastman Kodak Company, 1997 *** 31 *** As an unpublished work pursuant to Title 17 of the United *** 32 *** States Code. All rights reserved. *** 33 ********************************************************************** 34 ********************************************************************** 35 **********************************************************************/ 36 37 package java.awt.color; 38 39 import sun.java2d.cmm.Profile; 40 import sun.java2d.cmm.ProfileDeferralInfo; 41 42 /** 43 * 44 * A subclass of the ICC_Profile class which represents profiles 45 * which meet the following criteria: the color space type of the 46 * profile is TYPE_GRAY and the profile includes the grayTRCTag and 47 * mediaWhitePointTag tags. Examples of this kind of profile are 48 * monochrome input profiles, monochrome display profiles, and 49 * monochrome output profiles. The getInstance methods in the 50 * ICC_Profile class will 51 * return an ICC_ProfileGray object when the above conditions are 52 * met. The advantage of this class is that it provides a lookup 53 * table that Java or native methods may be able to use directly to 54 * optimize color conversion in some cases. 55 * <p> 56 * To transform from a GRAY device profile color space to the CIEXYZ Profile 57 * Connection Space, the device gray component is transformed by 58 * a lookup through the tone reproduction curve (TRC). The result is 59 * treated as the achromatic component of the PCS. 60 <pre> 61 62 PCSY = grayTRC[deviceGray] 63 64 </pre> 65 * The inverse transform is done by converting the PCS Y components to 66 * device Gray via the inverse of the grayTRC. 67 */ 68 69 70 71 public class ICC_ProfileGray 72 extends ICC_Profile { 73 74 static final long serialVersionUID = -1124721290732002649L; 75 76 /** 77 * Constructs a new ICC_ProfileGray from a CMM ID. 78 */ 79 ICC_ProfileGray(Profile p) { 80 super(p); 81 } 82 83 /** 84 * Constructs a new ICC_ProfileGray from a ProfileDeferralInfo object. 85 */ 86 ICC_ProfileGray(ProfileDeferralInfo pdi) { 87 super(pdi); 88 } 89 90 91 /** 92 * Returns a float array of length 3 containing the X, Y, and Z 93 * components of the mediaWhitePointTag in the ICC profile. 94 * @return an array containing the components of the 95 * mediaWhitePointTag in the ICC profile. 96 */ 97 public float[] getMediaWhitePoint() { 98 return super.getMediaWhitePoint(); 99 } 100 101 102 /** 103 * Returns a gamma value representing the tone reproduction 104 * curve (TRC). If the profile represents the TRC as a table rather 105 * than a single gamma value, then an exception is thrown. In this 106 * case the actual table can be obtained via getTRC(). When 107 * using a gamma value, the PCS Y component is computed as follows: 108 <pre> 109 110 gamma 111 PCSY = deviceGray 112 113 </pre> 114 * @return the gamma value as a float. 115 * @exception ProfileDataException if the profile does not specify 116 * the TRC as a single gamma value. 117 */ 118 public float getGamma() { 119 float theGamma; 120 121 theGamma = super.getGamma(ICC_Profile.icSigGrayTRCTag); 122 return theGamma; 123 } 124 125 /** 126 * Returns the TRC as an array of shorts. If the profile has 127 * specified the TRC as linear (gamma = 1.0) or as a simple gamma 128 * value, this method throws an exception, and the getGamma() method 129 * should be used to get the gamma value. Otherwise the short array 130 * returned here represents a lookup table where the input Gray value 131 * is conceptually in the range [0.0, 1.0]. Value 0.0 maps 132 * to array index 0 and value 1.0 maps to array index length-1. 133 * Interpolation may be used to generate output values for 134 * input values which do not map exactly to an index in the 135 * array. Output values also map linearly to the range [0.0, 1.0]. 136 * Value 0.0 is represented by an array value of 0x0000 and 137 * value 1.0 by 0xFFFF, i.e. the values are really unsigned 138 * short values, although they are returned in a short array. 139 * @return a short array representing the TRC. 140 * @exception ProfileDataException if the profile does not specify 141 * the TRC as a table. 142 */ 143 public short[] getTRC() { 144 short[] theTRC; 145 146 theTRC = super.getTRC(ICC_Profile.icSigGrayTRCTag); 147 return theTRC; 148 } 149 150 }