/[classpath]/classpath/java/awt/color/ICC_ProfileGray.java
ViewVC logotype

Diff of /classpath/java/awt/color/ICC_ProfileGray.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by ericb, Thu Nov 7 15:40:04 2002 UTC revision 1.1.2.1 by gnu_andrew, Sat Jan 15 17:01:48 2005 UTC
# Line 1  Line 1 
1  /* ICC_ProfileGray.java -- the ICC profile for a Gray colorspace  /* ICC_ProfileGray.java -- the ICC profile for a Gray colorspace
2     Copyright (C) 2002 Free Software Foundation, Inc.     Copyright (C) 2002, 2004 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.     This file is part of GNU Classpath.
   
 GNU Classpath is free software; you can redistribute it and/or modify  
 it under the terms of the GNU General Public License as published by  
 the Free Software Foundation; either version 2, or (at your option)  
 any later version.  
   
 GNU Classpath is distributed in the hope that it will be useful, but  
 WITHOUT ANY WARRANTY; without even the implied warranty of  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
 General Public License for more details.  
   
 You should have received a copy of the GNU General Public License  
 along with GNU Classpath; see the file COPYING.  If not, write to the  
 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  
 02111-1307 USA.  
   
 Linking this library statically or dynamically with other modules is  
 making a combined work based on this library.  Thus, the terms and  
 conditions of the GNU General Public License cover the whole  
 combination.  
   
 As a special exception, the copyright holders of this library give you  
 permission to link this library with independent modules to produce an  
 executable, regardless of the license terms of these independent  
 modules, and to copy and distribute the resulting executable under  
 terms of your choice, provided that you also meet, for each linked  
 independent module, the terms and conditions of the license of that  
 module.  An independent module is a module which is not derived from  
 or based on this library.  If you modify this library, you may extend  
 this exception to your version of the library, but you are not  
 obligated to do so.  If you do not wish to do so, delete this  
 exception statement from your version. */  
5    
6       GNU Classpath is free software; you can redistribute it and/or modify
7       it under the terms of the GNU General Public License as published by
8       the Free Software Foundation; either version 2, or (at your option)
9       any later version.
10    
11       GNU Classpath is distributed in the hope that it will be useful, but
12       WITHOUT ANY WARRANTY; without even the implied warranty of
13       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14       General Public License for more details.
15    
16       You should have received a copy of the GNU General Public License
17       along with GNU Classpath; see the file COPYING.  If not, write to the
18       Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19       02111-1307 USA.
20    
21       Linking this library statically or dynamically with other modules is
22       making a combined work based on this library.  Thus, the terms and
23       conditions of the GNU General Public License cover the whole
24       combination.
25    
26       As a special exception, the copyright holders of this library give you
27       permission to link this library with independent modules to produce an
28       executable, regardless of the license terms of these independent
29       modules, and to copy and distribute the resulting executable under
30       terms of your choice, provided that you also meet, for each linked
31       independent module, the terms and conditions of the license of that
32       module.  An independent module is a module which is not derived from
33       or based on this library.  If you modify this library, you may extend
34       this exception to your version of the library, but you are not
35       obligated to do so.  If you do not wish to do so, delete this
36       exception statement from your version. */
37    
38  package java.awt.color;  package java.awt.color;
39    
40    
41  /**  /**
42   * STUBBED   * ICC_ProfileGray - a special case of ICC_Profiles.
43     *
44     * The ICC_Profile.getInstance() method will return an instance of the
45     * ICC_ProfileGray subclass when all the following conditions are met:
46     * The device color space of the profile is TYPE_GRAY.
47     * The profile contains a gray TRCTag.
48     * The profile contains a mediaWhitePointTag.
49     *
50     * As per the ICC specification, the color space conversion can then
51     * be done through the following method:
52     * linearGray = grayTRC[deviceGray]
53     *
54     * Note that if the profile contains a CLUT for the color space conversion,
55     * it should be used instead, and the TRC information ignored.
56     *
57     * @author Sven de Marothy
58   * @since 1.2   * @since 1.2
59   */   */
60  public class ICC_ProfileGray extends ICC_Profile  public class ICC_ProfileGray extends ICC_Profile
# Line 48  public class ICC_ProfileGray extends ICC Line 63  public class ICC_ProfileGray extends ICC
63     * Compatible with JDK 1.2+.     * Compatible with JDK 1.2+.
64     */     */
65    private static final long serialVersionUID = -1124721290732002649L;    private static final long serialVersionUID = -1124721290732002649L;
66      private transient float[] whitePoint;
67    
68      /**
69       * Package-private constructor used by ICC_ColorSpace for creating an
70       * ICC_ProfileGray from a predefined ColorSpace (CS_GRAY)
71       */
72      ICC_ProfileGray(int cspace)
73      {
74        super(cspace);
75        whitePoint = getXYZData(icSigMediaWhitePointTag);
76      }
77    
78    ICC_ProfileGray()    /**
79       * Package-private constructor used by ICC_ColorSpace for creating an
80       * ICC_ProfileGray from profile data.
81       */
82      ICC_ProfileGray(byte[] data)
83    {    {
84      super(ColorSpace.CS_GRAY);      super(data);
85        whitePoint = getXYZData(icSigMediaWhitePointTag);
86    }    }
87    
88    
89      /**
90       * Returns the media white point of the profile.
91       */
92    public float[] getMediaWhitePoint()    public float[] getMediaWhitePoint()
93    {    {
94      return null;      float[] wp = new float[3];
95        wp[0] = whitePoint[0];
96        wp[1] = whitePoint[1];
97        wp[2] = whitePoint[2];
98        return wp;
99    }    }
100    
101      /**
102       * Returns the TRC gamma value.
103       * @throws ProfileDataException if the TRC is described by a lookup
104       * table and not a gamma value.
105       */
106    public float getGamma()    public float getGamma()
107    {    {
108      return 0;      short[] data = getCurve(icSigGrayTRCTag);
109        if (data == null)
110          throw new IllegalArgumentException("Couldn't read Gray TRC data.");
111        if (data.length != 1)
112          throw new ProfileDataException("TRC is a table, not a gamma value.");
113    
114        // convert the unsigned 7.8 fixed-point gamma to a float.
115        double gamma = (double) (data[0] & (0xFFFF)) / 256.0;
116        return (float) gamma;
117    }    }
118    
119      /**
120       * Returns the TRC lookup table.
121       * @throws ProfileDataException if the TRC is described by a gamma value
122       * and not a lookup table.
123       */
124    public short[] getTRC()    public short[] getTRC()
125    {    {
126      return null;      short[] data = getCurve(icSigGrayTRCTag);
127        if (data == null)
128          throw new IllegalArgumentException("Couldn't read Gray TRC data.");
129        if (data.length <= 1)
130          throw new ProfileDataException("Gamma value, not a TRC table.");
131        return data;
132    }    }
133  } // class ICC_ProfileGray  } // class ICC_ProfileGray

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26