1 /* $XConsortium: Xcms.h,v 1.15 92/11/19 16:43:04 rws 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
38 #define XcmsSuccessWithCompression 2
41 * Color Space Format ID's
42 * Color Space ID's are of XcmsColorFormat type.
45 * 0 == Device-Independent
46 * 1 == Device-Dependent
49 * 0 == Registered with X Consortium
52 #define XcmsUndefinedFormat (XcmsColorFormat)0x00000000
53 #define XcmsCIEXYZFormat (XcmsColorFormat)0x00000001
54 #define XcmsCIEuvYFormat (XcmsColorFormat)0x00000002
55 #define XcmsCIExyYFormat (XcmsColorFormat)0x00000003
56 #define XcmsCIELabFormat (XcmsColorFormat)0x00000004
57 #define XcmsCIELuvFormat (XcmsColorFormat)0x00000005
58 #define XcmsTekHVCFormat (XcmsColorFormat)0x00000006
59 #define XcmsRGBFormat (XcmsColorFormat)0x80000000
60 #define XcmsRGBiFormat (XcmsColorFormat)0x80000001
63 * State of XcmsPerScrnInfo
65 #define XcmsInitNone 0x00 /* no initialization attempted */
66 #define XcmsInitSuccess 0x01 /* initialization successful */
67 #define XcmsInitFailure 0xff /* failure, use defaults */
69 #define DisplayOfCCC(ccc) ((ccc)->dpy)
70 #define ScreenNumberOfCCC(ccc) ((ccc)->screenNumber)
71 #define VisualOfCCC(ccc) ((ccc)->visual)
72 #define ClientWhitePointOfCCC(ccc) (&(ccc)->clientWhitePt)
73 #define ScreenWhitePointOfCCC(ccc) (&(ccc)->pPerScrnInfo->screenWhitePt)
74 #define FunctionSetOfCCC(ccc) ((ccc)->pPerScrnInfo->functionSet)
76 typedef unsigned long XcmsColorFormat; /* Color Space Format ID */
78 typedef double XcmsFloat;
84 unsigned short red; /* scaled from 0x0000 to 0xffff */
85 unsigned short green; /* scaled from 0x0000 to 0xffff */
86 unsigned short blue; /* scaled from 0x0000 to 0xffff */
93 XcmsFloat red; /* 0.0 - 1.0 */
94 XcmsFloat green; /* 0.0 - 1.0 */
95 XcmsFloat blue; /* 0.0 - 1.0 */
111 XcmsFloat u_prime; /* 0.0 - 1.0 */
112 XcmsFloat v_prime; /* 0.0 - 1.0 */
113 XcmsFloat Y; /* 0.0 - 1.0 */
120 XcmsFloat x; /* 0.0 - 1.0 */
121 XcmsFloat y; /* 0.0 - 1.0 */
122 XcmsFloat Y; /* 0.0 - 1.0 */
129 XcmsFloat L_star; /* 0.0 - 100.0 */
138 XcmsFloat L_star; /* 0.0 - 100.0 */
147 XcmsFloat H; /* 0.0 - 360.0 */
148 XcmsFloat V; /* 0.0 - 100.0 */
149 XcmsFloat C; /* 0.0 - 100.0 */
164 * XCMS Color Structure
177 } spec; /* the color specification */
178 unsigned long pixel; /* pixel value (as needed) */
179 XcmsColorFormat format; /* the specification format */
184 * XCMS Per Screen related data
187 typedef struct _XcmsPerScrnInfo {
188 XcmsColor screenWhitePt; /* Screen White point */
189 XPointer functionSet; /* pointer to Screen Color Characterization */
190 /* Function Set structure */
191 XPointer screenData; /* pointer to corresponding Screen Color*/
192 /* Characterization Data */
193 unsigned char state; /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */
197 typedef struct _XcmsCCC *XcmsCCC;
199 typedef Status (*XcmsCompressionProc)( /* Gamut Compression Proc */
200 #if NeedFunctionPrototypes
202 XcmsColor* /* colors_in_out */,
203 unsigned int /* ncolors */,
204 unsigned int /* index */,
205 Bool* /* compression_flags_return */
209 typedef Status (*XcmsWhiteAdjustProc)( /* White Point Adjust Proc */
210 #if NeedFunctionPrototypes
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 */
222 * XCMS Color Conversion Context
224 typedef struct _XcmsCCC {
225 Display *dpy; /* X Display */
226 int screenNumber; /* X screen number */
227 Visual *visual; /* X Visual */
228 XcmsColor clientWhitePt; /* Client White Point */
229 XcmsCompressionProc gamutCompProc; /* Gamut Compression Function */
230 XPointer gamutCompClientData; /* Gamut Comp Func Client Data */
231 XcmsWhiteAdjustProc whitePtAdjProc; /* White Point Adjustment Function */
232 XPointer whitePtAdjClientData; /* White Pt Adj Func Client Data */
233 XcmsPerScrnInfo *pPerScrnInfo; /* pointer to per screen information */
234 /* associated with the above display */
238 typedef Status (*XcmsScreenInitProc)( /* Screen Initialization Proc */
239 #if NeedFunctionPrototypes
241 int /* screen_number */,
242 XcmsPerScrnInfo* /* screen_info */
246 typedef void (*XcmsScreenFreeProc)(
247 #if NeedFunctionPrototypes
248 XPointer /* screenData */
253 * Function List Pointer -- pointer to an array of function pointers.
254 * The end of list is indicated by a NULL pointer.
256 typedef Status (*XcmsConversionProc)();
257 typedef XcmsConversionProc *XcmsFuncListPtr;
259 typedef int (*XcmsParseStringProc)( /* Color String Parsing Proc */
260 #if NeedFunctionPrototypes
261 char* /* color_string */,
262 XcmsColor* /* color_return */
267 * Color Space -- per Color Space related data (Device-Independent
268 * or Device-Dependent)
270 typedef struct _XcmsColorSpace {
271 char *prefix; /* Prefix of string format. */
272 XcmsColorFormat id; /* Format ID number. */
273 XcmsParseStringProc parseString;
274 /* String format parsing function */
275 XcmsFuncListPtr to_CIEXYZ; /* Pointer to an array of function */
276 /* pointers such that when the */
277 /* functions are executed in sequence */
278 /* will convert a XcmsColor structure */
279 /* from this color space to CIEXYZ */
281 XcmsFuncListPtr from_CIEXYZ;/* Pointer to an array of function */
282 /* pointers such that when the */
283 /* functions are executed in sequence */
284 /* will convert a XcmsColor structure */
285 /* from CIEXYZ space to this color */
287 int inverse_flag; /* If 1, indicates that for 0 <= i < n */
288 /* where n is the number of function */
289 /* pointers in the lists to_CIEXYZ */
290 /* and from_CIEXYZ; for each function */
291 /* to_CIEXYZ[i] its inverse function */
292 /* is from_CIEXYZ[n - i]. */
297 * Screen Color Characterization Function Set -- per device class
298 * color space conversion functions.
300 typedef struct _XcmsFunctionSet {
301 XcmsColorSpace **DDColorSpaces;
302 /* Pointer to an array of pointers to */
303 /* Device-DEPENDENT color spaces */
304 /* understood by this SCCFuncSet. */
305 XcmsScreenInitProc screenInitProc;
306 /* Screen initialization function that */
307 /* reads Screen Color Characterization*/
308 /* Data off properties on the screen's*/
310 XcmsScreenFreeProc screenFreeProc;
311 /* Function that frees the SCCData */
317 extern Status XcmsAddColorSpace (
318 #if NeedFunctionPrototypes
319 XcmsColorSpace* /* pColorSpace */
323 extern Status XcmsAddFunctionSet (
324 #if NeedFunctionPrototypes
325 XcmsFunctionSet* /* functionSet */
329 extern Status XcmsAllocColor (
330 #if NeedFunctionPrototypes
332 Colormap /* colormap */,
333 XcmsColor* /* color_in_out */,
334 XcmsColorFormat /* result_format */
338 extern Status XcmsAllocNamedColor (
339 #if NeedFunctionPrototypes
341 Colormap /* colormap */,
342 _Xconst char* /* color_string */,
343 XcmsColor* /* color_scrn_return */,
344 XcmsColor* /* color_exact_return */,
345 XcmsColorFormat /* result_format */
349 extern XcmsCCC XcmsCCCOfColormap (
350 #if NeedFunctionPrototypes
352 Colormap /* colormap */
356 extern Status XcmsCIELabClipab(
357 #if NeedFunctionPrototypes
359 XcmsColor* /* colors_in_out */,
360 unsigned int /* ncolors */,
361 unsigned int /* index */,
362 Bool* /* compression_flags_return */
366 extern Status XcmsCIELabClipL(
367 #if NeedFunctionPrototypes
369 XcmsColor* /* colors_in_out */,
370 unsigned int /* ncolors */,
371 unsigned int /* index */,
372 Bool* /* compression_flags_return */
376 extern Status XcmsCIELabClipLab(
377 #if NeedFunctionPrototypes
379 XcmsColor* /* colors_in_out */,
380 unsigned int /* ncolors */,
381 unsigned int /* index */,
382 Bool* /* compression_flags_return */
386 extern Status XcmsCIELabQueryMaxC (
387 #if NeedFunctionPrototypes
389 XcmsFloat /* hue_angle */,
390 XcmsFloat /* L_star */,
391 XcmsColor* /* color_return */
395 extern Status XcmsCIELabQueryMaxL (
396 #if NeedFunctionPrototypes
398 XcmsFloat /* hue_angle */,
399 XcmsFloat /* chroma */,
400 XcmsColor* /* color_return */
404 extern Status XcmsCIELabQueryMaxLC (
405 #if NeedFunctionPrototypes
407 XcmsFloat /* hue_angle */,
408 XcmsColor* /* color_return */
412 extern Status XcmsCIELabQueryMinL (
413 #if NeedFunctionPrototypes
415 XcmsFloat /* hue_angle */,
416 XcmsFloat /* chroma */,
417 XcmsColor* /* color_return */
421 extern Status XcmsCIELabToCIEXYZ (
422 #if NeedFunctionPrototypes
424 XcmsColor* /* white_point */,
425 XcmsColor* /* colors */,
426 unsigned int /* ncolors */
430 extern Status XcmsCIELabWhiteShiftColors(
431 #if NeedFunctionPrototypes
433 XcmsColor* /* initial_white_point*/,
434 XcmsColor* /* target_white_point*/,
435 XcmsColorFormat /* target_format */,
436 XcmsColor* /* colors_in_out */,
437 unsigned int /* ncolors */,
438 Bool* /* compression_flags_return */
442 extern Status XcmsCIELuvClipL(
443 #if NeedFunctionPrototypes
445 XcmsColor* /* colors_in_out */,
446 unsigned int /* ncolors */,
447 unsigned int /* index */,
448 Bool* /* compression_flags_return */
452 extern Status XcmsCIELuvClipLuv(
453 #if NeedFunctionPrototypes
455 XcmsColor* /* colors_in_out */,
456 unsigned int /* ncolors */,
457 unsigned int /* index */,
458 Bool* /* compression_flags_return */
462 extern Status XcmsCIELuvClipuv(
463 #if NeedFunctionPrototypes
465 XcmsColor* /* colors_in_out */,
466 unsigned int /* ncolors */,
467 unsigned int /* index */,
468 Bool* /* compression_flags_return */
472 extern Status XcmsCIELuvQueryMaxC (
473 #if NeedFunctionPrototypes
475 XcmsFloat /* hue_angle */,
476 XcmsFloat /* L_star */,
477 XcmsColor* /* color_return */
481 extern Status XcmsCIELuvQueryMaxL (
482 #if NeedFunctionPrototypes
484 XcmsFloat /* hue_angle */,
485 XcmsFloat /* chroma */,
486 XcmsColor* /* color_return */
490 extern Status XcmsCIELuvQueryMaxLC (
491 #if NeedFunctionPrototypes
493 XcmsFloat /* hue_angle */,
494 XcmsColor* /* color_return */
498 extern Status XcmsCIELuvQueryMinL (
499 #if NeedFunctionPrototypes
501 XcmsFloat /* hue_angle */,
502 XcmsFloat /* chroma */,
503 XcmsColor* /* color_return */
507 extern Status XcmsCIELuvToCIEuvY (
508 #if NeedFunctionPrototypes
510 XcmsColor* /* white_point */,
511 XcmsColor* /* colors */,
512 unsigned int /* ncolors */
516 extern Status XcmsCIELuvWhiteShiftColors(
517 #if NeedFunctionPrototypes
519 XcmsColor* /* initial_white_point*/,
520 XcmsColor* /* target_white_point*/,
521 XcmsColorFormat /* target_format */,
522 XcmsColor* /* colors_in_out */,
523 unsigned int /* ncolors */,
524 Bool* /* compression_flags_return */
528 extern Status XcmsCIEXYZToCIELab (
529 #if NeedFunctionPrototypes
531 XcmsColor* /* white_point */,
532 XcmsColor* /* colors */,
533 unsigned int /* ncolors */
537 extern Status XcmsCIEXYZToCIEuvY (
538 #if NeedFunctionPrototypes
540 XcmsColor* /* white_point */,
541 XcmsColor* /* colors */,
542 unsigned int /* ncolors */
546 extern Status XcmsCIEXYZToCIExyY (
547 #if NeedFunctionPrototypes
549 XcmsColor* /* white_point */,
550 XcmsColor* /* colors */,
551 unsigned int /* ncolors */
555 extern Status XcmsCIEXYZToRGBi (
556 #if NeedFunctionPrototypes
558 XcmsColor* /* colors */,
559 unsigned int /* ncolors */,
560 Bool* /* compression_flags_return */
564 extern Status XcmsCIEuvYToCIELuv (
565 #if NeedFunctionPrototypes
567 XcmsColor* /* white_point */,
568 XcmsColor* /* colors */,
569 unsigned int /* ncolors */
573 extern Status XcmsCIEuvYToCIEXYZ (
574 #if NeedFunctionPrototypes
576 XcmsColor* /* white_point */,
577 XcmsColor* /* colors */,
578 unsigned int /* ncolors */
582 extern Status XcmsCIEuvYToTekHVC (
583 #if NeedFunctionPrototypes
585 XcmsColor* /* white_point */,
586 XcmsColor* /* colors */,
587 unsigned int /* ncolors */
591 extern Status XcmsCIExyYToCIEXYZ (
592 #if NeedFunctionPrototypes
594 XcmsColor* /* white_point */,
595 XcmsColor* /* colors */,
596 unsigned int /* ncolors */
600 extern XcmsColor *XcmsClientWhitePointOfCCC (
601 #if NeedFunctionPrototypes
606 extern Status XcmsConvertColors (
607 #if NeedFunctionPrototypes
609 XcmsColor* /* colorArry_in_out */,
610 unsigned int /* nColors */,
611 XcmsColorFormat /* targetFormat */,
612 Bool* /* compArry_return */
616 extern XcmsCCC XcmsCreateCCC (
617 #if NeedFunctionPrototypes
619 int /* screenNumber */,
620 Visual* /* visual */,
621 XcmsColor* /* clientWhitePt */,
622 XcmsCompressionProc /* gamutCompProc */,
623 XPointer /* gamutCompClientData */,
624 XcmsWhiteAdjustProc /* whitePtAdjProc */,
625 XPointer /* whitePtAdjClientData */
629 extern XcmsCCC XcmsDefaultCCC (
630 #if NeedFunctionPrototypes
632 int /* screenNumber */
636 extern Display *XcmsDisplayOfCCC (
637 #if NeedFunctionPrototypes
642 extern XcmsColorFormat XcmsFormatOfPrefix (
643 #if NeedFunctionPrototypes
648 extern void XcmsFreeCCC (
649 #if NeedFunctionPrototypes
654 extern Status XcmsLookupColor (
655 #if NeedFunctionPrototypes
657 Colormap /* colormap */,
658 _Xconst char* /* color_string */,
659 XcmsColor* /* pColor_exact_in_out */,
660 XcmsColor* /* pColor_scrn_in_out */,
661 XcmsColorFormat /* result_format */
665 extern char *XcmsPrefixOfFormat (
666 #if NeedFunctionPrototypes
667 XcmsColorFormat /* id */
671 extern Status XcmsQueryBlack (
672 #if NeedFunctionPrototypes
674 XcmsColorFormat /* target_format */,
675 XcmsColor* /* color_return */
679 extern Status XcmsQueryBlue (
680 #if NeedFunctionPrototypes
682 XcmsColorFormat /* target_format */,
683 XcmsColor* /* color_return */
687 extern Status XcmsQueryColor (
688 #if NeedFunctionPrototypes
690 Colormap /* colormap */,
691 XcmsColor* /* pColor_in_out */,
692 XcmsColorFormat /* result_format */
696 extern Status XcmsQueryColors (
697 #if NeedFunctionPrototypes
699 Colormap /* colormap */,
700 XcmsColor* /* colorArry_in_out */,
701 unsigned int /* nColors */,
702 XcmsColorFormat /* result_format */
706 extern Status XcmsQueryGreen (
707 #if NeedFunctionPrototypes
709 XcmsColorFormat /* target_format */,
710 XcmsColor* /* color_return */
714 extern Status XcmsQueryRed (
715 #if NeedFunctionPrototypes
717 XcmsColorFormat /* target_format */,
718 XcmsColor* /* color_return */
722 extern Status XcmsQueryWhite (
723 #if NeedFunctionPrototypes
725 XcmsColorFormat /* target_format */,
726 XcmsColor* /* color_return */
730 extern Status XcmsRGBiToCIEXYZ (
731 #if NeedFunctionPrototypes
733 XcmsColor* /* colors */,
734 unsigned int /* ncolors */,
735 Bool* /* compression_flags_return */
739 extern Status XcmsRGBiToRGB (
740 #if NeedFunctionPrototypes
742 XcmsColor* /* colors */,
743 unsigned int /* ncolors */,
744 Bool* /* compression_flags_return */
748 extern Status XcmsRGBToRGBi (
749 #if NeedFunctionPrototypes
751 XcmsColor* /* colors */,
752 unsigned int /* ncolors */,
753 Bool* /* compression_flags_return */
757 extern int XcmsScreenNumberOfCCC (
758 #if NeedFunctionPrototypes
763 extern XcmsColor *XcmsScreenWhitePointOfCCC (
764 #if NeedFunctionPrototypes
769 extern XcmsCCC XcmsSetCCCOfColormap(
770 #if NeedFunctionPrototypes
772 Colormap /* colormap */,
777 extern XcmsCompressionProc XcmsSetCompressionProc (
778 #if NeedFunctionPrototypes
780 XcmsCompressionProc /* compression_proc */,
781 XPointer /* client_data */
785 extern XcmsWhiteAdjustProc XcmsSetWhiteAdjustProc (
786 #if NeedFunctionPrototypes
788 XcmsWhiteAdjustProc /* white_adjust_proc */,
789 XPointer /* client_data */
793 extern Status XcmsSetWhitePoint (
794 #if NeedFunctionPrototypes
796 XcmsColor* /* color */
800 extern Status XcmsStoreColor (
801 #if NeedFunctionPrototypes
803 Colormap /* colormap */,
804 XcmsColor* /* pColor_in */
808 extern Status XcmsStoreColors (
809 #if NeedFunctionPrototypes
811 Colormap /* colormap */,
812 XcmsColor* /* colorArry_in */,
813 unsigned int /* nColors */,
814 Bool* /* compArry_return */
818 extern Status XcmsTekHVCClipC(
819 #if NeedFunctionPrototypes
821 XcmsColor* /* colors_in_out */,
822 unsigned int /* ncolors */,
823 unsigned int /* index */,
824 Bool* /* compression_flags_return */
828 extern Status XcmsTekHVCClipV(
829 #if NeedFunctionPrototypes
831 XcmsColor* /* colors_in_out */,
832 unsigned int /* ncolors */,
833 unsigned int /* index */,
834 Bool* /* compression_flags_return */
838 extern Status XcmsTekHVCClipVC(
839 #if NeedFunctionPrototypes
841 XcmsColor* /* colors_in_out */,
842 unsigned int /* ncolors */,
843 unsigned int /* index */,
844 Bool* /* compression_flags_return */
848 extern Status XcmsTekHVCQueryMaxC (
849 #if NeedFunctionPrototypes
852 XcmsFloat /* value */,
853 XcmsColor* /* color_return */
857 extern Status XcmsTekHVCQueryMaxV (
858 #if NeedFunctionPrototypes
861 XcmsFloat /* chroma */,
862 XcmsColor* /* color_return */
866 extern Status XcmsTekHVCQueryMaxVC (
867 #if NeedFunctionPrototypes
870 XcmsColor* /* color_return */
874 extern Status XcmsTekHVCQueryMaxVSamples (
875 #if NeedFunctionPrototypes
878 XcmsColor* /* colors_return */,
879 unsigned int /* nsamples */
883 extern Status XcmsTekHVCQueryMinV (
884 #if NeedFunctionPrototypes
887 XcmsFloat /* chroma */,
888 XcmsColor* /* color_return */
892 extern Status XcmsTekHVCToCIEuvY (
893 #if NeedFunctionPrototypes
895 XcmsColor* /* white_point */,
896 XcmsColor* /* colors */,
897 unsigned int /* ncolors */
901 extern Status XcmsTekHVCWhiteShiftColors(
902 #if NeedFunctionPrototypes
904 XcmsColor* /* initial_white_point*/,
905 XcmsColor* /* target_white_point*/,
906 XcmsColorFormat /* target_format */,
907 XcmsColor* /* colors_in_out */,
908 unsigned int /* ncolors */,
909 Bool* /* compression_flags_return */
913 extern Visual *XcmsVisualOfCCC (
914 #if NeedFunctionPrototypes
921 #endif /* _XCMS_H_ */