3 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
6 * This file is a component of an X Window System-specific implementation
7 * of XCMS based on the TekColor Color Management System. Permission is
8 * hereby granted to use, copy, modify, sell, and otherwise distribute this
9 * software and its documentation for any purpose and without fee, provided
10 * that this copyright, permission, and disclaimer notice is reproduced in
11 * all copies of this software and in supporting documentation. TekColor
12 * is a trademark of Tektronix, Inc.
14 * Tektronix makes no representation about the suitability of this software
15 * for any purpose. It is provided "as is" and with all faults.
17 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
18 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
20 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
21 * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
22 * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23 * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
29 * Source for XcmsCIELuvClipuv() gamut compression routine.
41 /************************************************************************
45 ************************************************************************/
49 * XcmsCIELuvClipuv - Reduce the chroma for a hue and L*
57 XcmsColor *pColors_in_out,
63 * Reduce the Chroma for a specific hue and chroma to
64 * to bring the given color into the gamut of the
65 * specified device. As required of gamut compression
66 * functions, this routine returns pColor_in_out
67 * in XcmsCIEXYZFormat on successful completion.
69 * Since this routine works with the L* within
70 * pColor_in_out intermediate results may be returned
71 * even though it may be invalid.
74 * XcmsFailure - Failure
75 * XcmsSuccess - Succeeded
83 * Color specification passed as input can be assumed to:
84 * 1. Be in XcmsCIEXYZFormat
85 * 2. Already be white point adjusted for the Screen White Point.
86 * This means that the white point now associated with this
87 * color spec is the Screen White Point (even if the
88 * ccc->clientWhitePt differs).
91 pColor = pColors_in_out + i;
93 if (ccc->visual->class < PseudoColor) {
97 _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
99 _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
100 1, XcmsCIEXYZFormat);
102 *(pCompressed + i) = True;
106 if (pColor->format != XcmsCIELuvFormat) {
107 if (_XcmsDIConvertColors(ccc, pColor,
108 &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIELuvFormat)
113 if (XcmsCIELuvQueryMaxC(ccc,
114 degrees(XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
115 pColor->spec.CIELuv.v_star)),
116 pColor->spec.CIELuv.L_star,
117 pColor) == XcmsFailure) {
120 retval = _XcmsDIConvertColors(ccc, pColor,
121 &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
122 if (retval != XcmsFailure && pCompressed != NULL) {
123 *(pCompressed + i) = True;