* Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
* This file is a component of an X Window System-specific implementation
* of Xcms based on the TekColor Color Management System. Permission is
* hereby granted to use, copy, modify, sell, and otherwise distribute this
* software and its documentation for any purpose and without fee, provided
* that this copyright, permission, and disclaimer notice is reproduced in
* all copies of this software and in supporting documentation. TekColor
* is a trademark of Tektronix, Inc.
* Tektronix makes no representation about the suitability of this software
* for any purpose. It is provided "as is" and with all faults.
* TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
* INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
* Public include file for X Color Management System
/* The Xcms structs are full of implicit padding to properly align members.
We can't clean that up without breaking ABI, so tell clang not to bother
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#define XcmsSuccessWithCompression 2
* Color Space Format ID's
* Color Space ID's are of XcmsColorFormat type.
* 0 == Device-Independent
* 0 == Registered with X Consortium
#define XcmsUndefinedFormat (XcmsColorFormat)0x00000000
#define XcmsCIEXYZFormat (XcmsColorFormat)0x00000001
#define XcmsCIEuvYFormat (XcmsColorFormat)0x00000002
#define XcmsCIExyYFormat (XcmsColorFormat)0x00000003
#define XcmsCIELabFormat (XcmsColorFormat)0x00000004
#define XcmsCIELuvFormat (XcmsColorFormat)0x00000005
#define XcmsTekHVCFormat (XcmsColorFormat)0x00000006
#define XcmsRGBFormat (XcmsColorFormat)0x80000000
#define XcmsRGBiFormat (XcmsColorFormat)0x80000001
* State of XcmsPerScrnInfo
#define XcmsInitNone 0x00 /* no initialization attempted */
#define XcmsInitSuccess 0x01 /* initialization successful */
#define XcmsInitFailure 0xff /* failure, use defaults */
#define DisplayOfCCC(ccc) ((ccc)->dpy)
#define ScreenNumberOfCCC(ccc) ((ccc)->screenNumber)
#define VisualOfCCC(ccc) ((ccc)->visual)
#define ClientWhitePointOfCCC(ccc) (&(ccc)->clientWhitePt)
#define ScreenWhitePointOfCCC(ccc) (&(ccc)->pPerScrnInfo->screenWhitePt)
#define FunctionSetOfCCC(ccc) ((ccc)->pPerScrnInfo->functionSet)
typedef unsigned long XcmsColorFormat; /* Color Space Format ID */
typedef double XcmsFloat;
unsigned short red; /* scaled from 0x0000 to 0xffff */
unsigned short green; /* scaled from 0x0000 to 0xffff */
unsigned short blue; /* scaled from 0x0000 to 0xffff */
XcmsFloat red; /* 0.0 - 1.0 */
XcmsFloat green; /* 0.0 - 1.0 */
XcmsFloat blue; /* 0.0 - 1.0 */
XcmsFloat u_prime; /* 0.0 - 1.0 */
XcmsFloat v_prime; /* 0.0 - 1.0 */
XcmsFloat Y; /* 0.0 - 1.0 */
XcmsFloat x; /* 0.0 - 1.0 */
XcmsFloat y; /* 0.0 - 1.0 */
XcmsFloat Y; /* 0.0 - 1.0 */
XcmsFloat L_star; /* 0.0 - 100.0 */
XcmsFloat L_star; /* 0.0 - 100.0 */
XcmsFloat H; /* 0.0 - 360.0 */
XcmsFloat V; /* 0.0 - 100.0 */
XcmsFloat C; /* 0.0 - 100.0 */
} spec; /* the color specification */
unsigned long pixel; /* pixel value (as needed) */
XcmsColorFormat format; /* the specification format */
* XCMS Per Screen related data
typedef struct _XcmsPerScrnInfo {
XcmsColor screenWhitePt; /* Screen White point */
XPointer functionSet; /* pointer to Screen Color Characterization */
/* Function Set structure */
XPointer screenData; /* pointer to corresponding Screen Color*/
/* Characterization Data */
unsigned char state; /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */
typedef struct _XcmsCCC *XcmsCCC;
typedef Status (*XcmsCompressionProc)( /* Gamut Compression Proc */
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
typedef Status (*XcmsWhiteAdjustProc)( /* White Point Adjust Proc */
XcmsColor* /* initial_white_point*/,
XcmsColor* /* target_white_point*/,
XcmsColorFormat /* target_format */,
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
Bool* /* compression_flags_return */
* XCMS Color Conversion Context
typedef struct _XcmsCCC {
Display *dpy; /* X Display */
int screenNumber; /* X screen number */
Visual *visual; /* X Visual */
XcmsColor clientWhitePt; /* Client White Point */
XcmsCompressionProc gamutCompProc; /* Gamut Compression Function */
XPointer gamutCompClientData; /* Gamut Comp Func Client Data */
XcmsWhiteAdjustProc whitePtAdjProc; /* White Point Adjustment Function */
XPointer whitePtAdjClientData; /* White Pt Adj Func Client Data */
XcmsPerScrnInfo *pPerScrnInfo; /* pointer to per screen information */
/* associated with the above display */
typedef Status (*XcmsScreenInitProc)( /* Screen Initialization Proc */
XcmsPerScrnInfo* /* screen_info */
typedef void (*XcmsScreenFreeProc)(
XPointer /* screenData */
* Function List Pointer -- pointer to an array of function pointers.
* The end of list is indicated by a NULL pointer.
* XXX: The use of the XcmsConversionProc type is broken. The
* device-independent colour conversion code uses it as:
typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, XcmsColor *,
* while the device-dependent code uses it as:
typedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, unsigned int,
* Until this is reworked, it's probably best to leave it unprotoized.
* The code works regardless.
typedef Status (*XcmsDDConversionProc)( /* using device-dependent version */
XcmsColor* /* pcolors_in_out */,
unsigned int /* ncolors */,
typedef Status (*XcmsDIConversionProc)( /* using device-independent version */
XcmsColor* /* white_point */,
XcmsColor* /* pcolors_in_out */,
unsigned int /* ncolors */
typedef XcmsDIConversionProc XcmsConversionProc;
typedef XcmsConversionProc *XcmsFuncListPtr;
typedef int (*XcmsParseStringProc)( /* Color String Parsing Proc */
char* /* color_string */,
XcmsColor* /* color_return */
* Color Space -- per Color Space related data (Device-Independent
typedef struct _XcmsColorSpace {
const char *prefix; /* Prefix of string format. */
XcmsColorFormat id; /* Format ID number. */
XcmsParseStringProc parseString;
/* String format parsing function */
XcmsFuncListPtr to_CIEXYZ; /* Pointer to an array of function */
/* pointers such that when the */
/* functions are executed in sequence */
/* will convert a XcmsColor structure */
/* from this color space to CIEXYZ */
XcmsFuncListPtr from_CIEXYZ;/* Pointer to an array of function */
/* pointers such that when the */
/* functions are executed in sequence */
/* will convert a XcmsColor structure */
/* from CIEXYZ space to this color */
int inverse_flag; /* If 1, indicates that for 0 <= i < n */
/* where n is the number of function */
/* pointers in the lists to_CIEXYZ */
/* and from_CIEXYZ; for each function */
/* to_CIEXYZ[i] its inverse function */
/* is from_CIEXYZ[n - i]. */
* Screen Color Characterization Function Set -- per device class
* color space conversion functions.
typedef struct _XcmsFunctionSet {
XcmsColorSpace **DDColorSpaces;
/* Pointer to an array of pointers to */
/* Device-DEPENDENT color spaces */
/* understood by this SCCFuncSet. */
XcmsScreenInitProc screenInitProc;
/* Screen initialization function that */
/* reads Screen Color Characterization*/
/* Data off properties on the screen's*/
XcmsScreenFreeProc screenFreeProc;
/* Function that frees the SCCData */
extern Status XcmsAddColorSpace (
XcmsColorSpace* /* pColorSpace */
extern Status XcmsAddFunctionSet (
XcmsFunctionSet* /* functionSet */
extern Status XcmsAllocColor (
XcmsColor* /* color_in_out */,
XcmsColorFormat /* result_format */
extern Status XcmsAllocNamedColor (
_Xconst char* /* color_string */,
XcmsColor* /* color_scrn_return */,
XcmsColor* /* color_exact_return */,
XcmsColorFormat /* result_format */
extern XcmsCCC XcmsCCCOfColormap (
extern Status XcmsCIELabClipab(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELabClipL(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELabClipLab(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELabQueryMaxC (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELabQueryMaxL (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELabQueryMaxLC (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELabQueryMinL (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELabToCIEXYZ (
XcmsColor* /* white_point */,
unsigned int /* ncolors */
extern Status XcmsCIELabWhiteShiftColors(
XcmsColor* /* initial_white_point*/,
XcmsColor* /* target_white_point*/,
XcmsColorFormat /* target_format */,
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
Bool* /* compression_flags_return */
extern Status XcmsCIELuvClipL(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELuvClipLuv(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELuvClipuv(
XcmsColor* /* colors_in_out */,
unsigned int /* ncolors */,
unsigned int /* index */,
Bool* /* compression_flags_return */
extern Status XcmsCIELuvQueryMaxC (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELuvQueryMaxL (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELuvQueryMaxLC (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELuvQueryMinL (
XcmsFloat /* hue_angle */,
XcmsColor* /* color_return */
extern Status XcmsCIELuvToCIEuvY (
XcmsColor* /* white_point */,
unsigned int /* ncolors */
extern Status XcmsCIELuvWhiteShiftColors(