jdk/src/share/classes/java/awt/color/ICC_ProfileGray.java
changeset 539 7952521a4ad3
child 715 f16baef3a20e
equal deleted inserted replaced
538:d95bc71a5732 539:7952521a4ad3
       
     1 /*
       
     2  * Portions Copyright 1997-2007 Sun Microsystems, Inc.  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.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 /**********************************************************************
       
    27  **********************************************************************
       
    28  **********************************************************************
       
    29  *** COPYRIGHT (c) Eastman Kodak Company, 1997                      ***
       
    30  *** As  an unpublished  work pursuant to Title 17 of the United    ***
       
    31  *** States Code.  All rights reserved.                             ***
       
    32  **********************************************************************
       
    33  **********************************************************************
       
    34  **********************************************************************/
       
    35 
       
    36 package java.awt.color;
       
    37 
       
    38 import java.awt.image.LookupTable;
       
    39 import sun.java2d.cmm.ProfileDeferralInfo;
       
    40 
       
    41 /**
       
    42  *
       
    43  * A subclass of the ICC_Profile class which represents profiles
       
    44  * which meet the following criteria: the color space type of the
       
    45  * profile is TYPE_GRAY and the profile includes the grayTRCTag and
       
    46  * mediaWhitePointTag tags.  Examples of this kind of profile are
       
    47  * monochrome input profiles, monochrome display profiles, and
       
    48  * monochrome output profiles.  The getInstance methods in the
       
    49  * ICC_Profile class will
       
    50  * return an ICC_ProfileGray object when the above conditions are
       
    51  * met.  The advantage of this class is that it provides a lookup
       
    52  * table that Java or native methods may be able to use directly to
       
    53  * optimize color conversion in some cases.
       
    54  * <p>
       
    55  * To transform from a GRAY device profile color space to the CIEXYZ Profile
       
    56  * Connection Space, the device gray component is transformed by
       
    57  * a lookup through the tone reproduction curve (TRC).  The result is
       
    58  * treated as the achromatic component of the PCS.
       
    59 <pre>
       
    60 
       
    61 &nbsp;               PCSY = grayTRC[deviceGray]
       
    62 
       
    63 </pre>
       
    64  * The inverse transform is done by converting the PCS Y components to
       
    65  * device Gray via the inverse of the grayTRC.
       
    66  * <p>
       
    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(long ID) {
       
    80         super(ID);
       
    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 &nbsp;                         gamma
       
   111 &nbsp;        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 }