home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xcmsint.h < prev    next >
C/C++ Source or Header  |  1999-11-02  |  8KB  |  247 lines

  1. /* $XConsortium: Xcmsint.h,v 1.19 95/06/08 23:20:39 gildea 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.  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.
  14.  * 
  15.  * Tektronix makes no representation about the suitability of this software
  16.  * for any purpose.  It is provided "as is" and with all faults.
  17.  * 
  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.
  25.  *
  26.  *
  27.  *    DESCRIPTION
  28.  *        Private include file for Color Management System.
  29.  *        (i.e., for API internal use only)
  30.  *
  31.  */
  32. #ifndef _XCMSINT_H_
  33. #define _XCMSINT_H_
  34.  
  35. #include <X11/Xcms.h>
  36.  
  37. /*
  38.  *    DEFINES
  39.  */
  40.  
  41.     /*
  42.      * Private Status Value
  43.      */
  44. #define    _XCMS_NEWNAME    -1
  45.  
  46.     /*
  47.      * Color Space ID's are of XcmsColorFormat type.
  48.      *
  49.      *    bit 31
  50.      *        0 == Device-Independent
  51.      *        1 == Device-Dependent
  52.      *
  53.      *    bit 30:
  54.          *          0 == Registered with X Consortium
  55.          *          1 == Unregistered
  56.          */
  57. #define       XCMS_DD_ID(id)          ((id) & (XcmsColorFormat)0x80000000)
  58. #define       XCMS_DI_ID(id)          (!((id) & (XcmsColorFormat)0x80000000))
  59. #define       XCMS_UNREG_ID(id)       ((id) & (XcmsColorFormat)0x40000000)
  60. #define       XCMS_REG_ID(id)         (!((id) & (XcmsColorFormat)0x40000000))
  61. #define       XCMS_FIRST_REG_DI_ID    (XcmsColorFormat)0x00000001
  62. #define       XCMS_FIRST_UNREG_DI_ID  (XcmsColorFormat)0x40000000
  63. #define       XCMS_FIRST_REG_DD_ID    (XcmsColorFormat)0x80000000
  64. #define       XCMS_FIRST_UNREG_DD_ID  (XcmsColorFormat)0xc0000000
  65.  
  66. /*
  67.  *    TYPEDEFS
  68.  */
  69.  
  70.     /*
  71.      * Structure for caching Colormap info.
  72.      *    This is provided for the Xlib modifications to:
  73.      *        XAllocNamedColor()
  74.      *        XLookupColor()
  75.      *        XParseColor()
  76.      *        XStoreNamedColor()
  77.      */
  78. typedef struct _XcmsCmapRec {
  79.     Colormap cmapID;
  80.     Display *dpy;
  81.     Window windowID;
  82.     Visual *visual;
  83.     struct _XcmsCCC *ccc;
  84.     struct _XcmsCmapRec *pNext;
  85. } XcmsCmapRec;
  86.  
  87.     /*
  88.      * Intensity Record (i.e., value / intensity tuple)
  89.      */
  90. typedef struct _IntensityRec {
  91.     unsigned short value;
  92.     XcmsFloat intensity;
  93. } IntensityRec;
  94.  
  95.     /*
  96.      * Intensity Table
  97.      */
  98. typedef struct _IntensityTbl {
  99.     IntensityRec *pBase;
  100.     unsigned int nEntries;
  101. } IntensityTbl;
  102.  
  103.     /*
  104.      * Structure for storing per-Visual Intensity Tables (aka gamma maps).
  105.      */
  106. typedef struct _XcmsIntensityMap {
  107.     VisualID visualID;
  108.     XPointer    screenData;    /* pointer to corresponding Screen Color*/
  109.                 /*    Characterization Data        */
  110.     void (*pFreeScreenData)();    /* Function that frees a Screen        */
  111.                 /*   structure.                */
  112.     struct _XcmsIntensityMap *pNext;
  113. } XcmsIntensityMap;
  114.  
  115.  
  116.     /*
  117.      * Structure for storing "registered" color space prefix/ID
  118.      */
  119. typedef struct _XcmsRegColorSpaceEntry {
  120.     char *prefix;    /* Color Space prefix (e.g., "CIEXYZ:") */
  121.     XcmsColorFormat id;    /* Color Space ID (e.g., XcmsCIEXYZFormat) */
  122. } XcmsRegColorSpaceEntry;
  123.  
  124.  
  125.     /*
  126.      * Xcms Per Display (i.e. connection) related data
  127.      */
  128. typedef struct _XcmsPerDpyInfo {
  129.  
  130.     XcmsCCC paDefaultCCC; /* based on default visual of screen */
  131.         /*
  132.          * Pointer to an array of XcmsCCC structures, one for
  133.          * each screen.
  134.          */
  135.     XcmsCmapRec *pClientCmaps;    /* Pointer to linked list of XcmsCmapRec's */
  136.  
  137. } XcmsPerDpyInfo, *XcmsPerDpyInfoPtr;
  138.  
  139. /*
  140.  *    DEFINES
  141.  */
  142.  
  143. #define XDCCC_NUMBER    0x8000000L    /* 2**27 per XDCCC */
  144.  
  145. #ifdef GRAY
  146. #define XDCCC_SCREENWHITEPT_ATOM_NAME    "XDCCC_GRAY_SCREENWHITEPOINT"
  147. #define XDCCC_GRAY_CORRECT_ATOM_NAME    "XDCCC_GRAY_CORRECTION"
  148. #endif /* GRAY */
  149.  
  150. #ifndef _ConversionValues
  151. typedef struct _ConversionValues {
  152.     IntensityTbl IntensityTbl;
  153. } ConversionValues;
  154. #endif
  155.  
  156. #ifdef GRAY
  157. typedef struct {
  158.     IntensityTbl *IntensityTbl;
  159. } GRAY_SCCData;
  160. #endif /* GRAY */
  161.  
  162. /*
  163.  *    DEFINES
  164.  */
  165.  
  166. #define XDCCC_MATRIX_ATOM_NAME    "XDCCC_LINEAR_RGB_MATRICES"
  167. #define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION"
  168.  
  169. typedef struct {
  170.     XcmsFloat XYZtoRGBmatrix[3][3];
  171.     XcmsFloat RGBtoXYZmatrix[3][3];
  172.     IntensityTbl *pRedTbl;
  173.     IntensityTbl *pGreenTbl;
  174.     IntensityTbl *pBlueTbl;
  175. } LINEAR_RGB_SCCData;
  176.  
  177. /*
  178.  *    DESCRIPTION
  179.  *        Include file for defining the math macros used in the
  180.  *        XCMS source.  Instead of using math library routines
  181.  *        directly, XCMS uses macros so that based on the
  182.  *        definitions here, vendors and sites can specify exactly
  183.  *        what routine will be called (those from libm.a or their
  184.  *        custom routines).  If not defined to math library routines
  185.  *        (e.g., sqrt in libm.a), then the client is not forced to
  186.  *        be linked with -lm.
  187.  */
  188.  
  189. #define XCMS_ATAN(x)        _XcmsArcTangent(x)
  190. #define XCMS_COS(x)        _XcmsCosine(x)
  191. #define XCMS_CUBEROOT(x)    _XcmsCubeRoot(x)
  192. #define XCMS_FABS(x)        ((x) < 0.0 ? -(x) : (x))
  193. #define XCMS_SIN(x)        _XcmsSine(x)
  194. #define XCMS_SQRT(x)        _XcmsSquareRoot(x)
  195. #define XCMS_TAN(x)        (XCMS_SIN(x) / XCMS_COS(x))
  196.  
  197. #ifdef __STDC__
  198. double _XcmsArcTangent(double a);
  199. double _XcmsCosine(double a);
  200. double _XcmsCubeRoot(double a);
  201. double _XcmsSine(double a);
  202. double _XcmsSquareRoot(double a);
  203. #else
  204. double _XcmsArcTangent();
  205. double _XcmsCosine();
  206. double _XcmsCubeRoot();
  207. double _XcmsSine();
  208. double _XcmsSquareRoot();
  209. #endif
  210.  
  211. /*
  212.  *  DEFINES FOR GAMUT COMPRESSION AND QUERY ROUTINES
  213.  */
  214. #ifndef PI
  215. #  ifdef M_PI
  216. #    define PI M_PI
  217. #  else
  218. #    define PI 3.14159265358979323846264338327950
  219. #  endif /* M_PI */
  220. #endif /* PI */
  221. #ifndef degrees
  222. #  define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
  223. #endif /* degrees */
  224. #ifndef radians
  225. #  define radians(d) ((XcmsFloat)(d) * PI / 180.0)
  226. #endif /* radians */
  227.  
  228. #define XCMS_CIEUSTAROFHUE(h,c)    \
  229. ((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
  230. ((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \
  231. (XcmsFloat)1.0)))
  232. #define XCMS_CIEVSTAROFHUE(h,c)    \
  233. ((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
  234. ((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \
  235. (XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0)))
  236. /* this hue is returned in radians */
  237. #define XCMS_CIELUV_PMETRIC_HUE(u,v)    \
  238. (((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2)))
  239. #define XCMS_CIELUV_PMETRIC_CHROMA(u,v)    XCMS_SQRT(((u)*(u)) + ((v)*(v)))
  240.  
  241. #define XCMS_CIEASTAROFHUE(h,c)        XCMS_CIEUSTAROFHUE((h), (c))
  242. #define XCMS_CIEBSTAROFHUE(h,c)        XCMS_CIEVSTAROFHUE((h), (c))
  243. #define XCMS_CIELAB_PMETRIC_HUE(a,b)    XCMS_CIELUV_PMETRIC_HUE((a), (b))
  244. #define XCMS_CIELAB_PMETRIC_CHROMA(a,b)    XCMS_CIELUV_PMETRIC_CHROMA((a), (b))
  245.  
  246. #endif /* _XCMSINT_H_ */
  247.