~ubuntu-branches/ubuntu/lucid/libx11/lucid

« back to all changes in this revision

Viewing changes to src/xcms/LuvMxLC.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-01-17 16:34:54 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090117163454-gaey3cd32xyavueo
Tags: 2:1.1.99.2-1build1
Fakesync with Debian, all previous Ubuntu changes are included
in the new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*
4
4
 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
5
5
 *      All Rights Reserved
6
 
 * 
 
6
 *
7
7
 * This file is a component of an X Window System-specific implementation
8
8
 * of XCMS based on the TekColor Color Management System.  Permission is
9
9
 * hereby granted to use, copy, modify, sell, and otherwise distribute this
11
11
 * that this copyright, permission, and disclaimer notice is reproduced in
12
12
 * all copies of this software and in supporting documentation.  TekColor
13
13
 * is a trademark of Tektronix, Inc.
14
 
 * 
 
14
 *
15
15
 * Tektronix makes no representation about the suitability of this software
16
16
 * for any purpose.  It is provided "as is" and with all faults.
17
 
 * 
 
17
 *
18
18
 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
19
19
 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20
20
 * PARTICULAR PURPOSE.  IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
98
98
 *              XcmsFailure - Failure
99
99
 *              XcmsSuccess - Succeeded
100
100
 *
101
 
 */ 
 
101
 */
102
102
{
103
103
    XcmsFloat nSmall, nLarge;
104
104
    XcmsColor tmp;
115
115
     * out of bounds RGBi values in tmp when the ccc->gamutCompProc
116
116
     * is NULL.
117
117
     */
118
 
    if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc), 
119
 
                               (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL) 
 
118
    if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc),
 
119
                               (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL)
120
120
            == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
121
121
        return (XcmsFailure);
122
122
    }
123
123
 
124
124
    /* Now pick the smallest RGB */
125
 
    nSmall = MIN3(tmp.spec.RGBi.red, 
126
 
                  tmp.spec.RGBi.green, 
 
125
    nSmall = MIN3(tmp.spec.RGBi.red,
 
126
                  tmp.spec.RGBi.green,
127
127
                  tmp.spec.RGBi.blue);
128
128
    /* Make the smallest RGB equal to zero */
129
129
    tmp.spec.RGBi.red   -= nSmall;
131
131
    tmp.spec.RGBi.blue  -= nSmall;
132
132
 
133
133
    /* Now pick the largest RGB */
134
 
    nLarge = MAX3(tmp.spec.RGBi.red, 
135
 
                  tmp.spec.RGBi.green, 
 
134
    nLarge = MAX3(tmp.spec.RGBi.red,
 
135
                  tmp.spec.RGBi.green,
136
136
                  tmp.spec.RGBi.blue);
137
137
    /* Scale the RGB values based on the largest one */
138
138
    tmp.spec.RGBi.red   /= nLarge;
149
149
 
150
150
    /* Convert from RGBi to Luv */
151
151
    if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
152
 
               ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat, (Bool *) NULL) 
 
152
               ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat, (Bool *) NULL)
153
153
            == XcmsFailure) {
154
154
        return (XcmsFailure);
155
155
    }
156
156
 
157
157
    memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
158
 
    return (XcmsSuccess);    
 
158
    return (XcmsSuccess);
159
159
}
160
160
 
161
161
 
192
192
 *              XcmsFailure - Failure
193
193
 *              XcmsSuccess - Succeeded
194
194
 *
195
 
 */ 
 
195
 */
196
196
{
197
197
    XcmsCCCRec myCCC;
198
198
 
202
202
    if (ccc == NULL || pColor_return == NULL) {
203
203
        return(XcmsFailure);
204
204
    }
205
 
    
 
205
 
206
206
    /* Use my own CCC */
207
207
    memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
208
208
    myCCC.clientWhitePt.format = XcmsUndefinedFormat;
213
213
    }
214
214
    while (hue_angle >= 360.0) {
215
215
        hue_angle -= 360.0;
216
 
    } 
217
 
    
 
216
    }
 
217
 
218
218
    return(_XcmsCIELuvQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return,
219
219
            (XcmsRGBi *)NULL));
220
220
}