1 /* $Xorg: Xcms.h,v 1.6 2000/08/17 19:45:04 cpqbld Exp $ */
4 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
7 * This file is a component of an X Window System-specific implementation
8 * of Xcms based on the TekColor Color Management System. Permission is
9 * hereby granted to use, copy, modify, sell, and otherwise distribute this
10 * software and its documentation for any purpose and without fee, provided
11 * that this copyright, permission, and disclaimer notice is reproduced in
12 * all copies of this software and in supporting documentation. TekColor
13 * is a trademark of Tektronix, Inc.
15 * Tektronix makes no representation about the suitability of this software
16 * for any purpose. It is provided "as is" and with all faults.
18 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
19 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
21 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
22 * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
23 * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
24 * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
28 * Public include file for X Color Management System
30 /* $XFree86: xc/lib/X11/Xcms.h,v 1.7 2003/11/03 03:46:26 dawes Exp $ */
41 #define XcmsSuccessWithCompression 2
44 * Color Space Format ID's
45 * Color Space ID's are of XcmsColorFormat type.
48 * 0 == Device-Independent
49 * 1 == Device-Dependent
52 * 0 == Registered with X Consortium
55 #define XcmsUndefinedFormat (XcmsColorFormat)0x00000000
56 #define XcmsCIEXYZFormat (XcmsColorFormat)0x00000001
57 #define XcmsCIEuvYFormat (XcmsColorFormat)0x00000002
58 #define XcmsCIExyYFormat (XcmsColorFormat)0x00000003
59 #define XcmsCIELabFormat (XcmsColorFormat)0x00000004
60 #define XcmsCIELuvFormat (XcmsColorFormat)0x00000005
61 #define XcmsTekHVCFormat (XcmsColorFormat)0x00000006
62 #define XcmsRGBFormat (XcmsColorFormat)0x80000000
63 #define XcmsRGBiFormat (XcmsColorFormat)0x80000001
66 * State of XcmsPerScrnInfo
68 #define XcmsInitNone 0x00 /* no initialization attempted */
69 #define XcmsInitSuccess 0x01 /* initialization successful */
70 #define XcmsInitFailure 0xff /* failure, use defaults */
72 #define DisplayOfCCC(ccc) ((ccc)->dpy)
73 #define ScreenNumberOfCCC(ccc) ((ccc)->screenNumber)
74 #define VisualOfCCC(ccc) ((ccc)->visual)
75 #define ClientWhitePointOfCCC(ccc) (&(ccc)->clientWhitePt)
76 #define ScreenWhitePointOfCCC(ccc) (&(ccc)->pPerScrnInfo->screenWhitePt)
77 #define FunctionSetOfCCC(ccc) ((ccc)->pPerScrnInfo->functionSet)
79 typedef unsigned long XcmsColorFormat
; /* Color Space Format ID */
81 typedef double XcmsFloat
;
87 unsigned short red
; /* scaled from 0x0000 to 0xffff */
88 unsigned short green
; /* scaled from 0x0000 to 0xffff */
89 unsigned short blue
; /* scaled from 0x0000 to 0xffff */
96 XcmsFloat red
; /* 0.0 - 1.0 */
97 XcmsFloat green
; /* 0.0 - 1.0 */
98 XcmsFloat blue
; /* 0.0 - 1.0 */
114 XcmsFloat u_prime
; /* 0.0 - 1.0 */
115 XcmsFloat v_prime
; /* 0.0 - 1.0 */
116 XcmsFloat Y
; /* 0.0 - 1.0 */
123 XcmsFloat x
; /* 0.0 - 1.0 */
124 XcmsFloat y
; /* 0.0 - 1.0 */
125 XcmsFloat Y
; /* 0.0 - 1.0 */
132 XcmsFloat L_star
; /* 0.0 - 100.0 */
141 XcmsFloat L_star
; /* 0.0 - 100.0 */
150 XcmsFloat H
; /* 0.0 - 360.0 */
151 XcmsFloat V
; /* 0.0 - 100.0 */
152 XcmsFloat C
; /* 0.0 - 100.0 */
167 * XCMS Color Structure
180 } spec
; /* the color specification */
181 unsigned long pixel
; /* pixel value (as needed) */
182 XcmsColorFormat format
; /* the specification format */
187 * XCMS Per Screen related data
190 typedef struct _XcmsPerScrnInfo
{
191 XcmsColor screenWhitePt
; /* Screen White point */
192 XPointer functionSet
; /* pointer to Screen Color Characterization */
193 /* Function Set structure */
194 XPointer screenData
; /* pointer to corresponding Screen Color*/
195 /* Characterization Data */
196 unsigned char state
; /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */
200 typedef struct _XcmsCCC
*XcmsCCC
;
202 typedef Status (*XcmsCompressionProc
)( /* Gamut Compression Proc */
204 XcmsColor
* /* colors_in_out */,
205 unsigned int /* ncolors */,
206 unsigned int /* index */,
207 Bool
* /* compression_flags_return */
210 typedef Status (*XcmsWhiteAdjustProc
)( /* White Point Adjust Proc */
212 XcmsColor
* /* initial_white_point*/,
213 XcmsColor
* /* target_white_point*/,
214 XcmsColorFormat
/* target_format */,
215 XcmsColor
* /* colors_in_out */,
216 unsigned int /* ncolors */,
217 Bool
* /* compression_flags_return */
221 * XCMS Color Conversion Context
223 typedef struct _XcmsCCC
{
224 Display
*dpy
; /* X Display */
225 int screenNumber
; /* X screen number */
226 Visual
*visual
; /* X Visual */
227 XcmsColor clientWhitePt
; /* Client White Point */
228 XcmsCompressionProc gamutCompProc
; /* Gamut Compression Function */
229 XPointer gamutCompClientData
; /* Gamut Comp Func Client Data */
230 XcmsWhiteAdjustProc whitePtAdjProc
; /* White Point Adjustment Function */
231 XPointer whitePtAdjClientData
; /* White Pt Adj Func Client Data */
232 XcmsPerScrnInfo
*pPerScrnInfo
; /* pointer to per screen information */
233 /* associated with the above display */
237 typedef Status (*XcmsScreenInitProc
)( /* Screen Initialization Proc */
239 int /* screen_number */,
240 XcmsPerScrnInfo
* /* screen_info */
243 typedef void (*XcmsScreenFreeProc
)(
244 XPointer
/* screenData */
248 * Function List Pointer -- pointer to an array of function pointers.
249 * The end of list is indicated by a NULL pointer.
252 * XXX: The use of the XcmsConversionProc type is broken. The
253 * device-independent colour conversion code uses it as:
255 typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, XcmsColor *,
258 * while the device-dependent code uses it as:
260 typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, unsigned int,
263 * Until this is reworked, it's probably best to leave it unprotoized.
264 * The code works regardless.
266 typedef Status (*XcmsDDConversionProc
)( /* using device-dependent version */
268 XcmsColor
* /* pcolors_in_out */,
269 unsigned int /* ncolors */,
270 Bool
* /* pCompressed */
273 typedef Status (*XcmsDIConversionProc
)( /* using device-independent version */
275 XcmsColor
* /* white_point */,
276 XcmsColor
* /* pcolors_in_out */,
277 unsigned int /* ncolors */
280 typedef XcmsDIConversionProc XcmsConversionProc
;
281 typedef XcmsConversionProc
*XcmsFuncListPtr
;
283 typedef int (*XcmsParseStringProc
)( /* Color String Parsing Proc */
284 char* /* color_string */,
285 XcmsColor
* /* color_return */
289 * Color Space -- per Color Space related data (Device-Independent
290 * or Device-Dependent)
292 typedef struct _XcmsColorSpace
{
293 const char *prefix
; /* Prefix of string format. */
294 XcmsColorFormat id
; /* Format ID number. */
295 XcmsParseStringProc parseString
;
296 /* String format parsing function */
297 XcmsFuncListPtr to_CIEXYZ
; /* Pointer to an array of function */
298 /* pointers such that when the */
299 /* functions are executed in sequence */
300 /* will convert a XcmsColor structure */
301 /* from this color space to CIEXYZ */
303 XcmsFuncListPtr from_CIEXYZ
;/* Pointer to an array of function */
304 /* pointers such that when the */
305 /* functions are executed in sequence */
306 /* will convert a XcmsColor structure */
307 /* from CIEXYZ space to this color */
309 int inverse_flag
; /* If 1, indicates that for 0 <= i < n */
310 /* where n is the number of function */
311 /* pointers in the lists to_CIEXYZ */
312 /* and from_CIEXYZ; for each function */
313 /* to_CIEXYZ[i] its inverse function */
314 /* is from_CIEXYZ[n - i]. */
319 * Screen Color Characterization Function Set -- per device class
320 * color space conversion functions.
322 typedef struct _XcmsFunctionSet
{
323 XcmsColorSpace
**DDColorSpaces
;
324 /* Pointer to an array of pointers to */
325 /* Device-DEPENDENT color spaces */
326 /* understood by this SCCFuncSet. */
327 XcmsScreenInitProc screenInitProc
;
328 /* Screen initialization function that */
329 /* reads Screen Color Characterization*/
330 /* Data off properties on the screen's*/
332 XcmsScreenFreeProc screenFreeProc
;
333 /* Function that frees the SCCData */
339 extern Status
XcmsAddColorSpace (
340 XcmsColorSpace
* /* pColorSpace */
343 extern Status
XcmsAddFunctionSet (
344 XcmsFunctionSet
* /* functionSet */
347 extern Status
XcmsAllocColor (
349 Colormap
/* colormap */,
350 XcmsColor
* /* color_in_out */,
351 XcmsColorFormat
/* result_format */
354 extern Status
XcmsAllocNamedColor (
356 Colormap
/* colormap */,
357 _Xconst
char* /* color_string */,
358 XcmsColor
* /* color_scrn_return */,
359 XcmsColor
* /* color_exact_return */,
360 XcmsColorFormat
/* result_format */
363 extern XcmsCCC
XcmsCCCOfColormap (
365 Colormap
/* colormap */
368 extern Status
XcmsCIELabClipab(
370 XcmsColor
* /* colors_in_out */,
371 unsigned int /* ncolors */,
372 unsigned int /* index */,
373 Bool
* /* compression_flags_return */
376 extern Status
XcmsCIELabClipL(
378 XcmsColor
* /* colors_in_out */,
379 unsigned int /* ncolors */,
380 unsigned int /* index */,
381 Bool
* /* compression_flags_return */
384 extern Status
XcmsCIELabClipLab(
386 XcmsColor
* /* colors_in_out */,
387 unsigned int /* ncolors */,
388 unsigned int /* index */,
389 Bool
* /* compression_flags_return */
392 extern Status
XcmsCIELabQueryMaxC (
394 XcmsFloat
/* hue_angle */,
395 XcmsFloat
/* L_star */,
396 XcmsColor
* /* color_return */
399 extern Status
XcmsCIELabQueryMaxL (
401 XcmsFloat
/* hue_angle */,
402 XcmsFloat
/* chroma */,
403 XcmsColor
* /* color_return */
406 extern Status
XcmsCIELabQueryMaxLC (
408 XcmsFloat
/* hue_angle */,
409 XcmsColor
* /* color_return */
412 extern Status
XcmsCIELabQueryMinL (
414 XcmsFloat
/* hue_angle */,
415 XcmsFloat
/* chroma */,
416 XcmsColor
* /* color_return */
419 extern Status
XcmsCIELabToCIEXYZ (
421 XcmsColor
* /* white_point */,
422 XcmsColor
* /* colors */,
423 unsigned int /* ncolors */
426 extern Status
XcmsCIELabWhiteShiftColors(
428 XcmsColor
* /* initial_white_point*/,
429 XcmsColor
* /* target_white_point*/,
430 XcmsColorFormat
/* target_format */,
431 XcmsColor
* /* colors_in_out */,
432 unsigned int /* ncolors */,
433 Bool
* /* compression_flags_return */
436 extern Status
XcmsCIELuvClipL(
438 XcmsColor
* /* colors_in_out */,
439 unsigned int /* ncolors */,
440 unsigned int /* index */,
441 Bool
* /* compression_flags_return */
444 extern Status
XcmsCIELuvClipLuv(
446 XcmsColor
* /* colors_in_out */,
447 unsigned int /* ncolors */,
448 unsigned int /* index */,
449 Bool
* /* compression_flags_return */
452 extern Status
XcmsCIELuvClipuv(
454 XcmsColor
* /* colors_in_out */,
455 unsigned int /* ncolors */,
456 unsigned int /* index */,
457 Bool
* /* compression_flags_return */
460 extern Status
XcmsCIELuvQueryMaxC (
462 XcmsFloat
/* hue_angle */,
463 XcmsFloat
/* L_star */,
464 XcmsColor
* /* color_return */
467 extern Status
XcmsCIELuvQueryMaxL (
469 XcmsFloat
/* hue_angle */,
470 XcmsFloat
/* chroma */,
471 XcmsColor
* /* color_return */
474 extern Status
XcmsCIELuvQueryMaxLC (
476 XcmsFloat
/* hue_angle */,
477 XcmsColor
* /* color_return */
480 extern Status
XcmsCIELuvQueryMinL (
482 XcmsFloat
/* hue_angle */,
483 XcmsFloat
/* chroma */,
484 XcmsColor
* /* color_return */
487 extern Status
XcmsCIELuvToCIEuvY (
489 XcmsColor
* /* white_point */,
490 XcmsColor
* /* colors */,
491 unsigned int /* ncolors */
494 extern Status
XcmsCIELuvWhiteShiftColors(
496 XcmsColor
* /* initial_white_point*/,
497 XcmsColor
* /* target_white_point*/,
498 XcmsColorFormat
/* target_format */,
499 XcmsColor
* /* colors_in_out */,
500 unsigned int /* ncolors */,
501 Bool
* /* compression_flags_return */
504 extern Status
XcmsCIEXYZToCIELab (
506 XcmsColor
* /* white_point */,
507 XcmsColor
* /* colors */,
508 unsigned int /* ncolors */
511 extern Status
XcmsCIEXYZToCIEuvY (
513 XcmsColor
* /* white_point */,
514 XcmsColor
* /* colors */,
515 unsigned int /* ncolors */
518 extern Status
XcmsCIEXYZToCIExyY (
520 XcmsColor
* /* white_point */,
521 XcmsColor
* /* colors */,
522 unsigned int /* ncolors */
525 extern Status
XcmsCIEXYZToRGBi (
527 XcmsColor
* /* colors */,
528 unsigned int /* ncolors */,
529 Bool
* /* compression_flags_return */
532 extern Status
XcmsCIEuvYToCIELuv (
534 XcmsColor
* /* white_point */,
535 XcmsColor
* /* colors */,
536 unsigned int /* ncolors */
539 extern Status
XcmsCIEuvYToCIEXYZ (
541 XcmsColor
* /* white_point */,
542 XcmsColor
* /* colors */,
543 unsigned int /* ncolors */
546 extern Status
XcmsCIEuvYToTekHVC (
548 XcmsColor
* /* white_point */,
549 XcmsColor
* /* colors */,
550 unsigned int /* ncolors */
553 extern Status
XcmsCIExyYToCIEXYZ (
555 XcmsColor
* /* white_point */,
556 XcmsColor
* /* colors */,
557 unsigned int /* ncolors */
560 extern XcmsColor
*XcmsClientWhitePointOfCCC (
564 extern Status
XcmsConvertColors (
566 XcmsColor
* /* colorArry_in_out */,
567 unsigned int /* nColors */,
568 XcmsColorFormat
/* targetFormat */,
569 Bool
* /* compArry_return */
572 extern XcmsCCC
XcmsCreateCCC (
574 int /* screenNumber */,
575 Visual
* /* visual */,
576 XcmsColor
* /* clientWhitePt */,
577 XcmsCompressionProc
/* gamutCompProc */,
578 XPointer
/* gamutCompClientData */,
579 XcmsWhiteAdjustProc
/* whitePtAdjProc */,
580 XPointer
/* whitePtAdjClientData */
583 extern XcmsCCC
XcmsDefaultCCC (
585 int /* screenNumber */
588 extern Display
*XcmsDisplayOfCCC (
592 extern XcmsColorFormat
XcmsFormatOfPrefix (
596 extern void XcmsFreeCCC (
600 extern Status
XcmsLookupColor (
602 Colormap
/* colormap */,
603 _Xconst
char* /* color_string */,
604 XcmsColor
* /* pColor_exact_in_out */,
605 XcmsColor
* /* pColor_scrn_in_out */,
606 XcmsColorFormat
/* result_format */
609 extern char *XcmsPrefixOfFormat (
610 XcmsColorFormat
/* id */
613 extern Status
XcmsQueryBlack (
615 XcmsColorFormat
/* target_format */,
616 XcmsColor
* /* color_return */
619 extern Status
XcmsQueryBlue (
621 XcmsColorFormat
/* target_format */,
622 XcmsColor
* /* color_return */
625 extern Status
XcmsQueryColor (
627 Colormap
/* colormap */,
628 XcmsColor
* /* pColor_in_out */,
629 XcmsColorFormat
/* result_format */
632 extern Status
XcmsQueryColors (
634 Colormap
/* colormap */,
635 XcmsColor
* /* colorArry_in_out */,
636 unsigned int /* nColors */,
637 XcmsColorFormat
/* result_format */
640 extern Status
XcmsQueryGreen (
642 XcmsColorFormat
/* target_format */,
643 XcmsColor
* /* color_return */
646 extern Status
XcmsQueryRed (
648 XcmsColorFormat
/* target_format */,
649 XcmsColor
* /* color_return */
652 extern Status
XcmsQueryWhite (
654 XcmsColorFormat
/* target_format */,
655 XcmsColor
* /* color_return */
658 extern Status
XcmsRGBiToCIEXYZ (
660 XcmsColor
* /* colors */,
661 unsigned int /* ncolors */,
662 Bool
* /* compression_flags_return */
665 extern Status
XcmsRGBiToRGB (
667 XcmsColor
* /* colors */,
668 unsigned int /* ncolors */,
669 Bool
* /* compression_flags_return */
672 extern Status
XcmsRGBToRGBi (
674 XcmsColor
* /* colors */,
675 unsigned int /* ncolors */,
676 Bool
* /* compression_flags_return */
679 extern int XcmsScreenNumberOfCCC (
683 extern XcmsColor
*XcmsScreenWhitePointOfCCC (
687 extern XcmsCCC
XcmsSetCCCOfColormap(
689 Colormap
/* colormap */,
693 extern XcmsCompressionProc
XcmsSetCompressionProc (
695 XcmsCompressionProc
/* compression_proc */,
696 XPointer
/* client_data */
699 extern XcmsWhiteAdjustProc
XcmsSetWhiteAdjustProc (
701 XcmsWhiteAdjustProc
/* white_adjust_proc */,
702 XPointer
/* client_data */
705 extern Status
XcmsSetWhitePoint (
707 XcmsColor
* /* color */
710 extern Status
XcmsStoreColor (
712 Colormap
/* colormap */,
713 XcmsColor
* /* pColor_in */
716 extern Status
XcmsStoreColors (
718 Colormap
/* colormap */,
719 XcmsColor
* /* colorArry_in */,
720 unsigned int /* nColors */,
721 Bool
* /* compArry_return */
724 extern Status
XcmsTekHVCClipC(
726 XcmsColor
* /* colors_in_out */,
727 unsigned int /* ncolors */,
728 unsigned int /* index */,
729 Bool
* /* compression_flags_return */
732 extern Status
XcmsTekHVCClipV(
734 XcmsColor
* /* colors_in_out */,
735 unsigned int /* ncolors */,
736 unsigned int /* index */,
737 Bool
* /* compression_flags_return */
740 extern Status
XcmsTekHVCClipVC(
742 XcmsColor
* /* colors_in_out */,
743 unsigned int /* ncolors */,
744 unsigned int /* index */,
745 Bool
* /* compression_flags_return */
748 extern Status
XcmsTekHVCQueryMaxC (
751 XcmsFloat
/* value */,
752 XcmsColor
* /* color_return */
755 extern Status
XcmsTekHVCQueryMaxV (
758 XcmsFloat
/* chroma */,
759 XcmsColor
* /* color_return */
762 extern Status
XcmsTekHVCQueryMaxVC (
765 XcmsColor
* /* color_return */
768 extern Status
XcmsTekHVCQueryMaxVSamples (
771 XcmsColor
* /* colors_return */,
772 unsigned int /* nsamples */
775 extern Status
XcmsTekHVCQueryMinV (
778 XcmsFloat
/* chroma */,
779 XcmsColor
* /* color_return */
782 extern Status
XcmsTekHVCToCIEuvY (
784 XcmsColor
* /* white_point */,
785 XcmsColor
* /* colors */,
786 unsigned int /* ncolors */
789 extern Status
XcmsTekHVCWhiteShiftColors(
791 XcmsColor
* /* initial_white_point*/,
792 XcmsColor
* /* target_white_point*/,
793 XcmsColorFormat
/* target_format */,
794 XcmsColor
* /* colors_in_out */,
795 unsigned int /* ncolors */,
796 Bool
* /* compression_flags_return */
799 extern Visual
*XcmsVisualOfCCC (
805 #endif /* _XCMS_H_ */