Debian Codegraph @

nx-X11/lib/src/xcms/CvColW.c

raw
1
2 /*
3 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
4 * All Rights Reserved
5 *
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.
13 *
14 * Tektronix makes no representation about the suitability of this software
15 * for any purpose. It is provided "as is" and with all faults.
16 *
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.
24 *
25 *
26 *
27 * NAME
28 * XcmsCvColW.c
29 *
30 * DESCRIPTION
31 * <overall description of what the package does>
32 *
33 *
34 */
35
36 #ifdef HAVE_CONFIG_H
37 #include <config.h>
38 #endif
39 #include "Xlibint.h"
40 #include "Xcmsint.h"
41 #include "Cv.h"
42
43
44 /************************************************************************
45 * *
46 * API PRIVATE ROUTINES *
47 * *
48 ************************************************************************/
49
50
51 /*
52 * NAME
53 * _XcmsConvertColorsWithWhitePt - Convert XcmsColor structures
54 *
55 * SYNOPSIS
56 */
57 Status
58 _XcmsConvertColorsWithWhitePt(
59 XcmsCCC ccc,
60 XcmsColor *pColors_in_out,
61 XcmsColor *pWhitePt,
62 unsigned int nColors,
63 XcmsColorFormat newFormat,
64 Bool *pCompressed)
65 /*
66 * DESCRIPTION
67 * Convert XcmsColor structures between device-independent
68 * and/or device-dependent formats but allowing the calling
69 * routine to specify the white point to be associated
70 * with the color specifications (overriding
71 * ccc->clientWhitePt).
72 *
73 * This routine has been provided for use in white point
74 * adjustment routines.
75 *
76 * RETURNS
77 * XcmsFailure if failed,
78 * XcmsSuccess if succeeded without gamut compression,
79 * XcmsSuccessWithCompression if succeeded with gamut
80 * compression.
81 *
82 */
83 {
84 if (ccc == NULL || pColors_in_out == NULL ||
85 pColors_in_out->format == XcmsUndefinedFormat) {
86 return(XcmsFailure);
87 }
88
89 if (nColors == 0 || pColors_in_out->format == newFormat) {
90 /* do nothing */
91 return(XcmsSuccess);
92 }
93
94 if (XCMS_DI_ID(pColors_in_out->format) && XCMS_DI_ID(newFormat)) {
95 /*
96 * Device-Independent to Device-Independent Conversion
97 */
98 return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
99 newFormat));
100 }
101 if (XCMS_DD_ID(pColors_in_out->format) && XCMS_DD_ID(newFormat)) {
102 /*
103 * Device-Dependent to Device-Dependent Conversion
104 */
105 return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
106 pCompressed));
107 }
108
109 /*
110 * Otherwise we have:
111 * 1. Device-Independent to Device-Dependent Conversion
112 * OR
113 * 2. Device-Dependent to Device-Independent Conversion
114 */
115
116 if (XCMS_DI_ID(pColors_in_out->format)) {
117 /*
118 * 1. Device-Independent to Device-Dependent Conversion
119 */
120 /* First convert to CIEXYZ */
121 if (_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
122 XcmsCIEXYZFormat) == XcmsFailure) {
123 return(XcmsFailure);
124 }
125 /* Then convert to DD Format */
126 return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
127 pCompressed));
128 } else {
129 /*
130 * 2. Device-Dependent to Device-Independent Conversion
131 */
132 /* First convert to CIEXYZ */
133 if (_XcmsDDConvertColors(ccc, pColors_in_out, nColors,
134 XcmsCIEXYZFormat, pCompressed) == XcmsFailure) {
135 return(XcmsFailure);
136 }
137 /* Then convert to DI Format */
138 return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
139 newFormat));
140 }
141 }