📄 xcmslrgb.c
字号:
/* $XConsortium: XcmsLRGB.c,v 1.22 92/01/02 19:28:13 rws Exp $" *//* * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. * All Rights Reserved * * 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. * * * NAME * XcmsLRGB.c * * DESCRIPTION * This file contains the conversion routines: * 1. CIE XYZ to RGB intensity * 2. RGB intensity to device RGB * 3. device RGB to RGB intensity * 4. RGB intensity to CIE XYZ * */#include <stdio.h>#include <X11/Xos.h>#include <X11/Xatom.h>#include "Xlibint.h"#include "Xcmsint.h"#if __STDC__#define Const const#else#define Const /**/#endif/* * EXTERNS * External declarations required locally to this package * that are not already declared in any of the included header * files (external includes or internal includes). */extern char XcmsRGB_prefix[];extern char XcmsRGBi_prefix[];extern unsigned long _XcmsGetElement();extern void _XcmsFreeIntensityMaps();/* * LOCAL DEFINES * #define declarations local to this package. */#define EPS 0.001#ifndef MIN#define MIN(x,y) ((x) > (y) ? (y) : (x))#endif /* MIN */#ifndef MAX#define MAX(x,y) ((x) > (y) ? (x) : (y))#endif /* MAX */#ifndef MIN3#define MIN3(x,y,z) (MIN(x, MIN(y, z)))#endif /* MIN3 */#ifndef MAX3#define MAX3(x,y,z) (MAX(x, MAX(y, z)))#endif /* MAX3 *//* * LOCAL TYPEDEFS * typedefs local to this package (for use with local vars). * *//* * FORWARD DECLARATIONS */static void LINEAR_RGB_FreeSCCData();static int LINEAR_RGB_InitSCCData();int XcmsLRGB_RGB_ParseString();int XcmsLRGB_RGBi_ParseString();Status _XcmsGetTableType0();Status _XcmsGetTableType1();/* * LOCALS VARIABLES * Variables local to this package. * Usage example: * static int ExampleLocalVar; */static unsigned short Const MASK[17] = { 0x0000, /* 0 bitsPerRGB */ 0x8000, /* 1 bitsPerRGB */ 0xc000, /* 2 bitsPerRGB */ 0xe000, /* 3 bitsPerRGB */ 0xf000, /* 4 bitsPerRGB */ 0xf800, /* 5 bitsPerRGB */ 0xfc00, /* 6 bitsPerRGB */ 0xfe00, /* 7 bitsPerRGB */ 0xff00, /* 8 bitsPerRGB */ 0xff80, /* 9 bitsPerRGB */ 0xffc0, /* 10 bitsPerRGB */ 0xffe0, /* 11 bitsPerRGB */ 0xfff0, /* 12 bitsPerRGB */ 0xfff8, /* 13 bitsPerRGB */ 0xfffc, /* 14 bitsPerRGB */ 0xfffe, /* 15 bitsPerRGB */ 0xffff /* 16 bitsPerRGB */}; /* * A NULL terminated array of function pointers that when applied * in series will convert an XcmsColor structure from XcmsRGBFormat * to XcmsCIEXYZFormat. */static XcmsConversionProc Fl_RGB_to_CIEXYZ[] = { XcmsRGBToRGBi, XcmsRGBiToCIEXYZ, NULL}; /* * A NULL terminated array of function pointers that when applied * in series will convert an XcmsColor structure from XcmsCIEXYZFormat * to XcmsRGBFormat. */static XcmsConversionProc Fl_CIEXYZ_to_RGB[] = { XcmsCIEXYZToRGBi, XcmsRGBiToRGB, NULL}; /* * A NULL terminated array of function pointers that when applied * in series will convert an XcmsColor structure from XcmsRGBiFormat * to XcmsCIEXYZFormat. */static XcmsConversionProc Fl_RGBi_to_CIEXYZ[] = { XcmsRGBiToCIEXYZ, NULL}; /* * A NULL terminated array of function pointers that when applied * in series will convert an XcmsColor structure from XcmsCIEXYZFormat * to XcmsRGBiFormat. */static XcmsConversionProc Fl_CIEXYZ_to_RGBi[] = { XcmsCIEXYZToRGBi, NULL}; /* * RGBi Color Spaces */XcmsColorSpace XcmsRGBiColorSpace = { XcmsRGBi_prefix, /* prefix */ XcmsRGBiFormat, /* id */ XcmsLRGB_RGBi_ParseString, /* parseString */ Fl_RGBi_to_CIEXYZ, /* to_CIEXYZ */ Fl_CIEXYZ_to_RGBi, /* from_CIEXYZ */ 1 }; /* * RGB Color Spaces */XcmsColorSpace XcmsRGBColorSpace = { XcmsRGB_prefix, /* prefix */ XcmsRGBFormat, /* id */ XcmsLRGB_RGB_ParseString, /* parseString */ Fl_RGB_to_CIEXYZ, /* to_CIEXYZ */ Fl_CIEXYZ_to_RGB, /* from_CIEXYZ */ 1 }; /* * Device-Independent Color Spaces known to the * LINEAR_RGB Screen Color Characteristics Function Set. */static XcmsColorSpace *DDColorSpaces[] = { &XcmsRGBColorSpace, &XcmsRGBiColorSpace, NULL};/* * GLOBALS * Variables declared in this package that are allowed * to be used globally. */ /* * LINEAR_RGB Screen Color Characteristics Function Set. */XcmsFunctionSet XcmsLinearRGBFunctionSet = { &DDColorSpaces[0], /* pDDColorSpaces */ LINEAR_RGB_InitSCCData, /* pInitScrnFunc */ LINEAR_RGB_FreeSCCData /* pFreeSCCData */ };/* * DESCRIPTION * Contents of Default SCCData should be replaced if other * data should be used as default. * * *//* * NAME Tektronix 19" (Sony) CRT * PART_NUMBER 119-2451-00 * MODEL Tek4300, Tek4800 */static IntensityRec Const Default_RGB_RedTuples[] = { /* {unsigned short value, XcmsFloat intensity} */ 0x0000, 0.000000, 0x0909, 0.000000, 0x0a0a, 0.000936, 0x0f0f, 0.001481, 0x1414, 0.002329, 0x1919, 0.003529, 0x1e1e, 0.005127, 0x2323, 0.007169, 0x2828, 0.009699, 0x2d2d, 0.012759, 0x3232, 0.016392, 0x3737, 0.020637, 0x3c3c, 0.025533, 0x4141, 0.031119, 0x4646, 0.037431, 0x4b4b, 0.044504, 0x5050, 0.052373, 0x5555, 0.061069, 0x5a5a, 0.070624, 0x5f5f, 0.081070, 0x6464, 0.092433, 0x6969, 0.104744, 0x6e6e, 0.118026, 0x7373, 0.132307, 0x7878, 0.147610, 0x7d7d, 0.163958, 0x8282, 0.181371, 0x8787, 0.199871, 0x8c8c, 0.219475, 0x9191, 0.240202, 0x9696, 0.262069, 0x9b9b, 0.285089, 0xa0a0, 0.309278, 0xa5a5, 0.334647, 0xaaaa, 0.361208, 0xafaf, 0.388971, 0xb4b4, 0.417945, 0xb9b9, 0.448138, 0xbebe, 0.479555, 0xc3c3, 0.512202, 0xc8c8, 0.546082, 0xcdcd, 0.581199, 0xd2d2, 0.617552, 0xd7d7, 0.655144, 0xdcdc, 0.693971, 0xe1e1, 0.734031, 0xe6e6, 0.775322, 0xebeb, 0.817837, 0xf0f0, 0.861571, 0xf5f5, 0.906515, 0xfafa, 0.952662, 0xffff, 1.000000};static IntensityRec Const Default_RGB_GreenTuples[] = { /* {unsigned short value, XcmsFloat intensity} */ 0x0000, 0.000000, 0x1313, 0.000000, 0x1414, 0.000832, 0x1919, 0.001998, 0x1e1e, 0.003612, 0x2323, 0.005736, 0x2828, 0.008428, 0x2d2d, 0.011745, 0x3232, 0.015740, 0x3737, 0.020463, 0x3c3c, 0.025960, 0x4141, 0.032275, 0x4646, 0.039449, 0x4b4b, 0.047519, 0x5050, 0.056520, 0x5555, 0.066484, 0x5a5a, 0.077439, 0x5f5f, 0.089409, 0x6464, 0.102418, 0x6969, 0.116485, 0x6e6e, 0.131625, 0x7373, 0.147853, 0x7878, 0.165176, 0x7d7d, 0.183604, 0x8282, 0.203140, 0x8787, 0.223783, 0x8c8c, 0.245533, 0x9191, 0.268384, 0x9696, 0.292327, 0x9b9b, 0.317351, 0xa0a0, 0.343441, 0xa5a5, 0.370580, 0xaaaa, 0.398747, 0xafaf, 0.427919, 0xb4b4, 0.458068, 0xb9b9, 0.489165, 0xbebe, 0.521176, 0xc3c3, 0.554067, 0xc8c8, 0.587797, 0xcdcd, 0.622324, 0xd2d2, 0.657604, 0xd7d7, 0.693588, 0xdcdc, 0.730225, 0xe1e1, 0.767459, 0xe6e6, 0.805235, 0xebeb, 0.843491, 0xf0f0, 0.882164, 0xf5f5, 0.921187, 0xfafa, 0.960490, 0xffff, 1.000000};static IntensityRec Const Default_RGB_BlueTuples[] = { /* {unsigned short value, XcmsFloat intensity} */ 0x0000, 0.000000, 0x0e0e, 0.000000, 0x0f0f, 0.001341, 0x1414, 0.002080, 0x1919, 0.003188, 0x1e1e, 0.004729, 0x2323, 0.006766, 0x2828, 0.009357, 0x2d2d, 0.012559, 0x3232, 0.016424, 0x3737, 0.021004, 0x3c3c, 0.026344, 0x4141, 0.032489, 0x4646, 0.039481, 0x4b4b, 0.047357, 0x5050, 0.056154, 0x5555, 0.065903, 0x5a5a, 0.076634, 0x5f5f, 0.088373, 0x6464, 0.101145, 0x6969, 0.114968, 0x6e6e, 0.129862, 0x7373, 0.145841, 0x7878, 0.162915, 0x7d7d, 0.181095, 0x8282, 0.200386, 0x8787, 0.220791, 0x8c8c, 0.242309, 0x9191, 0.264937, 0x9696, 0.288670, 0x9b9b, 0.313499, 0xa0a0, 0.339410, 0xa5a5, 0.366390, 0xaaaa, 0.394421, 0xafaf, 0.423481, 0xb4b4, 0.453547, 0xb9b9, 0.484592, 0xbebe, 0.516587, 0xc3c3, 0.549498, 0xc8c8, 0.583291, 0xcdcd, 0.617925, 0xd2d2, 0.653361, 0xd7d7, 0.689553, 0xdcdc, 0.726454, 0xe1e1, 0.764013, 0xe6e6, 0.802178, 0xebeb, 0.840891, 0xf0f0, 0.880093, 0xf5f5, 0.919723, 0xfafa, 0.959715, 0xffff, 1.00000};static IntensityTbl Default_RGB_RedTbl = { /* IntensityRec *pBase */ (IntensityRec *) Default_RGB_RedTuples, /* unsigned int nEntries */ 52};static IntensityTbl Default_RGB_GreenTbl = { /* IntensityRec *pBase */ (IntensityRec *)Default_RGB_GreenTuples, /* unsigned int nEntries */ 50};static IntensityTbl Default_RGB_BlueTbl = { /* IntensityRec *pBase */ (IntensityRec *)Default_RGB_BlueTuples, /* unsigned int nEntries */ 51};static LINEAR_RGB_SCCData Default_RGB_SCCData = { /* XcmsFloat XYZtoRGBmatrix[3][3] */ 3.48340481253539000, -1.52176374927285200, -0.55923133354049780, -1.07152751306193600, 1.96593795204372400, 0.03673691339553462, 0.06351179790497788, -0.20020501000496480, 0.81070942031648220, /* XcmsFloat RGBtoXYZmatrix[3][3] */ 0.38106149108714790, 0.32025712365352110, 0.24834578525933100, 0.20729745115140850, 0.68054638776373240, 0.11215616108485920, 0.02133944350088028, 0.14297193020246480, 1.24172892629665500, /* IntensityTbl *pRedTbl */ &Default_RGB_RedTbl, /* IntensityTbl *pGreenTbl */ &Default_RGB_GreenTbl, /* IntensityTbl *pBlueTbl */ &Default_RGB_BlueTbl};/************************************************************************ * * * PRIVATE ROUTINES * * * ************************************************************************//* * NAME * LINEAR_RGB_InitSCCData() * * SYNOPSIS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -