KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > color > ICC_ColorSpace


1 /*
2  * @(#)ICC_ColorSpace.java 1.31 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 /**********************************************************************
9  **********************************************************************
10  **********************************************************************
11  *** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
12  *** As an unpublished work pursuant to Title 17 of the United ***
13  *** States Code. All rights reserved. ***
14  **********************************************************************
15  **********************************************************************
16  **********************************************************************/

17
18 package java.awt.color;
19
20 import sun.awt.color.ICC_Transform;
21
22
23 /**
24  *
25  * The ICC_ColorSpace class is an implementation of the abstract
26  * ColorSpace class. This representation of
27  * device independent and device dependent color spaces is based on the
28  * International Color Consortium Specification ICC.1:2001-12, File Format for
29  * Color Profiles (see <A HREF="http://www.color.org">http://www.color.org</A>).
30  * <p>
31  * Typically, a Color or ColorModel would be associated with an ICC
32  * Profile which is either an input, display, or output profile (see
33  * the ICC specification). There are other types of ICC Profiles, e.g.
34  * abstract profiles, device link profiles, and named color profiles,
35  * which do not contain information appropriate for representing the color
36  * space of a color, image, or device (see ICC_Profile).
37  * Attempting to create an ICC_ColorSpace object from an inappropriate ICC
38  * Profile is an error.
39  * <p>
40  * ICC Profiles represent transformations from the color space of
41  * the profile (e.g. a monitor) to a Profile Connection Space (PCS).
42  * Profiles of interest for tagging images or colors have a
43  * PCS which is one of the device independent
44  * spaces (one CIEXYZ space and two CIELab spaces) defined in the
45  * ICC Profile Format Specification. Most profiles of interest
46  * either have invertible transformations or explicitly specify
47  * transformations going both directions. Should an ICC_ColorSpace
48  * object be used in a way requiring a conversion from PCS to
49  * the profile's native space and there is inadequate data to
50  * correctly perform the conversion, the ICC_ColorSpace object will
51  * produce output in the specified type of color space (e.g. TYPE_RGB,
52  * TYPE_CMYK, etc.), but the specific color values of the output data
53  * will be undefined.
54  * <p>
55  * The details of this class are not important for simple applets,
56  * which draw in a default color space or manipulate and display
57  * imported images with a known color space. At most, such applets
58  * would need to get one of the default color spaces via
59  * ColorSpace.getInstance().
60  * <p>
61  * @see ColorSpace
62  * @see ICC_Profile
63  */

64
65
66
67 public class ICC_ColorSpace extends ColorSpace JavaDoc {
68
69     static final long serialVersionUID = 3455889114070431483L;
70
71     private ICC_Profile JavaDoc thisProfile;
72     private float[] minVal;
73     private float[] maxVal;
74     private float[] diffMinMax;
75     private float[] invDiffMinMax;
76     private boolean needScaleInit = true;
77
78     // {to,from}{RGB,CIEXYZ} methods create and cache these when needed
79
private transient ICC_Transform this2srgb;
80     private transient ICC_Transform srgb2this;
81     private transient ICC_Transform this2xyz;
82     private transient ICC_Transform xyz2this;
83   
84
85     /**
86     * Constructs a new ICC_ColorSpace from an ICC_Profile object.
87     * @param profile the specified ICC_Profile object
88     * @exception IllegalArgumentException if profile is inappropriate for
89     * representing a ColorSpace.
90     */

91     public ICC_ColorSpace (ICC_Profile JavaDoc profile) {
92         super (profile.getColorSpaceType(), profile.getNumComponents());
93
94         int profileClass = profile.getProfileClass();
95
96         /* REMIND - is NAMEDCOLOR OK? */
97         if ((profileClass != ICC_Profile.CLASS_INPUT) &&
98             (profileClass != ICC_Profile.CLASS_DISPLAY) &&
99             (profileClass != ICC_Profile.CLASS_OUTPUT) &&
100             (profileClass != ICC_Profile.CLASS_COLORSPACECONVERSION) &&
101             (profileClass != ICC_Profile.CLASS_NAMEDCOLOR) ) {
102             throw new IllegalArgumentException JavaDoc("Invalid profile type");
103         }
104
105         thisProfile = profile;
106         setMinMax();
107     }
108
109     /**
110     * Returns the ICC_Profile for this ICC_ColorSpace.
111     * @return the ICC_Profile for this ICC_ColorSpace.
112     */

113     public ICC_Profile JavaDoc getProfile() {
114         return thisProfile;
115     }
116
117     /**
118      * Transforms a color value assumed to be in this ColorSpace
119      * into a value in the default CS_sRGB color space.
120      * <p>
121      * This method transforms color values using algorithms designed
122      * to produce the best perceptual match between input and output
123      * colors. In order to do colorimetric conversion of color values,
124      * you should use the <code>toCIEXYZ</code>
125      * method of this color space to first convert from the input
126      * color space to the CS_CIEXYZ color space, and then use the
127      * <code>fromCIEXYZ</code> method of the CS_sRGB color space to
128      * convert from CS_CIEXYZ to the output color space.
129      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
130      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
131      * <p>
132      * @param colorvalue a float array with length of at least the number
133      * of components in this ColorSpace.
134      * @return a float array of length 3.
135      * @throws ArrayIndexOutOfBoundsException if array length is not
136      * at least the number of components in this ColorSpace.
137      */

138     public float[] toRGB (float[] colorvalue) {
139     
140         if (this2srgb == null) {
141             ICC_Transform[] transformList = new ICC_Transform [2];
142             ICC_ColorSpace JavaDoc srgbCS =
143                 (ICC_ColorSpace JavaDoc) ColorSpace.getInstance (CS_sRGB);
144             transformList[0] = new ICC_Transform (
145                 thisProfile, ICC_Transform.Any, ICC_Transform.In);
146             transformList[1] = new ICC_Transform (
147                 srgbCS.getProfile(), ICC_Transform.Any, ICC_Transform.Out);
148             this2srgb = new ICC_Transform (transformList);
149             if (needScaleInit) {
150                 setComponentScaling();
151             }
152         }
153
154         int nc = this.getNumComponents();
155         short tmp[] = new short[nc];
156         for (int i = 0; i < nc; i++) {
157             tmp[i] = (short)
158                 ((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f);
159         }
160         tmp = this2srgb.colorConvert(tmp, null);
161         float[] result = new float [3];
162         for (int i = 0; i < 3; i++) {
163             result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f;
164         }
165         return result;
166     }
167
168     /**
169      * Transforms a color value assumed to be in the default CS_sRGB
170      * color space into this ColorSpace.
171      * <p>
172      * This method transforms color values using algorithms designed
173      * to produce the best perceptual match between input and output
174      * colors. In order to do colorimetric conversion of color values,
175      * you should use the <code>toCIEXYZ</code>
176      * method of the CS_sRGB color space to first convert from the input
177      * color space to the CS_CIEXYZ color space, and then use the
178      * <code>fromCIEXYZ</code> method of this color space to
179      * convert from CS_CIEXYZ to the output color space.
180      * See {@link #toCIEXYZ(float[]) toCIEXYZ} and
181      * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information.
182      * <p>
183      * @param rgbvalue a float array with length of at least 3.
184      * @return a float array with length equal to the number of
185      * components in this ColorSpace.
186      * @throws ArrayIndexOutOfBoundsException if array length is not
187      * at least 3.
188      */

189     public float[] fromRGB(float[] rgbvalue) {
190     
191         if (srgb2this == null) {
192             ICC_Transform[] transformList = new ICC_Transform [2];
193             ICC_ColorSpace JavaDoc srgbCS =
194                 (ICC_ColorSpace JavaDoc) ColorSpace.getInstance (CS_sRGB);
195             transformList[0] = new ICC_Transform (
196                 srgbCS.getProfile(), ICC_Transform.Any, ICC_Transform.In);
197             transformList[1] = new ICC_Transform (
198                 thisProfile, ICC_Transform.Any, ICC_Transform.Out);
199             srgb2this = new ICC_Transform (transformList);
200             if (needScaleInit) {
201                 setComponentScaling();
202             }
203         }
204
205         short tmp[] = new short[3];
206         for (int i = 0; i < 3; i++) {
207             tmp[i] = (short) ((rgbvalue[i] * 65535.0f) + 0.5f);
208         }
209         tmp = srgb2this.colorConvert(tmp, null);
210         int nc = this.getNumComponents();
211         float[] result = new float [nc];
212         for (int i = 0; i < nc; i++) {
213             result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
214                         diffMinMax[i] + minVal[i];
215         }
216         return result;
217     }
218
219
220     /**
221      * Transforms a color value assumed to be in this ColorSpace
222      * into the CS_CIEXYZ conversion color space.
223      * <p>
224      * This method transforms color values using relative colorimetry,
225      * as defined by the ICC Specification. This
226      * means that the XYZ values returned by this method are represented
227      * relative to the D50 white point of the CS_CIEXYZ color space.
228      * This representation is useful in a two-step color conversion
229      * process in which colors are transformed from an input color
230      * space to CS_CIEXYZ and then to an output color space. This
231      * representation is not the same as the XYZ values that would
232      * be measured from the given color value by a colorimeter.
233      * A further transformation is necessary to compute the XYZ values
234      * that would be measured using current CIE recommended practices.
235      * The paragraphs below explain this in more detail.
236      * <p>
237      * The ICC standard uses a device independent color space (DICS) as the
238      * mechanism for converting color from one device to another device. In
239      * this architecture, colors are converted from the source device's color
240      * space to the ICC DICS and then from the ICC DICS to the destination
241      * device's color space. The ICC standard defines device profiles which
242      * contain transforms which will convert between a device's color space
243      * and the ICC DICS. The overall conversion of colors from a source
244      * device to colors of a destination device is done by connecting the
245      * device-to-DICS transform of the profile for the source device to the
246      * DICS-to-device transform of the profile for the destination device.
247      * For this reason, the ICC DICS is commonly referred to as the profile
248      * connection space (PCS). The color space used in the methods
249      * toCIEXYZ and fromCIEXYZ is the CIEXYZ PCS defined by the ICC
250      * Specification. This is also the color space represented by
251      * ColorSpace.CS_CIEXYZ.
252      * <p>
253      * The XYZ values of a color are often represented as relative to some
254      * white point, so the actual meaning of the XYZ values cannot be known
255      * without knowing the white point of those values. This is known as
256      * relative colorimetry. The PCS uses a white point of D50, so the XYZ
257      * values of the PCS are relative to D50. For example, white in the PCS
258      * will have the XYZ values of D50, which is defined to be X=.9642,
259      * Y=1.000, and Z=0.8249. This white point is commonly used for graphic
260      * arts applications, but others are often used in other applications.
261      * <p>
262      * To quantify the color characteristics of a device such as a printer
263      * or monitor, measurements of XYZ values for particular device colors
264      * are typically made. For purposes of this discussion, the term
265      * device XYZ values is used to mean the XYZ values that would be
266      * measured from device colors using current CIE recommended practices.
267      * <p>
268      * Converting between device XYZ values and the PCS XYZ values returned
269      * by this method corresponds to converting between the device's color
270      * space, as represented by CIE colorimetric values, and the PCS. There
271      * are many factors involved in this process, some of which are quite
272      * subtle. The most important, however, is the adjustment made to account
273      * for differences between the device's white point and the white point of
274      * the PCS. There are many techniques for doing this and it is the
275      * subject of much current research and controversy. Some commonly used
276      * methods are XYZ scaling, the von Kries transform, and the Bradford
277      * transform. The proper method to use depends upon each particular
278      * application.
279      * <p>
280      * The simplest method is XYZ scaling. In this method each device XYZ
281      * value is converted to a PCS XYZ value by multiplying it by the ratio
282      * of the PCS white point (D50) to the device white point.
283      * <pre>
284      *
285      * Xd, Yd, Zd are the device XYZ values
286      * Xdw, Ydw, Zdw are the device XYZ white point values
287      * Xp, Yp, Zp are the PCS XYZ values
288      * Xd50, Yd50, Zd50 are the PCS XYZ white point values
289      *
290      * Xp = Xd * (Xd50 / Xdw)
291      * Yp = Yd * (Yd50 / Ydw)
292      * Zp = Zd * (Zd50 / Zdw)
293      *
294      * </pre>
295      * <p>
296      * Conversion from the PCS to the device would be done by inverting these
297      * equations:
298      * <pre>
299      *
300      * Xd = Xp * (Xdw / Xd50)
301      * Yd = Yp * (Ydw / Yd50)
302      * Zd = Zp * (Zdw / Zd50)
303      *
304      * </pre>
305      * <p>
306      * Note that the media white point tag in an ICC profile is not the same
307      * as the device white point. The media white point tag is expressed in
308      * PCS values and is used to represent the difference between the XYZ of
309      * device illuminant and the XYZ of the device media when measured under
310      * that illuminant. The device white point is expressed as the device
311      * XYZ values corresponding to white displayed on the device. For
312      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
313      * will result in a measured device XYZ value of D65. This will not
314      * be the same as the media white point tag XYZ value in the ICC
315      * profile for an sRGB device.
316      * <p>
317      * @param colorvalue a float array with length of at least the number
318      * of components in this ColorSpace.
319      * @return a float array of length 3.
320      * @throws ArrayIndexOutOfBoundsException if array length is not
321      * at least the number of components in this ColorSpace.
322      */

323     public float[] toCIEXYZ(float[] colorvalue) {
324     
325         if (this2xyz == null) {
326             ICC_Transform[] transformList = new ICC_Transform [2];
327             ICC_ColorSpace JavaDoc xyzCS =
328                 (ICC_ColorSpace JavaDoc) ColorSpace.getInstance (CS_CIEXYZ);
329             try {
330                 transformList[0] = new ICC_Transform (thisProfile,
331                     ICC_Profile.icRelativeColorimetric, ICC_Transform.In);
332             } catch (CMMException JavaDoc e) {
333                 transformList[0] = new ICC_Transform (thisProfile,
334                     ICC_Transform.Any, ICC_Transform.In);
335             }
336             transformList[1] = new ICC_Transform (xyzCS.getProfile(),
337                 ICC_Transform.Any, ICC_Transform.Out);
338             this2xyz = new ICC_Transform (transformList);
339             if (needScaleInit) {
340                 setComponentScaling();
341             }
342         }
343
344         int nc = this.getNumComponents();
345         short tmp[] = new short[nc];
346         for (int i = 0; i < nc; i++) {
347             tmp[i] = (short)
348                 ((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f);
349         }
350         tmp = this2xyz.colorConvert(tmp, null);
351         float ALMOST_TWO = 1.0f + (32767.0f / 32768.0f);
352         // For CIEXYZ, min = 0.0, max = ALMOST_TWO for all components
353
float[] result = new float [3];
354         for (int i = 0; i < 3; i++) {
355             result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) * ALMOST_TWO;
356         }
357         return result;
358     }
359
360
361     /**
362      * Transforms a color value assumed to be in the CS_CIEXYZ conversion
363      * color space into this ColorSpace.
364      * <p>
365      * This method transforms color values using relative colorimetry,
366      * as defined by the ICC Specification. This
367      * means that the XYZ argument values taken by this method are represented
368      * relative to the D50 white point of the CS_CIEXYZ color space.
369      * This representation is useful in a two-step color conversion
370      * process in which colors are transformed from an input color
371      * space to CS_CIEXYZ and then to an output color space. The color
372      * values returned by this method are not those that would produce
373      * the XYZ value passed to the method when measured by a colorimeter.
374      * If you have XYZ values corresponding to measurements made using
375      * current CIE recommended practices, they must be converted to D50
376      * relative values before being passed to this method.
377      * The paragraphs below explain this in more detail.
378      * <p>
379      * The ICC standard uses a device independent color space (DICS) as the
380      * mechanism for converting color from one device to another device. In
381      * this architecture, colors are converted from the source device's color
382      * space to the ICC DICS and then from the ICC DICS to the destination
383      * device's color space. The ICC standard defines device profiles which
384      * contain transforms which will convert between a device's color space
385      * and the ICC DICS. The overall conversion of colors from a source
386      * device to colors of a destination device is done by connecting the
387      * device-to-DICS transform of the profile for the source device to the
388      * DICS-to-device transform of the profile for the destination device.
389      * For this reason, the ICC DICS is commonly referred to as the profile
390      * connection space (PCS). The color space used in the methods
391      * toCIEXYZ and fromCIEXYZ is the CIEXYZ PCS defined by the ICC
392      * Specification. This is also the color space represented by
393      * ColorSpace.CS_CIEXYZ.
394      * <p>
395      * The XYZ values of a color are often represented as relative to some
396      * white point, so the actual meaning of the XYZ values cannot be known
397      * without knowing the white point of those values. This is known as
398      * relative colorimetry. The PCS uses a white point of D50, so the XYZ
399      * values of the PCS are relative to D50. For example, white in the PCS
400      * will have the XYZ values of D50, which is defined to be X=.9642,
401      * Y=1.000, and Z=0.8249. This white point is commonly used for graphic
402      * arts applications, but others are often used in other applications.
403      * <p>
404      * To quantify the color characteristics of a device such as a printer
405      * or monitor, measurements of XYZ values for particular device colors
406      * are typically made. For purposes of this discussion, the term
407      * device XYZ values is used to mean the XYZ values that would be
408      * measured from device colors using current CIE recommended practices.
409      * <p>
410      * Converting between device XYZ values and the PCS XYZ values taken as
411      * arguments by this method corresponds to converting between the device's
412      * color space, as represented by CIE colorimetric values, and the PCS.
413      * There are many factors involved in this process, some of which are quite
414      * subtle. The most important, however, is the adjustment made to account
415      * for differences between the device's white point and the white point of
416      * the PCS. There are many techniques for doing this and it is the
417      * subject of much current research and controversy. Some commonly used
418      * methods are XYZ scaling, the von Kries transform, and the Bradford
419      * transform. The proper method to use depends upon each particular
420      * application.
421      * <p>
422      * The simplest method is XYZ scaling. In this method each device XYZ
423      * value is converted to a PCS XYZ value by multiplying it by the ratio
424      * of the PCS white point (D50) to the device white point.
425      * <pre>
426      *
427      * Xd, Yd, Zd are the device XYZ values
428      * Xdw, Ydw, Zdw are the device XYZ white point values
429      * Xp, Yp, Zp are the PCS XYZ values
430      * Xd50, Yd50, Zd50 are the PCS XYZ white point values
431      *
432      * Xp = Xd * (Xd50 / Xdw)
433      * Yp = Yd * (Yd50 / Ydw)
434      * Zp = Zd * (Zd50 / Zdw)
435      *
436      * </pre>
437      * <p>
438      * Conversion from the PCS to the device would be done by inverting these
439      * equations:
440      * <pre>
441      *
442      * Xd = Xp * (Xdw / Xd50)
443      * Yd = Yp * (Ydw / Yd50)
444      * Zd = Zp * (Zdw / Zd50)
445      *
446      * </pre>
447      * <p>
448      * Note that the media white point tag in an ICC profile is not the same
449      * as the device white point. The media white point tag is expressed in
450      * PCS values and is used to represent the difference between the XYZ of
451      * device illuminant and the XYZ of the device media when measured under
452      * that illuminant. The device white point is expressed as the device
453      * XYZ values corresponding to white displayed on the device. For
454      * example, displaying the RGB color (1.0, 1.0, 1.0) on an sRGB device
455      * will result in a measured device XYZ value of D65. This will not
456      * be the same as the media white point tag XYZ value in the ICC
457      * profile for an sRGB device.
458      * <p>
459      * <p>
460      * @param colorvalue a float array with length of at least 3.
461      * @return a float array with length equal to the number of
462      * components in this ColorSpace.
463      * @throws ArrayIndexOutOfBoundsException if array length is not
464      * at least 3.
465      */

466     public float[] fromCIEXYZ(float[] colorvalue) {
467     
468         if (xyz2this == null) {
469             ICC_Transform[] transformList = new ICC_Transform [2];
470             ICC_ColorSpace JavaDoc xyzCS =
471                 (ICC_ColorSpace JavaDoc) ColorSpace.getInstance (CS_CIEXYZ);
472             transformList[0] = new ICC_Transform (xyzCS.getProfile(),
473                 ICC_Transform.Any, ICC_Transform.In);
474             try {
475                 transformList[1] = new ICC_Transform (thisProfile,
476                     ICC_Profile.icRelativeColorimetric, ICC_Transform.Out);
477             } catch (CMMException JavaDoc e) {
478                 transformList[1] = new ICC_Transform (thisProfile,
479                     ICC_Transform.Any, ICC_Transform.Out);
480             }
481             xyz2this = new ICC_Transform (transformList);
482             if (needScaleInit) {
483                 setComponentScaling();
484             }
485         }
486
487         short tmp[] = new short[3];
488         float ALMOST_TWO = 1.0f + (32767.0f / 32768.0f);
489         float factor = 65535.0f / ALMOST_TWO;
490         // For CIEXYZ, min = 0.0, max = ALMOST_TWO for all components
491
for (int i = 0; i < 3; i++) {
492             tmp[i] = (short) ((colorvalue[i] * factor) + 0.5f);
493         }
494         tmp = xyz2this.colorConvert(tmp, null);
495         int nc = this.getNumComponents();
496         float[] result = new float [nc];
497         for (int i = 0; i < nc; i++) {
498             result[i] = (((float) (tmp[i] & 0xffff)) / 65535.0f) *
499                         diffMinMax[i] + minVal[i];
500         }
501         return result;
502     }
503
504     /**
505      * Returns the minimum normalized color component value for the
506      * specified component. For TYPE_XYZ spaces, this method returns
507      * minimum values of 0.0 for all components. For TYPE_Lab spaces,
508      * this method returns 0.0 for L and -128.0 for a and b components.
509      * This is consistent with the encoding of the XYZ and Lab Profile
510      * Connection Spaces in the ICC specification. For all other types, this
511      * method returns 0.0 for all components. When using an ICC_ColorSpace
512      * with a profile that requires different minimum component values,
513      * it is necessary to subclass this class and override this method.
514      * @param component The component index.
515      * @return The minimum normalized component value.
516      * @throws IllegalArgumentException if component is less than 0 or
517      * greater than numComponents - 1.
518      * @since 1.4
519      */

520     public float getMinValue(int component) {
521         if ((component < 0) || (component > this.getNumComponents() - 1)) {
522             throw new IllegalArgumentException JavaDoc(
523                 "Component index out of range: + component");
524         }
525         return minVal[component];
526     }
527
528     /**
529      * Returns the maximum normalized color component value for the
530      * specified component. For TYPE_XYZ spaces, this method returns
531      * maximum values of 1.0 + (32767.0 / 32768.0) for all components.
532      * For TYPE_Lab spaces,
533      * this method returns 100.0 for L and 127.0 for a and b components.
534      * This is consistent with the encoding of the XYZ and Lab Profile
535      * Connection Spaces in the ICC specification. For all other types, this
536      * method returns 1.0 for all components. When using an ICC_ColorSpace
537      * with a profile that requires different maximum component values,
538      * it is necessary to subclass this class and override this method.
539      * @param component The component index.
540      * @return The maximum normalized component value.
541      * @throws IllegalArgumentException if component is less than 0 or
542      * greater than numComponents - 1.
543      * @since 1.4
544      */

545     public float getMaxValue(int component) {
546         if ((component < 0) || (component > this.getNumComponents() - 1)) {
547             throw new IllegalArgumentException JavaDoc(
548                 "Component index out of range: + component");
549         }
550         return maxVal[component];
551     }
552
553     private void setMinMax() {
554         int nc = this.getNumComponents();
555         int type = this.getType();
556         minVal = new float[nc];
557         maxVal = new float[nc];
558         if (type == ColorSpace.TYPE_Lab) {
559             minVal[0] = 0.0f; // L
560
maxVal[0] = 100.0f;
561             minVal[1] = -128.0f; // a
562
maxVal[1] = 127.0f;
563             minVal[2] = -128.0f; // b
564
maxVal[2] = 127.0f;
565         } else if (type == ColorSpace.TYPE_XYZ) {
566             minVal[0] = minVal[1] = minVal[2] = 0.0f; // X, Y, Z
567
maxVal[0] = maxVal[1] = maxVal[2] = 1.0f + (32767.0f/ 32768.0f);
568         } else {
569             for (int i = 0; i < nc; i++) {
570                 minVal[i] = 0.0f;
571                 maxVal[i] = 1.0f;
572             }
573         }
574     }
575
576     private void setComponentScaling() {
577         int nc = this.getNumComponents();
578         diffMinMax = new float[nc];
579         invDiffMinMax = new float[nc];
580         for (int i = 0; i < nc; i++) {
581             minVal[i] = this.getMinValue(i); // in case getMinVal is overridden
582
maxVal[i] = this.getMaxValue(i); // in case getMaxVal is overridden
583
diffMinMax[i] = maxVal[i] - minVal[i];
584             invDiffMinMax[i] = 65535.0f / diffMinMax[i];
585         }
586         needScaleInit = false;
587     }
588
589 }
590
Popular Tags