HVCWpAj.c revision 1ab64890
1/* $Xorg: HVCWpAj.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
2
3/*
4 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
5 * 	All Rights Reserved
6 *
7 * This file is a component of an X Window System-specific implementation
8 * of Xcms based on the TekColor Color Management System.  TekColor is a
9 * trademark of Tektronix, Inc.  The term "TekHVC" designates a particular
10 * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
11 * foreign patents pending).  Permission is hereby granted to use, copy,
12 * modify, sell, and otherwise distribute this software and its
13 * documentation for any purpose and without fee, provided that:
14 *
15 * 1. This copyright, permission, and disclaimer notice is reproduced in
16 *    all copies of this software and any modification thereof and in
17 *    supporting documentation;
18 * 2. Any color-handling application which displays TekHVC color
19 *    cooordinates identifies these as TekHVC color coordinates in any
20 *    interface that displays these coordinates and in any associated
21 *    documentation;
22 * 3. The term "TekHVC" is always used, and is only used, in association
23 *    with the mathematical derivations of the TekHVC Color Space,
24 *    including those provided in this file and any equivalent pathways and
25 *    mathematical derivations, regardless of digital (e.g., floating point
26 *    or integer) representation.
27 *
28 * Tektronix makes no representation about the suitability of this software
29 * for any purpose.  It is provided "as is" and with all faults.
30 *
31 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
32 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
33 * PARTICULAR PURPOSE.  IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
34 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
35 * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
36 * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
37 * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
38 *
39 *	DESCRIPTION
40 *		TekHVCWpAj.c
41 *
42 *	DESCRIPTION
43 *		This file contains routine(s) that support white point
44 *		adjustment of color specifications in the TekHVC color
45 *		space.
46 */
47/* $XFree86$ */
48
49#ifdef HAVE_CONFIG_H
50#include <config.h>
51#endif
52#include "Xlibint.h"
53#include "Xcmsint.h"
54#include "Cv.h"
55
56
57/************************************************************************
58 *									*
59 *			 PUBLIC ROUTINES				*
60 *									*
61 ************************************************************************/
62
63/*
64 *	NAME
65 *		XcmsTekHVCWhiteShiftColors
66 *
67 *	SYNOPSIS
68 */
69Status
70XcmsTekHVCWhiteShiftColors(
71    XcmsCCC ccc,
72    XcmsColor *pWhitePtFrom,
73    XcmsColor *pWhitePtTo,
74    XcmsColorFormat destSpecFmt,
75    XcmsColor *pColors_in_out,
76    unsigned int nColors,
77    Bool *pCompressed)
78/*
79 *	DESCRIPTION
80 *		Convert color specifications in an array of XcmsColor structures
81 *		for differences in white points.
82 *
83 *	RETURNS
84 *		XcmsFailure if failed,
85 *		XcmsSuccess if succeeded without gamut compression,
86 *		XcmsSuccessWithCompression if succeeded with
87 *			gamut compression.
88 */
89{
90    if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
91	return(XcmsFailure);
92    }
93
94    /*
95     * Insure TekHVC installed
96     */
97    if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
98	return(XcmsFailure);
99    }
100
101    /*
102     * Convert to TekHVC using pWhitePtFrom
103     *    We can ignore return value for compression because we are converting
104     *    to XcmsTekHVCFormat which is device-independent, not device-dependent.
105     */
106    if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
107	    nColors, XcmsTekHVCFormat, pCompressed) == XcmsFailure) {
108	return(XcmsFailure);
109    }
110
111    /*
112     * Convert from TekHVC to destSpecFmt using pWhitePtTo
113     */
114    return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtTo,
115	    nColors, destSpecFmt, pCompressed));
116}
117