diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:53 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:53 +0000 |
commit | 71194c9839debbb6c1baaa4d5d8105af39907803 (patch) | |
tree | f75595183f24c6e7e9aa9e28898a45b42751fb3b |
R6.6 is the Xorg base-lineXORG-MAINXORG-STABLE
-rw-r--r-- | SCCDFile.h | 142 | ||||
-rw-r--r-- | datafiles/sample1.dcc | 843 | ||||
-rw-r--r-- | datafiles/sample2.dcc | 843 | ||||
-rw-r--r-- | loadData.c | 1787 | ||||
-rw-r--r-- | xcmsdb.c | 888 | ||||
-rw-r--r-- | xcmsdb.man | 93 |
6 files changed, 4596 insertions, 0 deletions
diff --git a/SCCDFile.h b/SCCDFile.h new file mode 100644 index 0000000..a8aa87f --- /dev/null +++ b/SCCDFile.h @@ -0,0 +1,142 @@ +/* $Xorg: SCCDFile.h,v 1.3 2000/08/17 19:54:13 cpqbld Exp $ */ +/* + * (c) Copyright 1990 Tektronix Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Tektronix not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + * Tektronix disclaims all warranties with regard to this software, including + * all implied warranties of merchantability and fitness, 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 performance of this + * software. + * + * + * NAME + * SCCDFile.h + * + * DESCRIPTION + * Include file for TekCMS Color Extension when using the + * X Device Color Characterization Convention (XDCCC). + * + */ +#ifndef SCCDFILE_H +#define SCCDFILE_H + +#include <X11/Xutil.h> +#include <X11/Xcms.h> + +/* + * DEFINES + */ + +#define XDCCC_NUMBER 0x8000000L /* 2**27 per ICCCM */ +#define XDCCC_MATRIX_ATOM_NAME "XDCCC_LINEAR_RGB_MATRICES" +#define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION" +#define READABLE_SD_SUFFIX ".txt" +#define TXT_FORMAT_VERSION "1.1" + +#define DATA_DELIMS " \t\n" /* space, tab, newline */ + +#define SC_BEGIN_KEYWORD "SCREENDATA_BEGIN" +#define SC_END_KEYWORD "SCREENDATA_END" +#define COMMENT_KEYWORD "COMMENT" +#define NAME_KEYWORD "NAME" +#define MODEL_KEYWORD "MODEL" +#define PART_NUMBER_KEYWORD "PART_NUMBER" +#define SERIAL_NUMBER_KEYWORD "SERIAL_NUMBER" +#define REVISION_KEYWORD "REVISION" +#define SCREEN_CLASS_KEYWORD "SCREEN_CLASS" +#define COLORIMETRIC_BEGIN_KEYWORD "COLORIMETRIC_BEGIN" +#define COLORIMETRIC_END_KEYWORD "COLORIMETRIC_END" +#define XYZTORGBMAT_BEGIN_KEYWORD "XYZtoRGB_MATRIX_BEGIN" +#define XYZTORGBMAT_END_KEYWORD "XYZtoRGB_MATRIX_END" +#define RGBTOXYZMAT_BEGIN_KEYWORD "RGBtoXYZ_MATRIX_BEGIN" +#define RGBTOXYZMAT_END_KEYWORD "RGBtoXYZ_MATRIX_END" +#define IPROFILE_BEGIN_KEYWORD "INTENSITY_PROFILE_BEGIN" +#define IPROFILE_END_KEYWORD "INTENSITY_PROFILE_END" +#define ITBL_BEGIN_KEYWORD "INTENSITY_TBL_BEGIN" +#define ITBL_END_KEYWORD "INTENSITY_TBL_END" + +#define WHITEPT_XYZ_BEGIN_KEYWORD "WHITEPT_XYZ_BEGIN" +#define WHITEPT_XYZ_END_KEYWORD "WHITEPT_XYZ_END" + +#define VIDEO_RGB_KEYWORD "VIDEO_RGB" +#ifdef GRAY +#define VIDEO_GRAY_KEYWORD "VIDEO_GRAY" +#endif + +#define DATA -1 +#define SC_BEGIN 1 +#define SC_END 2 +#define COMMENT 3 +#define NAME 4 +#define MODEL 5 +#define PART_NUMBER 6 +#define SERIAL_NUMBER 7 +#define REVISION 8 +#define SCREEN_CLASS 9 +#define COLORIMETRIC_BEGIN 10 +#define COLORIMETRIC_END 11 +#define XYZTORGBMAT_BEGIN 12 +#define XYZTORGBMAT_END 13 +#define RGBTOXYZMAT_BEGIN 14 +#define RGBTOXYZMAT_END 15 +#define IPROFILE_BEGIN 16 +#define IPROFILE_END 17 +#define ITBL_BEGIN 18 +#define ITBL_END 19 +#define WHITEPT_XYZ_BEGIN 20 +#define WHITEPT_XYZ_END 21 + +#define CORR_TYPE_NONE -1 +#define CORR_TYPE_0 0 +#define CORR_TYPE_1 1 + +#define VIDEO_RGB 0 +#ifdef GRAY +#define VIDEO_GRAY 1 +#endif + + /* + * Intensity Record (i.e., value / intensity tuple) + */ +typedef struct _IntensityRec { + unsigned short value; + XcmsFloat intensity; +} IntensityRec; + + /* + * Intensity Table + */ +typedef struct _IntensityTbl { + IntensityRec *pBase; + unsigned int nEntries; +} IntensityTbl; + +typedef struct _XDCCC_Matrix { + XcmsFloat XYZtoRGBmatrix[3][3]; + XcmsFloat RGBtoXYZmatrix[3][3]; +} XDCCC_Matrix; + +typedef struct _XDCCC_Correction { + XVisualInfo visual_info; + long visual_info_mask; + int tableType; + int nTables; + IntensityTbl* pRedTbl; + IntensityTbl* pGreenTbl; + IntensityTbl* pBlueTbl; + struct _XDCCC_Correction* next; +} XDCCC_Correction; + + +#endif /* SCCDFILE_H */ diff --git a/datafiles/sample1.dcc b/datafiles/sample1.dcc new file mode 100644 index 0000000..d22b72b --- /dev/null +++ b/datafiles/sample1.dcc @@ -0,0 +1,843 @@ +/* + * (c) Copyright 1990 1991 Tektronix Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Tektronix not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + * Tektronix disclaims all warranties with regard to this software, including + * all implied warranties of merchantability and fitness, 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 performance of this + * software. + * + * + * NAME + * sample1.dcc + * + * DESCRIPTION + * Sample Screen Color Characterization Data File + * + * IMPORTANT NOTICE + * This sample file is provided solely for the purpose of + * presenting the format of input files accepted by the + * 'cmsdb' utility -- a sample mechanism for placing Screen + * Color Characterization Data into root window properties + * in accordance with the X Device Color Characterization + * Convention (XDCCC). The data in this file is tailored + * specifically for the Tektronix monitor (part number + * 119-2451-00). These monitors have been built by the + * monitor vendor to Tektronix specifications that typically + * differ from monitors provided by the same vendor to other + * companies. Therefore, for accurate color rendition this + * sample file should only be used in conjunction with the + * specified Tektronix monitor. To be XCMS compatible, + * X workstation and X terminal vendors must provide screen + * characterization data for their own monitors. + */ +SCREENDATA_BEGIN 0.3 + + NAME Tektronix 19" (Sony) CRT + PART_NUMBER 119-2451-00 + MODEL Tek4300, XD88 + SCREEN_CLASS VIDEO_RGB + REVISION 1.0 + + COLORIMETRIC_BEGIN + XYZtoRGB_MATRIX_BEGIN + 3.48340481253539000 -1.52176374927285200 -0.55923133354049780 + -1.07152751306193600 1.96593795204372400 0.03673691339553462 + 0.06351179790497788 -0.20020501000496480 0.81070942031648220 + XYZtoRGB_MATRIX_END + RGBtoXYZ_MATRIX_BEGIN + 0.38106149108714790 0.32025712365352110 0.24834578525933100 + 0.20729745115140850 0.68054638776373240 0.11215616108485920 + 0.02133944350088028 0.14297193020246480 1.24172892629665500 + RGBtoXYZ_MATRIX_END + COLORIMETRIC_END + + INTENSITY_PROFILE_BEGIN 0 3 + INTENSITY_TBL_BEGIN RED 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000936 + 0x0b0b 0.001023 + 0x0c0c 0.001121 + 0x0d0d 0.001229 + 0x0e0e 0.001349 + 0x0f0f 0.001481 + 0x1010 0.001624 + 0x1111 0.001781 + 0x1212 0.001950 + 0x1313 0.002133 + 0x1414 0.002329 + 0x1515 0.002539 + 0x1616 0.002764 + 0x1717 0.003003 + 0x1818 0.003258 + 0x1919 0.003529 + 0x1a1a 0.003815 + 0x1b1b 0.004118 + 0x1c1c 0.004437 + 0x1d1d 0.004773 + 0x1e1e 0.005127 + 0x1f1f 0.005498 + 0x2020 0.005888 + 0x2121 0.006296 + 0x2222 0.006723 + 0x2323 0.007169 + 0x2424 0.007634 + 0x2525 0.008120 + 0x2626 0.008625 + 0x2727 0.009152 + 0x2828 0.009699 + 0x2929 0.010267 + 0x2a2a 0.010857 + 0x2b2b 0.011468 + 0x2c2c 0.012102 + 0x2d2d 0.012759 + 0x2e2e 0.013438 + 0x2f2f 0.014141 + 0x3030 0.014867 + 0x3131 0.015617 + 0x3232 0.016392 + 0x3333 0.017190 + 0x3434 0.018014 + 0x3535 0.018863 + 0x3636 0.019737 + 0x3737 0.020637 + 0x3838 0.021563 + 0x3939 0.022515 + 0x3a3a 0.023494 + 0x3b3b 0.024500 + 0x3c3c 0.025533 + 0x3d3d 0.026594 + 0x3e3e 0.027683 + 0x3f3f 0.028800 + 0x4040 0.029945 + 0x4141 0.031119 + 0x4242 0.032323 + 0x4343 0.033555 + 0x4444 0.034817 + 0x4545 0.036109 + 0x4646 0.037431 + 0x4747 0.038784 + 0x4848 0.040167 + 0x4949 0.041582 + 0x4a4a 0.043027 + 0x4b4b 0.044504 + 0x4c4c 0.046013 + 0x4d4d 0.047554 + 0x4e4e 0.049128 + 0x4f4f 0.050734 + 0x5050 0.052373 + 0x5151 0.054045 + 0x5252 0.055750 + 0x5353 0.057489 + 0x5454 0.059262 + 0x5555 0.061069 + 0x5656 0.062910 + 0x5757 0.064786 + 0x5858 0.066697 + 0x5959 0.068643 + 0x5a5a 0.070624 + 0x5b5b 0.072641 + 0x5c5c 0.074694 + 0x5d5d 0.076783 + 0x5e5e 0.078908 + 0x5f5f 0.081070 + 0x6060 0.083268 + 0x6161 0.085503 + 0x6262 0.087776 + 0x6363 0.090086 + 0x6464 0.092433 + 0x6565 0.094819 + 0x6666 0.097242 + 0x6767 0.099704 + 0x6868 0.102205 + 0x6969 0.104744 + 0x6a6a 0.107322 + 0x6b6b 0.109939 + 0x6c6c 0.112595 + 0x6d6d 0.115291 + 0x6e6e 0.118026 + 0x6f6f 0.120802 + 0x7070 0.123618 + 0x7171 0.126474 + 0x7272 0.129370 + 0x7373 0.132307 + 0x7474 0.135285 + 0x7575 0.138305 + 0x7676 0.141365 + 0x7777 0.144467 + 0x7878 0.147610 + 0x7979 0.150795 + 0x7a7a 0.154023 + 0x7b7b 0.157292 + 0x7c7c 0.160604 + 0x7d7d 0.163958 + 0x7e7e 0.167354 + 0x7f7f 0.170794 + 0x8080 0.174276 + 0x8181 0.177802 + 0x8282 0.181371 + 0x8383 0.184983 + 0x8484 0.188639 + 0x8585 0.192339 + 0x8686 0.196083 + 0x8787 0.199871 + 0x8888 0.203702 + 0x8989 0.207579 + 0x8a8a 0.211500 + 0x8b8b 0.215465 + 0x8c8c 0.219475 + 0x8d8d 0.223530 + 0x8e8e 0.227630 + 0x8f8f 0.231776 + 0x9090 0.235966 + 0x9191 0.240202 + 0x9292 0.244484 + 0x9393 0.248811 + 0x9494 0.253184 + 0x9595 0.257604 + 0x9696 0.262069 + 0x9797 0.266580 + 0x9898 0.271138 + 0x9999 0.275742 + 0x9a9a 0.280392 + 0x9b9b 0.285089 + 0x9c9c 0.289833 + 0x9d9d 0.294624 + 0x9e9e 0.299461 + 0x9f9f 0.304346 + 0xa0a0 0.309278 + 0xa1a1 0.314257 + 0xa2a2 0.319283 + 0xa3a3 0.324357 + 0xa4a4 0.329478 + 0xa5a5 0.334647 + 0xa6a6 0.339863 + 0xa7a7 0.345128 + 0xa8a8 0.350440 + 0xa9a9 0.355800 + 0xaaaa 0.361208 + 0xabab 0.366664 + 0xacac 0.372168 + 0xadad 0.377721 + 0xaeae 0.383322 + 0xafaf 0.388971 + 0xb0b0 0.394669 + 0xb1b1 0.400415 + 0xb2b2 0.406210 + 0xb3b3 0.412053 + 0xb4b4 0.417945 + 0xb5b5 0.423886 + 0xb6b6 0.429876 + 0xb7b7 0.435914 + 0xb8b8 0.442001 + 0xb9b9 0.448138 + 0xbaba 0.454323 + 0xbbbb 0.460557 + 0xbcbc 0.466841 + 0xbdbd 0.473173 + 0xbebe 0.479555 + 0xbfbf 0.485986 + 0xc0c0 0.492466 + 0xc1c1 0.498995 + 0xc2c2 0.505574 + 0xc3c3 0.512202 + 0xc4c4 0.518879 + 0xc5c5 0.525606 + 0xc6c6 0.532382 + 0xc7c7 0.539207 + 0xc8c8 0.546082 + 0xc9c9 0.553006 + 0xcaca 0.559980 + 0xcbcb 0.567004 + 0xcccc 0.574076 + 0xcdcd 0.581199 + 0xcece 0.588370 + 0xcfcf 0.595592 + 0xd0d0 0.602862 + 0xd1d1 0.610183 + 0xd2d2 0.617552 + 0xd3d3 0.624972 + 0xd4d4 0.632440 + 0xd5d5 0.639959 + 0xd6d6 0.647526 + 0xd7d7 0.655144 + 0xd8d8 0.662810 + 0xd9d9 0.670526 + 0xdada 0.678292 + 0xdbdb 0.686106 + 0xdcdc 0.693971 + 0xdddd 0.701884 + 0xdede 0.709847 + 0xdfdf 0.717859 + 0xe0e0 0.725921 + 0xe1e1 0.734031 + 0xe2e2 0.742191 + 0xe3e3 0.750400 + 0xe4e4 0.758658 + 0xe5e5 0.766966 + 0xe6e6 0.775322 + 0xe7e7 0.783727 + 0xe8e8 0.792181 + 0xe9e9 0.800684 + 0xeaea 0.809236 + 0xebeb 0.817837 + 0xecec 0.826486 + 0xeded 0.835185 + 0xeeee 0.843931 + 0xefef 0.852727 + 0xf0f0 0.861571 + 0xf1f1 0.870463 + 0xf2f2 0.879404 + 0xf3f3 0.888393 + 0xf4f4 0.897430 + 0xf5f5 0.906515 + 0xf6f6 0.915648 + 0xf7f7 0.924830 + 0xf8f8 0.934059 + 0xf9f9 0.943337 + 0xfafa 0.952662 + 0xfbfb 0.962034 + 0xfcfc 0.971454 + 0xfdfd 0.980922 + 0xfefe 0.990437 + 0xffff 1.000000 + INTENSITY_TBL_END + INTENSITY_TBL_BEGIN GREEN 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000000 + 0x0b0b 0.000000 + 0x0c0c 0.000000 + 0x0d0d 0.000000 + 0x0e0e 0.000000 + 0x0f0f 0.000000 + 0x1010 0.000000 + 0x1111 0.000000 + 0x1212 0.000000 + 0x1313 0.000000 + 0x1414 0.000832 + 0x1515 0.001033 + 0x1616 0.001249 + 0x1717 0.001482 + 0x1818 0.001731 + 0x1919 0.001998 + 0x1a1a 0.002283 + 0x1b1b 0.002587 + 0x1c1c 0.002909 + 0x1d1d 0.003251 + 0x1e1e 0.003612 + 0x1f1f 0.003994 + 0x2020 0.004397 + 0x2121 0.004821 + 0x2222 0.005267 + 0x2323 0.005736 + 0x2424 0.006227 + 0x2525 0.006741 + 0x2626 0.007279 + 0x2727 0.007842 + 0x2828 0.008428 + 0x2929 0.009040 + 0x2a2a 0.009677 + 0x2b2b 0.010340 + 0x2c2c 0.011029 + 0x2d2d 0.011745 + 0x2e2e 0.012489 + 0x2f2f 0.013259 + 0x3030 0.014058 + 0x3131 0.014885 + 0x3232 0.015740 + 0x3333 0.016625 + 0x3434 0.017539 + 0x3535 0.018484 + 0x3636 0.019458 + 0x3737 0.020463 + 0x3838 0.021499 + 0x3939 0.022566 + 0x3a3a 0.023665 + 0x3b3b 0.024796 + 0x3c3c 0.025960 + 0x3d3d 0.027156 + 0x3e3e 0.028385 + 0x3f3f 0.029648 + 0x4040 0.030945 + 0x4141 0.032275 + 0x4242 0.033640 + 0x4343 0.035039 + 0x4444 0.036474 + 0x4545 0.037944 + 0x4646 0.039449 + 0x4747 0.040990 + 0x4848 0.042567 + 0x4949 0.044181 + 0x4a4a 0.045832 + 0x4b4b 0.047519 + 0x4c4c 0.049244 + 0x4d4d 0.051006 + 0x4e4e 0.052806 + 0x4f4f 0.054644 + 0x5050 0.056520 + 0x5151 0.058435 + 0x5252 0.060389 + 0x5353 0.062381 + 0x5454 0.064413 + 0x5555 0.066484 + 0x5656 0.068595 + 0x5757 0.070746 + 0x5858 0.072936 + 0x5959 0.075167 + 0x5a5a 0.077439 + 0x5b5b 0.079751 + 0x5c5c 0.082104 + 0x5d5d 0.084498 + 0x5e5e 0.086933 + 0x5f5f 0.089409 + 0x6060 0.091927 + 0x6161 0.094487 + 0x6262 0.097089 + 0x6363 0.099732 + 0x6464 0.102418 + 0x6565 0.105146 + 0x6666 0.107917 + 0x6767 0.110730 + 0x6868 0.113586 + 0x6969 0.116485 + 0x6a6a 0.119427 + 0x6b6b 0.122411 + 0x6c6c 0.125439 + 0x6d6d 0.128511 + 0x6e6e 0.131625 + 0x6f6f 0.134783 + 0x7070 0.137985 + 0x7171 0.141231 + 0x7272 0.144520 + 0x7373 0.147853 + 0x7474 0.151229 + 0x7575 0.154650 + 0x7676 0.158115 + 0x7777 0.161624 + 0x7878 0.165176 + 0x7979 0.168774 + 0x7a7a 0.172415 + 0x7b7b 0.176100 + 0x7c7c 0.179830 + 0x7d7d 0.183604 + 0x7e7e 0.187423 + 0x7f7f 0.191285 + 0x8080 0.195192 + 0x8181 0.199144 + 0x8282 0.203140 + 0x8383 0.207180 + 0x8484 0.211264 + 0x8585 0.215393 + 0x8686 0.219566 + 0x8787 0.223783 + 0x8888 0.228045 + 0x8989 0.232351 + 0x8a8a 0.236701 + 0x8b8b 0.241095 + 0x8c8c 0.245533 + 0x8d8d 0.250015 + 0x8e8e 0.254542 + 0x8f8f 0.259112 + 0x9090 0.263726 + 0x9191 0.268384 + 0x9292 0.273085 + 0x9393 0.277830 + 0x9494 0.282619 + 0x9595 0.287451 + 0x9696 0.292327 + 0x9797 0.297246 + 0x9898 0.302207 + 0x9999 0.307212 + 0x9a9a 0.312260 + 0x9b9b 0.317351 + 0x9c9c 0.322484 + 0x9d9d 0.327660 + 0x9e9e 0.332878 + 0x9f9f 0.338138 + 0xa0a0 0.343441 + 0xa1a1 0.348786 + 0xa2a2 0.354172 + 0xa3a3 0.359600 + 0xa4a4 0.365069 + 0xa5a5 0.370580 + 0xa6a6 0.376132 + 0xa7a7 0.381725 + 0xa8a8 0.387359 + 0xa9a9 0.393033 + 0xaaaa 0.398747 + 0xabab 0.404502 + 0xacac 0.410297 + 0xadad 0.416131 + 0xaeae 0.422006 + 0xafaf 0.427919 + 0xb0b0 0.433871 + 0xb1b1 0.439863 + 0xb2b2 0.445893 + 0xb3b3 0.451961 + 0xb4b4 0.458068 + 0xb5b5 0.464213 + 0xb6b6 0.470395 + 0xb7b7 0.476614 + 0xb8b8 0.482871 + 0xb9b9 0.489165 + 0xbaba 0.495495 + 0xbbbb 0.501862 + 0xbcbc 0.508264 + 0xbdbd 0.514703 + 0xbebe 0.521176 + 0xbfbf 0.527685 + 0xc0c0 0.534229 + 0xc1c1 0.540808 + 0xc2c2 0.547420 + 0xc3c3 0.554067 + 0xc4c4 0.560747 + 0xc5c5 0.567460 + 0xc6c6 0.574207 + 0xc7c7 0.580986 + 0xc8c8 0.587797 + 0xc9c9 0.594640 + 0xcaca 0.601515 + 0xcbcb 0.608420 + 0xcccc 0.615357 + 0xcdcd 0.622324 + 0xcece 0.629322 + 0xcfcf 0.636349 + 0xd0d0 0.643405 + 0xd1d1 0.650490 + 0xd2d2 0.657604 + 0xd3d3 0.664746 + 0xd4d4 0.671916 + 0xd5d5 0.679113 + 0xd6d6 0.686337 + 0xd7d7 0.693588 + 0xd8d8 0.700865 + 0xd9d9 0.708167 + 0xdada 0.715495 + 0xdbdb 0.722848 + 0xdcdc 0.730225 + 0xdddd 0.737626 + 0xdede 0.745050 + 0xdfdf 0.752497 + 0xe0e0 0.759967 + 0xe1e1 0.767459 + 0xe2e2 0.774973 + 0xe3e3 0.782508 + 0xe4e4 0.790064 + 0xe5e5 0.797640 + 0xe6e6 0.805235 + 0xe7e7 0.812850 + 0xe8e8 0.820483 + 0xe9e9 0.828135 + 0xeaea 0.835805 + 0xebeb 0.843491 + 0xecec 0.851195 + 0xeded 0.858914 + 0xeeee 0.866649 + 0xefef 0.874399 + 0xf0f0 0.882164 + 0xf1f1 0.889943 + 0xf2f2 0.897735 + 0xf3f3 0.905540 + 0xf4f4 0.913357 + 0xf5f5 0.921187 + 0xf6f6 0.929027 + 0xf7f7 0.936878 + 0xf8f8 0.944739 + 0xf9f9 0.952610 + 0xfafa 0.960490 + 0xfbfb 0.968377 + 0xfcfc 0.976273 + 0xfdfd 0.984176 + 0xfefe 0.992085 + 0xffff 1.000000 + INTENSITY_TBL_END + INTENSITY_TBL_BEGIN BLUE 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000000 + 0x0b0b 0.000000 + 0x0c0c 0.000000 + 0x0d0d 0.000000 + 0x0e0e 0.000000 + 0x0f0f 0.001341 + 0x1010 0.001462 + 0x1111 0.001596 + 0x1212 0.001744 + 0x1313 0.001905 + 0x1414 0.002080 + 0x1515 0.002270 + 0x1616 0.002475 + 0x1717 0.002696 + 0x1818 0.002934 + 0x1919 0.003188 + 0x1a1a 0.003459 + 0x1b1b 0.003749 + 0x1c1c 0.004057 + 0x1d1d 0.004383 + 0x1e1e 0.004729 + 0x1f1f 0.005095 + 0x2020 0.005481 + 0x2121 0.005888 + 0x2222 0.006316 + 0x2323 0.006766 + 0x2424 0.007238 + 0x2525 0.007733 + 0x2626 0.008250 + 0x2727 0.008792 + 0x2828 0.009357 + 0x2929 0.009947 + 0x2a2a 0.010562 + 0x2b2b 0.011202 + 0x2c2c 0.011867 + 0x2d2d 0.012559 + 0x2e2e 0.013277 + 0x2f2f 0.014023 + 0x3030 0.014795 + 0x3131 0.015596 + 0x3232 0.016424 + 0x3333 0.017282 + 0x3434 0.018168 + 0x3535 0.019083 + 0x3636 0.020028 + 0x3737 0.021004 + 0x3838 0.022009 + 0x3939 0.023046 + 0x3a3a 0.024113 + 0x3b3b 0.025213 + 0x3c3c 0.026344 + 0x3d3d 0.027507 + 0x3e3e 0.028703 + 0x3f3f 0.029932 + 0x4040 0.031194 + 0x4141 0.032489 + 0x4242 0.033818 + 0x4343 0.035182 + 0x4444 0.036580 + 0x4545 0.038013 + 0x4646 0.039481 + 0x4747 0.040984 + 0x4848 0.042523 + 0x4949 0.044098 + 0x4a4a 0.045710 + 0x4b4b 0.047357 + 0x4c4c 0.049042 + 0x4d4d 0.050764 + 0x4e4e 0.052523 + 0x4f4f 0.054319 + 0x5050 0.056154 + 0x5151 0.058027 + 0x5252 0.059938 + 0x5353 0.061887 + 0x5454 0.063876 + 0x5555 0.065903 + 0x5656 0.067970 + 0x5757 0.070076 + 0x5858 0.072222 + 0x5959 0.074408 + 0x5a5a 0.076634 + 0x5b5b 0.078900 + 0x5c5c 0.081207 + 0x5d5d 0.083555 + 0x5e5e 0.085944 + 0x5f5f 0.088373 + 0x6060 0.090844 + 0x6161 0.093357 + 0x6262 0.095911 + 0x6363 0.098507 + 0x6464 0.101145 + 0x6565 0.103825 + 0x6666 0.106547 + 0x6767 0.109311 + 0x6868 0.112118 + 0x6969 0.114968 + 0x6a6a 0.117861 + 0x6b6b 0.120797 + 0x6c6c 0.123775 + 0x6d6d 0.126797 + 0x6e6e 0.129862 + 0x6f6f 0.132971 + 0x7070 0.136123 + 0x7171 0.139318 + 0x7272 0.142557 + 0x7373 0.145841 + 0x7474 0.149167 + 0x7575 0.152538 + 0x7676 0.155953 + 0x7777 0.159412 + 0x7878 0.162915 + 0x7979 0.166463 + 0x7a7a 0.170054 + 0x7b7b 0.173690 + 0x7c7c 0.177371 + 0x7d7d 0.181095 + 0x7e7e 0.184865 + 0x7f7f 0.188678 + 0x8080 0.192536 + 0x8181 0.196439 + 0x8282 0.200386 + 0x8383 0.204378 + 0x8484 0.208414 + 0x8585 0.212495 + 0x8686 0.216621 + 0x8787 0.220791 + 0x8888 0.225005 + 0x8989 0.229265 + 0x8a8a 0.233568 + 0x8b8b 0.237916 + 0x8c8c 0.242309 + 0x8d8d 0.246746 + 0x8e8e 0.251227 + 0x8f8f 0.255753 + 0x9090 0.260323 + 0x9191 0.264937 + 0x9292 0.269596 + 0x9393 0.274298 + 0x9494 0.279045 + 0x9595 0.283836 + 0x9696 0.288670 + 0x9797 0.293549 + 0x9898 0.298471 + 0x9999 0.303436 + 0x9a9a 0.308446 + 0x9b9b 0.313499 + 0x9c9c 0.318595 + 0x9d9d 0.323734 + 0x9e9e 0.328916 + 0x9f9f 0.334142 + 0xa0a0 0.339410 + 0xa1a1 0.344721 + 0xa2a2 0.350075 + 0xa3a3 0.355471 + 0xa4a4 0.360909 + 0xa5a5 0.366390 + 0xa6a6 0.371913 + 0xa7a7 0.377477 + 0xa8a8 0.383084 + 0xa9a9 0.388732 + 0xaaaa 0.394421 + 0xabab 0.400151 + 0xacac 0.405923 + 0xadad 0.411735 + 0xaeae 0.417588 + 0xafaf 0.423481 + 0xb0b0 0.429415 + 0xb1b1 0.435388 + 0xb2b2 0.441402 + 0xb3b3 0.447455 + 0xb4b4 0.453547 + 0xb5b5 0.459679 + 0xb6b6 0.465849 + 0xb7b7 0.472059 + 0xb8b8 0.478306 + 0xb9b9 0.484592 + 0xbaba 0.490916 + 0xbbbb 0.497278 + 0xbcbc 0.503677 + 0xbdbd 0.510114 + 0xbebe 0.516587 + 0xbfbf 0.523097 + 0xc0c0 0.529643 + 0xc1c1 0.536226 + 0xc2c2 0.542844 + 0xc3c3 0.549498 + 0xc4c4 0.556187 + 0xc5c5 0.562912 + 0xc6c6 0.569670 + 0xc7c7 0.576463 + 0xc8c8 0.583291 + 0xc9c9 0.590151 + 0xcaca 0.597046 + 0xcbcb 0.603973 + 0xcccc 0.610933 + 0xcdcd 0.617925 + 0xcece 0.624950 + 0xcfcf 0.632006 + 0xd0d0 0.639093 + 0xd1d1 0.646212 + 0xd2d2 0.653361 + 0xd3d3 0.660540 + 0xd4d4 0.667750 + 0xd5d5 0.674988 + 0xd6d6 0.682256 + 0xd7d7 0.689553 + 0xd8d8 0.696878 + 0xd9d9 0.704231 + 0xdada 0.711612 + 0xdbdb 0.719019 + 0xdcdc 0.726454 + 0xdddd 0.733915 + 0xdede 0.741402 + 0xdfdf 0.748914 + 0xe0e0 0.756451 + 0xe1e1 0.764013 + 0xe2e2 0.771600 + 0xe3e3 0.779210 + 0xe4e4 0.786843 + 0xe5e5 0.794499 + 0xe6e6 0.802178 + 0xe7e7 0.809878 + 0xe8e8 0.817600 + 0xe9e9 0.825343 + 0xeaea 0.833107 + 0xebeb 0.840891 + 0xecec 0.848694 + 0xeded 0.856517 + 0xeeee 0.864358 + 0xefef 0.872217 + 0xf0f0 0.880093 + 0xf1f1 0.887987 + 0xf2f2 0.895898 + 0xf3f3 0.903824 + 0xf4f4 0.911766 + 0xf5f5 0.919723 + 0xf6f6 0.927695 + 0xf7f7 0.935680 + 0xf8f8 0.943679 + 0xf9f9 0.951691 + 0xfafa 0.959715 + 0xfbfb 0.967750 + 0xfcfc 0.975797 + 0xfdfd 0.983855 + 0xfefe 0.991923 + 0xffff 1.00000 + INTENSITY_TBL_END + INTENSITY_PROFILE_END + +SCREENDATA_END diff --git a/datafiles/sample2.dcc b/datafiles/sample2.dcc new file mode 100644 index 0000000..4dc9c7e --- /dev/null +++ b/datafiles/sample2.dcc @@ -0,0 +1,843 @@ +/* + * (c) Copyright 1990 1991 Tektronix Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Tektronix not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + * Tektronix disclaims all warranties with regard to this software, including + * all implied warranties of merchantability and fitness, 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 performance of this + * software. + * + * + * NAME + * sample2.dcc + * + * DESCRIPTION + * Sample Screen Color Characterization Data File + * + * IMPORTANT NOTICE + * This sample file is provided solely for the purpose of + * presenting the format of input files accepted by the + * 'cmsdb' utility -- a sample mechanism for placing Screen + * Color Characterization Data into root window properties + * in accordance with the X Device Color Characterization + * Convention (XDCCC). The data in this file is tailored + * specifically for the Tektronix monitor (part number + * 119-3916-00). These monitors have been built by the + * monitor vendor to Tektronix specifications that typically + * differ from monitors provided by the same vendor to other + * companies. Therefore, for accurate color rendition this + * sample file should only be used in conjunction with the + * specified Tektronix monitor. To be XCMS compatible, + * X workstation and X terminal vendors must provide screen + * characterization data for their own monitors. + */ +SCREENDATA_BEGIN 0.3 + + NAME Tektronix 19" (Panasonic) CRT + PART_NUMBER 119-3916-00 + MODEL XP27 + SCREEN_CLASS VIDEO_RGB + REVISION 2.0 + + COLORIMETRIC_BEGIN + XYZtoRGB_MATRIX_BEGIN + 4.075911 -1.820444 -0.627311 + -1.102477 1.935176 0.037364 + 0.059967 -0.206788 0.885717 + XYZtoRGB_MATRIX_END + RGBtoXYZ_MATRIX_BEGIN + 0.333300 0.337244 0.221834 + 0.189464 0.706136 0.104400 + 0.021668 0.142028 1.138384 + RGBtoXYZ_MATRIX_END + COLORIMETRIC_END + + INTENSITY_PROFILE_BEGIN 0 3 + INTENSITY_TBL_BEGIN RED 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000000 + 0x0b0b 0.000000 + 0x0c0c 0.000000 + 0x0d0d 0.000000 + 0x0e0e 0.000000 + 0x0f0f 0.000000 + 0x1010 0.000000 + 0x1111 0.000000 + 0x1212 0.000000 + 0x1313 0.000000 + 0x1414 0.000000 + 0x1515 0.000000 + 0x1616 0.000000 + 0x1717 0.000000 + 0x1818 0.000000 + 0x1919 0.000000 + 0x1a1a 0.000000 + 0x1b1b 0.000000 + 0x1c1c 0.000000 + 0x1d1d 0.000000 + 0x1e1e 0.000000 + 0x1f1f 0.000152 + 0x2020 0.000303 + 0x2121 0.000455 + 0x2222 0.000607 + 0x2323 0.000759 + 0x2424 0.000910 + 0x2525 0.001062 + 0x2626 0.001213 + 0x2727 0.001365 + 0x2828 0.001516 + 0x2929 0.001683 + 0x2a2a 0.001850 + 0x2b2b 0.002017 + 0x2c2c 0.002184 + 0x2d2d 0.002350 + 0x2e2e 0.002581 + 0x2f2f 0.002813 + 0x3030 0.003044 + 0x3131 0.003275 + 0x3232 0.003506 + 0x3333 0.003902 + 0x3434 0.004298 + 0x3535 0.004694 + 0x3636 0.005090 + 0x3737 0.005487 + 0x3838 0.006029 + 0x3939 0.006571 + 0x3a3a 0.007114 + 0x3b3b 0.007656 + 0x3c3c 0.008198 + 0x3d3d 0.008998 + 0x3e3e 0.009799 + 0x3f3f 0.010599 + 0x4040 0.011399 + 0x4141 0.012200 + 0x4242 0.012987 + 0x4343 0.013775 + 0x4444 0.014563 + 0x4545 0.015350 + 0x4646 0.016138 + 0x4747 0.017156 + 0x4848 0.018174 + 0x4949 0.019191 + 0x4a4a 0.020209 + 0x4b4b 0.021227 + 0x4c4c 0.022418 + 0x4d4d 0.023609 + 0x4e4e 0.024800 + 0x4f4f 0.025991 + 0x5050 0.027181 + 0x5151 0.028690 + 0x5252 0.030198 + 0x5353 0.031707 + 0x5454 0.033215 + 0x5555 0.034724 + 0x5656 0.036212 + 0x5757 0.037700 + 0x5858 0.039187 + 0x5959 0.040675 + 0x5a5a 0.042163 + 0x5b5b 0.043903 + 0x5c5c 0.045642 + 0x5d5d 0.047382 + 0x5e5e 0.049121 + 0x5f5f 0.050861 + 0x6060 0.052846 + 0x6161 0.054830 + 0x6262 0.056815 + 0x6363 0.058800 + 0x6464 0.060785 + 0x6565 0.062914 + 0x6666 0.065043 + 0x6767 0.067173 + 0x6868 0.069302 + 0x6969 0.071431 + 0x6a6a 0.073965 + 0x6b6b 0.076498 + 0x6c6c 0.079032 + 0x6d6d 0.081565 + 0x6e6e 0.084099 + 0x6f6f 0.086704 + 0x7070 0.089310 + 0x7171 0.091916 + 0x7272 0.094521 + 0x7373 0.097127 + 0x7474 0.100051 + 0x7575 0.102975 + 0x7676 0.105899 + 0x7777 0.108823 + 0x7878 0.111747 + 0x7979 0.114750 + 0x7a7a 0.117752 + 0x7b7b 0.120755 + 0x7c7c 0.123757 + 0x7d7d 0.126760 + 0x7e7e 0.130326 + 0x7f7f 0.133893 + 0x8080 0.137459 + 0x8181 0.141026 + 0x8282 0.144592 + 0x8383 0.147992 + 0x8484 0.151391 + 0x8585 0.154791 + 0x8686 0.158190 + 0x8787 0.161590 + 0x8888 0.165460 + 0x8989 0.169329 + 0x8a8a 0.173199 + 0x8b8b 0.177068 + 0x8c8c 0.180938 + 0x8d8d 0.185355 + 0x8e8e 0.189773 + 0x8f8f 0.194190 + 0x9090 0.198608 + 0x9191 0.203025 + 0x9292 0.207218 + 0x9393 0.211412 + 0x9494 0.215605 + 0x9595 0.219799 + 0x9696 0.223992 + 0x9797 0.228504 + 0x9898 0.233016 + 0x9999 0.237527 + 0x9a9a 0.242039 + 0x9b9b 0.246551 + 0x9c9c 0.251762 + 0x9d9d 0.256974 + 0x9e9e 0.262185 + 0x9f9f 0.267397 + 0xa0a0 0.272608 + 0xa1a1 0.277726 + 0xa2a2 0.282845 + 0xa3a3 0.287963 + 0xa4a4 0.293082 + 0xa5a5 0.298200 + 0xa6a6 0.303506 + 0xa7a7 0.308811 + 0xa8a8 0.314117 + 0xa9a9 0.319422 + 0xaaaa 0.324728 + 0xabab 0.330258 + 0xacac 0.335788 + 0xadad 0.341317 + 0xaeae 0.346847 + 0xafaf 0.352377 + 0xb0b0 0.358593 + 0xb1b1 0.364808 + 0xb2b2 0.371024 + 0xb3b3 0.377239 + 0xb4b4 0.383455 + 0xb5b5 0.389612 + 0xb6b6 0.395769 + 0xb7b7 0.401925 + 0xb8b8 0.408082 + 0xb9b9 0.414239 + 0xbaba 0.420600 + 0xbbbb 0.426961 + 0xbcbc 0.433321 + 0xbdbd 0.439682 + 0xbebe 0.446043 + 0xbfbf 0.453125 + 0xc0c0 0.460207 + 0xc1c1 0.467288 + 0xc2c2 0.474370 + 0xc3c3 0.481452 + 0xc4c4 0.488288 + 0xc5c5 0.495125 + 0xc6c6 0.501961 + 0xc7c7 0.508798 + 0xc8c8 0.515634 + 0xc9c9 0.522853 + 0xcaca 0.530072 + 0xcbcb 0.537292 + 0xcccc 0.544511 + 0xcdcd 0.551730 + 0xcece 0.559584 + 0xcfcf 0.567438 + 0xd0d0 0.575292 + 0xd1d1 0.583146 + 0xd2d2 0.591000 + 0xd3d3 0.598768 + 0xd4d4 0.606535 + 0xd5d5 0.614303 + 0xd6d6 0.622070 + 0xd7d7 0.629838 + 0xd8d8 0.637745 + 0xd9d9 0.645652 + 0xdada 0.653558 + 0xdbdb 0.661465 + 0xdcdc 0.669372 + 0xdddd 0.678403 + 0xdede 0.687433 + 0xdfdf 0.696464 + 0xe0e0 0.705494 + 0xe1e1 0.714525 + 0xe2e2 0.723065 + 0xe3e3 0.731605 + 0xe4e4 0.740146 + 0xe5e5 0.748686 + 0xe6e6 0.757226 + 0xe7e7 0.766178 + 0xe8e8 0.775130 + 0xe9e9 0.784082 + 0xeaea 0.793034 + 0xebeb 0.801986 + 0xecec 0.811624 + 0xeded 0.821262 + 0xeeee 0.830901 + 0xefef 0.840539 + 0xf0f0 0.850177 + 0xf1f1 0.859991 + 0xf2f2 0.869804 + 0xf3f3 0.879618 + 0xf4f4 0.889431 + 0xf5f5 0.899245 + 0xf6f6 0.909217 + 0xf7f7 0.919188 + 0xf8f8 0.929160 + 0xf9f9 0.939131 + 0xfafa 0.949103 + 0xfbfb 0.959282 + 0xfcfc 0.969462 + 0xfdfd 0.979641 + 0xfefe 0.989821 + 0xffff 1.000000 + INTENSITY_TBL_END + INTENSITY_TBL_BEGIN GREEN 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000000 + 0x0b0b 0.000000 + 0x0c0c 0.000000 + 0x0d0d 0.000000 + 0x0e0e 0.000000 + 0x0f0f 0.000000 + 0x1010 0.000000 + 0x1111 0.000000 + 0x1212 0.000000 + 0x1313 0.000000 + 0x1414 0.000000 + 0x1515 0.000022 + 0x1616 0.000044 + 0x1717 0.000066 + 0x1818 0.000087 + 0x1919 0.000109 + 0x1a1a 0.000131 + 0x1b1b 0.000152 + 0x1c1c 0.000173 + 0x1d1d 0.000195 + 0x1e1e 0.000216 + 0x1f1f 0.000307 + 0x2020 0.000398 + 0x2121 0.000489 + 0x2222 0.000580 + 0x2323 0.000671 + 0x2424 0.000804 + 0x2525 0.000937 + 0x2626 0.001070 + 0x2727 0.001203 + 0x2828 0.001336 + 0x2929 0.001514 + 0x2a2a 0.001691 + 0x2b2b 0.001869 + 0x2c2c 0.002046 + 0x2d2d 0.002224 + 0x2e2e 0.002604 + 0x2f2f 0.002985 + 0x3030 0.003365 + 0x3131 0.003746 + 0x3232 0.004127 + 0x3333 0.004618 + 0x3434 0.005110 + 0x3535 0.005602 + 0x3636 0.006094 + 0x3737 0.006586 + 0x3838 0.007191 + 0x3939 0.007797 + 0x3a3a 0.008402 + 0x3b3b 0.009008 + 0x3c3c 0.009613 + 0x3d3d 0.010399 + 0x3e3e 0.011185 + 0x3f3f 0.011971 + 0x4040 0.012757 + 0x4141 0.013543 + 0x4242 0.014529 + 0x4343 0.015516 + 0x4444 0.016502 + 0x4545 0.017488 + 0x4646 0.018475 + 0x4747 0.019641 + 0x4848 0.020808 + 0x4949 0.021975 + 0x4a4a 0.023141 + 0x4b4b 0.024308 + 0x4c4c 0.025678 + 0x4d4d 0.027049 + 0x4e4e 0.028419 + 0x4f4f 0.029789 + 0x5050 0.031159 + 0x5151 0.032730 + 0x5252 0.034301 + 0x5353 0.035872 + 0x5454 0.037443 + 0x5555 0.039014 + 0x5656 0.040697 + 0x5757 0.042380 + 0x5858 0.044063 + 0x5959 0.045747 + 0x5a5a 0.047430 + 0x5b5b 0.049363 + 0x5c5c 0.051295 + 0x5d5d 0.053228 + 0x5e5e 0.055161 + 0x5f5f 0.057094 + 0x6060 0.059316 + 0x6161 0.061539 + 0x6262 0.063761 + 0x6363 0.065983 + 0x6464 0.068206 + 0x6565 0.070521 + 0x6666 0.072836 + 0x6767 0.075151 + 0x6868 0.077466 + 0x6969 0.079781 + 0x6a6a 0.082294 + 0x6b6b 0.084808 + 0x6c6c 0.087321 + 0x6d6d 0.089835 + 0x6e6e 0.092348 + 0x6f6f 0.095312 + 0x7070 0.098276 + 0x7171 0.101240 + 0x7272 0.104204 + 0x7373 0.107168 + 0x7474 0.110134 + 0x7575 0.113100 + 0x7676 0.116067 + 0x7777 0.119033 + 0x7878 0.121999 + 0x7979 0.125235 + 0x7a7a 0.128471 + 0x7b7b 0.131708 + 0x7c7c 0.134944 + 0x7d7d 0.138180 + 0x7e7e 0.141796 + 0x7f7f 0.145412 + 0x8080 0.149029 + 0x8181 0.152645 + 0x8282 0.156261 + 0x8383 0.159971 + 0x8484 0.163681 + 0x8585 0.167392 + 0x8686 0.171102 + 0x8787 0.174812 + 0x8888 0.178720 + 0x8989 0.182628 + 0x8a8a 0.186536 + 0x8b8b 0.190444 + 0x8c8c 0.194352 + 0x8d8d 0.198687 + 0x8e8e 0.203023 + 0x8f8f 0.207358 + 0x9090 0.211694 + 0x9191 0.216029 + 0x9292 0.220412 + 0x9393 0.224795 + 0x9494 0.229179 + 0x9595 0.233562 + 0x9696 0.237945 + 0x9797 0.242618 + 0x9898 0.247291 + 0x9999 0.251965 + 0x9a9a 0.256638 + 0x9b9b 0.261311 + 0x9c9c 0.266561 + 0x9d9d 0.271812 + 0x9e9e 0.277062 + 0x9f9f 0.282313 + 0xa0a0 0.287563 + 0xa1a1 0.292687 + 0xa2a2 0.297811 + 0xa3a3 0.302936 + 0xa4a4 0.308060 + 0xa5a5 0.313184 + 0xa6a6 0.318485 + 0xa7a7 0.323787 + 0xa8a8 0.329088 + 0xa9a9 0.334390 + 0xaaaa 0.339691 + 0xabab 0.345238 + 0xacac 0.350785 + 0xadad 0.356332 + 0xaeae 0.361879 + 0xafaf 0.367426 + 0xb0b0 0.373596 + 0xb1b1 0.379766 + 0xb2b2 0.385935 + 0xb3b3 0.392105 + 0xb4b4 0.398275 + 0xb5b5 0.404379 + 0xb6b6 0.410483 + 0xb7b7 0.416586 + 0xb8b8 0.422690 + 0xb9b9 0.428794 + 0xbaba 0.435099 + 0xbbbb 0.441405 + 0xbcbc 0.447710 + 0xbdbd 0.454016 + 0xbebe 0.460321 + 0xbfbf 0.467525 + 0xc0c0 0.474729 + 0xc1c1 0.481932 + 0xc2c2 0.489136 + 0xc3c3 0.496340 + 0xc4c4 0.503722 + 0xc5c5 0.511105 + 0xc6c6 0.518487 + 0xc7c7 0.525870 + 0xc8c8 0.533252 + 0xc9c9 0.540159 + 0xcaca 0.547066 + 0xcbcb 0.553972 + 0xcccc 0.560879 + 0xcdcd 0.567786 + 0xcece 0.576112 + 0xcfcf 0.584437 + 0xd0d0 0.592763 + 0xd1d1 0.601088 + 0xd2d2 0.609414 + 0xd3d3 0.617043 + 0xd4d4 0.624672 + 0xd5d5 0.632302 + 0xd6d6 0.639931 + 0xd7d7 0.647560 + 0xd8d8 0.655408 + 0xd9d9 0.663255 + 0xdada 0.671103 + 0xdbdb 0.678950 + 0xdcdc 0.686798 + 0xdddd 0.695334 + 0xdede 0.703869 + 0xdfdf 0.712405 + 0xe0e0 0.720940 + 0xe1e1 0.729476 + 0xe2e2 0.737757 + 0xe3e3 0.746039 + 0xe4e4 0.754320 + 0xe5e5 0.762602 + 0xe6e6 0.770883 + 0xe7e7 0.779637 + 0xe8e8 0.788391 + 0xe9e9 0.797145 + 0xeaea 0.805899 + 0xebeb 0.814653 + 0xecec 0.824068 + 0xeded 0.833483 + 0xeeee 0.842899 + 0xefef 0.852314 + 0xf0f0 0.861729 + 0xf1f1 0.870730 + 0xf2f2 0.879730 + 0xf3f3 0.888731 + 0xf4f4 0.897731 + 0xf5f5 0.906732 + 0xf6f6 0.915706 + 0xf7f7 0.924680 + 0xf8f8 0.933653 + 0xf9f9 0.942627 + 0xfafa 0.951601 + 0xfbfb 0.961281 + 0xfcfc 0.970961 + 0xfdfd 0.980640 + 0xfefe 0.990320 + 0xffff 1.000000 + INTENSITY_TBL_END + INTENSITY_TBL_BEGIN BLUE 256 + 0x0000 0.000000 + 0x0101 0.000000 + 0x0202 0.000000 + 0x0303 0.000000 + 0x0404 0.000000 + 0x0505 0.000000 + 0x0606 0.000000 + 0x0707 0.000000 + 0x0808 0.000000 + 0x0909 0.000000 + 0x0a0a 0.000000 + 0x0b0b 0.000000 + 0x0c0c 0.000000 + 0x0d0d 0.000000 + 0x0e0e 0.000000 + 0x0f0f 0.000000 + 0x1010 0.000000 + 0x1111 0.000000 + 0x1212 0.000000 + 0x1313 0.000000 + 0x1414 0.000000 + 0x1515 0.000000 + 0x1616 0.000000 + 0x1717 0.000000 + 0x1818 0.000000 + 0x1919 0.000000 + 0x1a1a 0.000000 + 0x1b1b 0.000000 + 0x1c1c 0.000000 + 0x1d1d 0.000000 + 0x1e1e 0.000000 + 0x1f1f 0.000000 + 0x2020 0.000000 + 0x2121 0.000000 + 0x2222 0.000000 + 0x2323 0.000000 + 0x2424 0.000201 + 0x2525 0.000402 + 0x2626 0.000603 + 0x2727 0.000804 + 0x2828 0.001005 + 0x2929 0.001606 + 0x2a2a 0.002206 + 0x2b2b 0.002807 + 0x2c2c 0.003408 + 0x2d2d 0.004008 + 0x2e2e 0.004413 + 0x2f2f 0.004818 + 0x3030 0.005224 + 0x3131 0.005629 + 0x3232 0.006034 + 0x3333 0.006034 + 0x3434 0.006034 + 0x3535 0.006034 + 0x3636 0.006034 + 0x3737 0.006034 + 0x3838 0.006835 + 0x3939 0.007637 + 0x3a3a 0.008439 + 0x3b3b 0.009240 + 0x3c3c 0.010042 + 0x3d3d 0.010837 + 0x3e3e 0.011632 + 0x3f3f 0.012428 + 0x4040 0.013223 + 0x4141 0.014018 + 0x4242 0.014820 + 0x4343 0.015621 + 0x4444 0.016423 + 0x4545 0.017225 + 0x4646 0.018026 + 0x4747 0.019032 + 0x4848 0.020038 + 0x4949 0.021044 + 0x4a4a 0.022049 + 0x4b4b 0.023055 + 0x4c4c 0.024262 + 0x4d4d 0.025469 + 0x4e4e 0.026675 + 0x4f4f 0.027882 + 0x5050 0.029089 + 0x5151 0.030491 + 0x5252 0.031893 + 0x5353 0.033296 + 0x5454 0.034698 + 0x5555 0.036100 + 0x5656 0.037715 + 0x5757 0.039330 + 0x5858 0.040945 + 0x5959 0.042560 + 0x5a5a 0.044175 + 0x5b5b 0.045982 + 0x5c5c 0.047790 + 0x5d5d 0.049597 + 0x5e5e 0.051405 + 0x5f5f 0.053212 + 0x6060 0.055409 + 0x6161 0.057607 + 0x6262 0.059805 + 0x6363 0.062002 + 0x6464 0.064200 + 0x6565 0.066412 + 0x6666 0.068625 + 0x6767 0.070837 + 0x6868 0.073050 + 0x6969 0.075262 + 0x6a6a 0.077664 + 0x6b6b 0.080065 + 0x6c6c 0.082467 + 0x6d6d 0.084868 + 0x6e6e 0.087270 + 0x6f6f 0.090083 + 0x7070 0.092896 + 0x7171 0.095710 + 0x7272 0.098523 + 0x7373 0.101336 + 0x7474 0.104353 + 0x7575 0.107370 + 0x7676 0.110388 + 0x7777 0.113405 + 0x7878 0.116422 + 0x7979 0.119640 + 0x7a7a 0.122858 + 0x7b7b 0.126077 + 0x7c7c 0.129295 + 0x7d7d 0.132513 + 0x7e7e 0.135920 + 0x7f7f 0.139328 + 0x8080 0.142735 + 0x8181 0.146143 + 0x8282 0.149550 + 0x8383 0.153165 + 0x8484 0.156780 + 0x8585 0.160394 + 0x8686 0.164009 + 0x8787 0.167624 + 0x8888 0.171436 + 0x8989 0.175249 + 0x8a8a 0.179061 + 0x8b8b 0.182874 + 0x8c8c 0.186686 + 0x8d8d 0.190910 + 0x8e8e 0.195134 + 0x8f8f 0.199358 + 0x9090 0.203582 + 0x9191 0.207806 + 0x9292 0.212219 + 0x9393 0.216632 + 0x9494 0.221045 + 0x9595 0.225458 + 0x9696 0.229871 + 0x9797 0.234696 + 0x9898 0.239520 + 0x9999 0.244345 + 0x9a9a 0.249169 + 0x9b9b 0.253994 + 0x9c9c 0.258998 + 0x9d9d 0.264003 + 0x9e9e 0.269007 + 0x9f9f 0.274012 + 0xa0a0 0.279016 + 0xa1a1 0.284045 + 0xa2a2 0.289073 + 0xa3a3 0.294102 + 0xa4a4 0.299130 + 0xa5a5 0.304159 + 0xa6a6 0.309779 + 0xa7a7 0.315399 + 0xa8a8 0.321018 + 0xa9a9 0.326638 + 0xaaaa 0.332258 + 0xabab 0.338293 + 0xacac 0.344327 + 0xadad 0.350362 + 0xaeae 0.356396 + 0xafaf 0.362431 + 0xb0b0 0.368651 + 0xb1b1 0.374872 + 0xb2b2 0.381092 + 0xb3b3 0.387313 + 0xb4b4 0.393533 + 0xb5b5 0.399567 + 0xb6b6 0.405602 + 0xb7b7 0.411636 + 0xb8b8 0.417671 + 0xb9b9 0.423705 + 0xbaba 0.430127 + 0xbbbb 0.436548 + 0xbcbc 0.442970 + 0xbdbd 0.449391 + 0xbebe 0.455813 + 0xbfbf 0.463033 + 0xc0c0 0.470253 + 0xc1c1 0.477472 + 0xc2c2 0.484692 + 0xc3c3 0.491912 + 0xc4c4 0.499138 + 0xc5c5 0.506364 + 0xc6c6 0.513591 + 0xc7c7 0.520817 + 0xc8c8 0.528043 + 0xc9c9 0.535269 + 0xcaca 0.542495 + 0xcbcb 0.549722 + 0xcccc 0.556948 + 0xcdcd 0.564174 + 0xcece 0.572009 + 0xcfcf 0.579845 + 0xd0d0 0.587680 + 0xd1d1 0.595516 + 0xd2d2 0.603351 + 0xd3d3 0.611379 + 0xd4d4 0.619407 + 0xd5d5 0.627434 + 0xd6d6 0.635462 + 0xd7d7 0.643490 + 0xd8d8 0.651512 + 0xd9d9 0.659533 + 0xdada 0.667555 + 0xdbdb 0.675576 + 0xdcdc 0.683598 + 0xdddd 0.692650 + 0xdede 0.701701 + 0xdfdf 0.710753 + 0xe0e0 0.719804 + 0xe1e1 0.728856 + 0xe2e2 0.737496 + 0xe3e3 0.746136 + 0xe4e4 0.754777 + 0xe5e5 0.763417 + 0xe6e6 0.772057 + 0xe7e7 0.781091 + 0xe8e8 0.790124 + 0xe9e9 0.799158 + 0xeaea 0.808191 + 0xebeb 0.817225 + 0xecec 0.826660 + 0xeded 0.836096 + 0xeeee 0.845531 + 0xefef 0.854967 + 0xf0f0 0.864402 + 0xf1f1 0.873235 + 0xf2f2 0.882067 + 0xf3f3 0.890900 + 0xf4f4 0.899732 + 0xf5f5 0.908565 + 0xf6f6 0.917806 + 0xf7f7 0.927047 + 0xf8f8 0.936287 + 0xf9f9 0.945528 + 0xfafa 0.954769 + 0xfbfb 0.963815 + 0xfcfc 0.972861 + 0xfdfd 0.981908 + 0xfefe 0.990954 + 0xffff 1.000000 + INTENSITY_TBL_END + INTENSITY_PROFILE_END + +SCREENDATA_END diff --git a/loadData.c b/loadData.c new file mode 100644 index 0000000..5082e83 --- /dev/null +++ b/loadData.c @@ -0,0 +1,1787 @@ +/* $Xorg: loadData.c,v 1.4 2000/08/17 19:54:13 cpqbld Exp $ */ + +/* + * (c) Copyright 1990 Tektronix Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Tektronix not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + * Tektronix disclaims all warranties with regard to this software, including + * all implied warranties of merchantability and fitness, 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 performance of this + * software. + * + * + * NAME + * LoadSCCData.c + * + * DESCRIPTION + * TekCMS API routine that reads screen data from a file + * and then loads the data on the root window of the screen. + * + * + * + */ + +/* + * INCLUDES + */ + +#include <X11/Xos.h> +#include <sys/stat.h> +#include <stdio.h> + +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include "SCCDFile.h" + + +/* + * 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). + */ + +#ifdef X_NOT_STDC_ENV +extern char *strtok(); +extern char *strchr(); +#endif +#ifndef X_NOT_STDC_ENV +#include <stdlib.h> +#else +char *calloc(); +#endif + +/* + * LOCAL TYPEDEFS + * typedefs local to this package (for use with local vars). + * + */ + +typedef struct _DefineEntry { + char *pString; + int define; +} DefineEntry; + + +/* + * LOCAL VARIABLES + */ +static int linenum = 0; + +static DefineEntry KeyTbl[] = { + SC_BEGIN_KEYWORD, SC_BEGIN, + SC_END_KEYWORD, SC_END, + COMMENT_KEYWORD, COMMENT, + NAME_KEYWORD, NAME, + MODEL_KEYWORD, MODEL, + PART_NUMBER_KEYWORD, PART_NUMBER, + SERIAL_NUMBER_KEYWORD, SERIAL_NUMBER, + REVISION_KEYWORD, REVISION, + SCREEN_CLASS_KEYWORD, SCREEN_CLASS, + COLORIMETRIC_BEGIN_KEYWORD, COLORIMETRIC_BEGIN, + COLORIMETRIC_END_KEYWORD, COLORIMETRIC_END, + XYZTORGBMAT_BEGIN_KEYWORD, XYZTORGBMAT_BEGIN, + XYZTORGBMAT_END_KEYWORD, XYZTORGBMAT_END, + WHITEPT_XYZ_BEGIN_KEYWORD, WHITEPT_XYZ_BEGIN, + WHITEPT_XYZ_END_KEYWORD, WHITEPT_XYZ_END, + RGBTOXYZMAT_BEGIN_KEYWORD, RGBTOXYZMAT_BEGIN, + RGBTOXYZMAT_END_KEYWORD, RGBTOXYZMAT_END, + IPROFILE_BEGIN_KEYWORD, IPROFILE_BEGIN, + IPROFILE_END_KEYWORD, IPROFILE_END, + ITBL_BEGIN_KEYWORD, ITBL_BEGIN, + ITBL_END_KEYWORD, ITBL_END, + "", -1 +}; + +static DefineEntry ScrnClassTbl[] = { + VIDEO_RGB_KEYWORD, VIDEO_RGB, +#ifdef GRAY + VIDEO_GRAY_KEYWORD, VIDEO_GRAY, +#endif /* GRAY */ + "", -1 +}; + +#define KEY_VISUALID 1 +#define KEY_DEPTH 2 +#define KEY_CLASS 3 +#define KEY_RED_MASK 4 +#define KEY_GREEN_MASK 5 +#define KEY_BLUE_MASK 6 +#define KEY_COLORMAP_SIZE 7 +#define KEY_BITS_PER_RGB 8 + +static DefineEntry VisualOptKeyTbl[] = { + "visualid", KEY_VISUALID, + "depth", KEY_DEPTH, + "class", KEY_CLASS, + "red_mask", KEY_RED_MASK, + "green_mask", KEY_GREEN_MASK, + "blue_mask", KEY_BLUE_MASK, + "colormap_size", KEY_COLORMAP_SIZE, + "bits_per_rgb", KEY_BITS_PER_RGB, + "", -1 +}; +static DefineEntry VisualClassTbl[] = { + "StaticGray", StaticGray, + "GrayScale", GrayScale, + "StaticColor", StaticColor, + "PseudoColor", PseudoColor, + "TrueColor", TrueColor, + "DirectColor", DirectColor, + "", -1 +}; + + +/************************************************************************ + * * + * PRIVATE ROUTINES * + * * + ************************************************************************/ + +/* + * NAME + * StrToDefine - convert a string to a define + * + * SYNOPSIS + */ +static int +StrToDefine(pde,pstring) + DefineEntry pde[]; /* IN: table of X string-define pairs */ + /* last entry must contain pair "", 0 */ + char *pstring; /* IN: string to be looked up in that table */ +/* + * DESCRIPTION + * Converts a string to an integer define. + * + * Looks up the string in the table and returns the integer + * associated with the string. + * + * Later may need similar function for unsigned long define. + * + * + * + * RETURNS + * The int equivalent of the defined string. + * -1 if the string is not found in table + * + */ +{ + while( strcmp(pde->pString,"") != 0 ){ + if( strcmp(pde->pString,pstring) == 0){ + return(pde->define); + } + pde++; + } + return(-1); +} + +/* + * NAME + * DefineToStr + * + * SYNOPSIS + */ +static char * +DefineToStr(pde,id) + DefineEntry pde[]; /* IN: table of X string-define pairs */ + /* last entry must contain pair "", 0 */ + int id; /* IN: id to be looked up in that table */ +/* + * DESCRIPTION + * Converts a string to an integer define. + * + * Looks up the string in the table and returns the integer + * associated with the string. + * + * Later may need similar function for unsigned long define. + * + * + * + * RETURNS + * The int equivalent of the defined string. + * -1 if the string is not found in table + * + */ +{ + while(pde->define != -1) { + if (pde->define == id) { + return(pde->pString); + } + pde++; + } + return(NULL); +} + +/* + * NAME + * SCKeyOf - convert keyword into key ID + * + * SYNOPSIS + */ +static int +SCKeyOf(string) + char *string; +/* + * DESCRIPTION + * Converts a string to an integer define. + * + * Looks up the string in the table and returns the integer + * associated with the string. + * + * Later may need similar function for unsigned long define. + * + * + * + * RETURNS + * The int equivalent of the defined string. + * -1 if the string is not found in table + * + */ +{ + return(StrToDefine(KeyTbl, string)); +} + + +/* + * NAME + * SCScrnClassOf - convert screen class string into class ID + * + * SYNOPSIS + */ +static int +SCScrnClassOf(string) + char *string; +/* + * DESCRIPTION + * Converts a string to an integer define. + * + * Looks up the string in the table and returns the integer + * associated with the string. + * + * Later may need similar function for unsigned long define. + * + * + * + * RETURNS + * The int equivalent of the defined string. + * -1 if the string is not found in table + * + */ +{ + return(StrToDefine(ScrnClassTbl, string)); +} + + +/* + * NAME + * SCScrnClassStringOf - convert screen class id into class string + * + * SYNOPSIS + */ +static char * +SCScrnClassStringOf(id) + int id; +/* + * DESCRIPTION + * Converts a id to astring + * + * RETURNS + * Pointer to string if found; otherwise NULL. + * + */ +{ + return(DefineToStr(ScrnClassTbl, id)); +} + +/* close the stream and return any memory allocated. */ +/*ARGSUSED*/ +static void +closeS(stream, pCorrection) + FILE *stream; + XDCCC_Correction* pCorrection; +{ + XDCCC_Correction* pNext; + if (stream) { + fclose (stream); + } + while (pCorrection) { + pNext = pCorrection->next; + free(pCorrection); + pCorrection = pNext; + } +} + +/* + * Get a line of text from the stream. + */ +static char * +nextline(buf, maxch, stream) + char *buf; + int maxch; + FILE *stream; +{ + linenum++; + return (fgets(buf, maxch, stream)); +} + + +static int +ProcessColorimetric(stream, pMatrix, VisualFlag) + FILE *stream; + XDCCC_Matrix* pMatrix; + int VisualFlag; +{ + char buf[BUFSIZ]; + char keyword[BUFSIZ]; + char token[BUFSIZ], *ptoken; + int ntok; + unsigned int matrices_processed = 0; + /* bit 0 for XYZtoRGB matrix */ + /* bit 1 for RGBtoXYZ matrix */ + int state = 0; + /* 0 -- looking for matrix */ + /* 1 -- processing data from matrix */ + /* 2 -- both matrices processed */ + /* Note: the order of the matrices is not important. */ + int count; + XcmsFloat *pElement; + + while ((nextline(buf, BUFSIZ, stream)) != NULL) { + if ((ntok = sscanf(buf, "%s %s", keyword, token)) > 0) { + switch (SCKeyOf(keyword)) { + case XYZTORGBMAT_BEGIN : + if (VisualFlag != VIDEO_RGB) { + fprintf(stderr, + "Line %d: Keyword XYZTORGBMAT_BEGIN mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if (state != 0) { + fprintf(stderr, + "Line %d: Extraneous keyword %s.\n", + linenum, keyword); + return (0); + } + state = 1; + count = 0; + pElement = (XcmsFloat *) pMatrix->XYZtoRGBmatrix; + break; + case XYZTORGBMAT_END : + if (VisualFlag != VIDEO_RGB) { + fprintf(stderr, + "Line %d: Keyword XYZTORGBMAT_END mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if ((state != 1) || (count != 9)) { + fprintf(stderr, + "Line %d: Incomplete XYZtoRGB matrix -- Premature %s\n", + linenum, keyword); + return (0); + } + matrices_processed |= 0x1; + if (matrices_processed == 3) { + state = 2; + } else { + state = 0; + } + break; + case RGBTOXYZMAT_BEGIN : + if (VisualFlag != VIDEO_RGB) { + fprintf(stderr, + "Line %d: Keyword RGBTOXYZMAT_BEGIN mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if (state != 0) { + fprintf(stderr, "Line %d: Extraneous keyword %s.\n", + linenum, keyword); + return (0); + } + state = 1; + count = 0; + pElement = (XcmsFloat *) pMatrix->RGBtoXYZmatrix; + break; + case RGBTOXYZMAT_END : + if (VisualFlag != VIDEO_RGB) { + fprintf(stderr, + "Line %d: Keyword RGBTOXYZMAT_END mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if ((state != 1) || (count != 9)) { + fprintf(stderr, + "Line %d: Incomplete RGBtoXYZ matrix -- Premature %s\n", + linenum, keyword); + return (0); + } + matrices_processed |= 0x2; + if (matrices_processed == 3) { + state = 2; + } else { + state = 0; + } + break; +#ifdef GRAY + case WHITEPT_XYZ_BEGIN : + if (VisualFlag != VIDEO_GRAY) { + fprintf(stderr, + "Line %d: Keyword WHITEPT_XYZ_BEGIN mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if (state != 0) { + fprintf(stderr, + "Line %d: Extraneous keyword %s.\n", + linenum, keyword); + return (0); + } + state = 1; + count = 0; + pElement = (XcmsFloat *) pMatrix->XYZtoRGBmatrix; + break; + case WHITEPT_XYZ_END : + if (VisualFlag != VIDEO_GRAY) { + fprintf(stderr, + "Line %d: Keyword WHITEPT_XYZ_END mismatch for visual %s.\n", + linenum, SCScrnClassStringOf(VisualFlag)); + return (0); + } + if ((state != 1) || (count != 3)) { + fprintf(stderr, + "Line %d: Incomplete white point -- Premature %s\n", + linenum, keyword); + return (0); + } + state = 2; + break; +#endif /* GRAY */ + case DATA : + for (ptoken = strtok(buf, DATA_DELIMS); ptoken != NULL; + ptoken = strtok(NULL, DATA_DELIMS)) { + if (sscanf(ptoken, "%lf", pElement) != 1) { + if (VisualFlag == VIDEO_RGB) { + fprintf(stderr, + "Line %d: Invalid matrix value %s.", + linenum, ptoken); + } else { + fprintf(stderr, + "Line %d: Invalid CIEXYZ value %s.\n", + linenum, ptoken); + } + return (0); + } + pElement++; + if (VisualFlag == VIDEO_RGB) { + if (++count > 9) { + fprintf(stderr, + "Line %d: Extra matrix value %s\n", + linenum, ptoken); + return (0); + } + } else { + if (++count > 3) { + fprintf(stderr, + "Line %d: Extra CIEXYZ value %s.\n", + linenum, ptoken); + return (0); + } + } + } + break; + case COLORIMETRIC_BEGIN : + fprintf(stderr, + "Line %d: Extraneous keyword %s.\n", + linenum, keyword); + return (0); +/* NOTREACHED */break; + case COLORIMETRIC_END : + if (state != 2) { + fprintf(stderr, + "Line %d: Incomplete Colorimetric data -- Premature %s\n", + linenum, keyword); + return (0); + } + return (1); + case COMMENT : + /* Currently, do nothing. */ + break; + default : + fprintf(stderr, + "Line %d: Unexpected keyword %s\n", + linenum, keyword); + return (0); +/* NOTREACHED */break; + } + } else if (ntok < 0) { + /* mismatch */ + fprintf(stderr, "Line %d: Unrecognized keyword\n", linenum); + return (0); +/* NOTREACHED */break; + } + } + return (0); +} + +static int +ProcessIProfile(stream, pCorrection) + FILE *stream; + XDCCC_Correction* pCorrection; +{ + char buf[BUFSIZ]; + char *keyword; + char *tableStr, *sizeStr, *ptoken; + int size; + int state = 0; + /************************************************ + * 0 -- Looking for Intensity Table(s) * + * 1 -- Processing Intensity Table(s) * + ************************************************/ + int nTbl = 0; + int count = 0; + IntensityRec *pIRec = NULL; + + while ((nextline(buf, BUFSIZ, stream)) != NULL) { + ptoken = keyword = strtok(buf, DATA_DELIMS); + if (keyword != (char*)NULL) { + switch (SCKeyOf(keyword)) { + case ITBL_BEGIN : + if (state != 0) { + fprintf(stderr,"Line %d: unexpected keyword %s\n", + linenum, keyword); + return (0); + } + tableStr = strtok((char*)NULL, DATA_DELIMS); + sizeStr = strtok((char*)NULL, DATA_DELIMS); + if ((sizeStr == (char*)NULL) || + sscanf(sizeStr, "%d", &size) != 1) { + fprintf(stderr, + "Line %d: invalid Intensity Table size, %s.\n", + linenum, sizeStr); + return (0); + } + if (size < 0) { + fprintf(stderr, + "Line %d: count %d < 0 for Intensity Table.\n", + linenum, size); + return (0); + } + if (strcmp(tableStr, "GREEN") == 0) { + if (pCorrection->nTables != 3) { + fprintf(stderr,"Line %d: incorrect number of tables\n", + linenum); + return (0); + } + if (pCorrection->pGreenTbl->pBase != NULL) { + fprintf(stderr, + "Line %d: multiple GREEN Intensity Profiles\n", + linenum); + return (0); + } + pCorrection->pGreenTbl->nEntries = size; + pCorrection->pGreenTbl->pBase = + (IntensityRec *) calloc (size, sizeof(IntensityRec)); + if (!pCorrection->pGreenTbl->pBase) { + fprintf(stderr, + "Line %d: Unable to allocate space for GREEN Intensity Profile\n", linenum); + return (0); + } + pIRec = pCorrection->pGreenTbl->pBase; + } else if (strcmp(tableStr, "BLUE") == 0) { + if (pCorrection->nTables != 3) { + fprintf(stderr, + "Line %d: incorrect number of tables\n", + linenum); + return (0); + } + if (pCorrection->pBlueTbl->pBase != NULL) { + fprintf(stderr, + "Line %d: multiple BLUE Intensity Profiles\n", + linenum); + return (0); + } + pCorrection->pBlueTbl->nEntries = size; + pCorrection->pBlueTbl->pBase = + (IntensityRec *) calloc (size, sizeof(IntensityRec)); + if (!pCorrection->pBlueTbl->pBase) { + fprintf(stderr, + "Line %d: Unable to allocate space for BLUE Intensity Profile\n", linenum); + return (0); + } + pIRec = pCorrection->pBlueTbl->pBase; + } else { + if (!strcmp(tableStr, "RGB") && pCorrection->nTables != 1) { + fprintf(stderr,"Line %d: multiple RGB Intensity Tables", + linenum); + return (0); + } + if (pCorrection->pRedTbl->pBase != NULL) { + fprintf(stderr, + "Line %d: multiple RED or GREEN or BLUE Intensity Tables\n", + linenum); + return (0); + } + pCorrection->pRedTbl->nEntries = size; + pCorrection->pRedTbl->pBase = + (IntensityRec *) calloc (size, sizeof(IntensityRec)); + if (!pCorrection->pRedTbl->pBase) { + fprintf(stderr, + "Line %d: Unable to allocate space for intensity table\n", linenum); + return (0); + } + pIRec = pCorrection->pRedTbl->pBase; + } + state = 1; + count = 0; + break; + case ITBL_END : + if ((state != 1) || (count != size)) { + fprintf(stderr, + "Line %d: incomplete Intensity Table -- Premature %s\n", + linenum, keyword); + return (0); + } + nTbl++; + state = 0; + break; + case DATA : + do { + /******************************************************** + * Note: tableType should only be 0 or 1 at this point. + * 0 indicates value and intensity stored. + * 1 indicates only intensity stored. + ********************************************************/ + if (pCorrection->tableType) { + if (sscanf(ptoken, "%lf", &pIRec->intensity) != 1) { + fprintf(stderr, + "Line %d: invalid Intensity Profile value %s\n", + linenum, ptoken); + return (0); + } + /* With tableType 1 only store the intensity. */ + pIRec++; + } else { +#if __STDC__ + /* Note ansi C can handle 0x preceeding hex number */ + if (sscanf(ptoken, "%hi", &pIRec->value) != 1) { + fprintf(stderr, + "Line %d: invalid Intensity Profile value %s\n", + linenum, ptoken); + return (0); + } +#else + if (*ptoken == '0' && + ((*(ptoken+1) == 'x') || (*(ptoken+1) == 'X') )) + ptoken += 2; + if (sscanf(ptoken, "%hx", &pIRec->value) != 1) { + fprintf(stderr, + "Line %d: invalid Intensity Profile value %s\n", + linenum, ptoken); + return (0); + } +#endif + if ((ptoken = strtok(NULL, DATA_DELIMS)) == NULL) { + fprintf(stderr, + "Line %d: missing Intensity Profile value\n", + linenum); + return (0); + } + if (sscanf(ptoken, "%lf", &pIRec->intensity) != 1) { + fprintf(stderr, + "Line %d: invalid Intensity Profile intensity %s\n", + linenum, ptoken); + return (0); + } + /* With tableType 0 only store both value & intensity*/ + pIRec++; + } + if (++count > size) { + fprintf(stderr, + "Line %d: extra Intensity value %s\n", + linenum, ptoken); + return (0); + } + ptoken = strtok(NULL, DATA_DELIMS); + } while(ptoken != NULL); + break; + case IPROFILE_BEGIN : + fprintf(stderr,"Line %d: extraneous keyword %s\n", + linenum, keyword); + return (0); +/* NOTREACHED */break; + case IPROFILE_END : + if ((state != 0) || (nTbl != pCorrection->nTables)) { + fprintf(stderr, + "Line %d: incomplete Intensity Profile data -- Premature %s\n", + linenum, keyword); + return (0); + } + return (1); + case COMMENT : + /* ignore line */ + break; + default : + fprintf(stderr,"Line %d: unexpected keyword %s\n", + linenum, keyword); + return (0); +/* NOTREACHED */break; + } + } /* else its was just a blank line */ + } + return (0); +} + +static void +PutTableType0Card8(pTbl, pCard8) + IntensityTbl *pTbl; + unsigned char **pCard8; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard8 = count - 1; + *pCard8 += 1; + for (; count; count--, pIRec++) { + **pCard8 = pIRec->value >> 8; + *pCard8 += 1; + **pCard8 = pIRec->intensity * 255.0; + *pCard8 += 1; + } +} + +static void +PutTableType1Card8(pTbl, pCard8) + IntensityTbl *pTbl; + unsigned char **pCard8; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard8 = count - 1; + *pCard8 += 1; + for (; count; count--, pIRec++) { + **pCard8 = pIRec->intensity * 255.0; + *pCard8 += 1; + } +} + +static void +PutTableType0Card16(pTbl, pCard16) + IntensityTbl *pTbl; + unsigned short **pCard16; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard16 = count - 1; + *pCard16 += 1; + for (; count; count--, pIRec++) { + **pCard16 = pIRec->value; + *pCard16 += 1; + **pCard16 = pIRec->intensity * 65535.0; + *pCard16 += 1; + } +} + +static void +PutTableType1Card16(pTbl, pCard16) + IntensityTbl *pTbl; + unsigned short **pCard16; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard16 = count - 1; + *pCard16 += 1; + for (; count; count--, pIRec++) { + **pCard16 = pIRec->intensity * 65535.0; + *pCard16 += 1; + } +} + +static void +PutTableType0Card32(pTbl, pCard32) + IntensityTbl *pTbl; + unsigned long **pCard32; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard32 = count - 1; + *pCard32 += 1; + for (; count; count--, pIRec++) { + **pCard32 = pIRec->value; + *pCard32 += 1; + **pCard32 = pIRec->intensity * 4294967295.0; + *pCard32 += 1; + } +} + +static void +PutTableType1Card32(pTbl, pCard32) + IntensityTbl *pTbl; + unsigned long **pCard32; +{ + unsigned int count; + IntensityRec *pIRec; + + pIRec = pTbl->pBase; + count = pTbl->nEntries; + **pCard32 = count - 1; + *pCard32 += 1; + for (; count; count--, pIRec++) { + **pCard32 = pIRec->intensity * 4294967295.0; + *pCard32 += 1; + } +} + + +static void +LoadMatrix(pDpy, root, pMatrix) + Display *pDpy; + Window root; + XDCCC_Matrix *pMatrix; +{ + int count; + unsigned long *pCard32; + unsigned long Card32Array[18]; + Atom MatricesAtom; + XcmsFloat *pValue; + + /* + * Store the XDCCC_LINEAR_RGB_MATRICES + */ + pCard32 = Card32Array; + pValue = (XcmsFloat *)pMatrix->XYZtoRGBmatrix; + for (count = 0; count < 9; count++) { + *pCard32++ = (unsigned long) (*pValue++ * (XcmsFloat) XDCCC_NUMBER); + } + pValue = (XcmsFloat *)pMatrix->RGBtoXYZmatrix; + for (count = 0; count < 9; count++) { + *pCard32++ = (unsigned long) (*pValue++ * (XcmsFloat) XDCCC_NUMBER); + } + MatricesAtom = XInternAtom (pDpy, XDCCC_MATRIX_ATOM_NAME, False); + XChangeProperty (pDpy, root, MatricesAtom, XA_INTEGER, 32, + PropModeReplace, (unsigned char *)Card32Array, 18); +} + + +static int +LoadCorrections(pDpy, root, pCorrection, targetFormat) + Display *pDpy; + Window root; + XDCCC_Correction *pCorrection; + int targetFormat; +{ + unsigned char *pCard8; + unsigned char *pCard8Array = (unsigned char *)NULL; + unsigned short *pCard16; + unsigned short *pCard16Array = (unsigned short *)NULL; + unsigned long *pCard32; + unsigned long *pCard32Array = (unsigned long *)NULL; + Atom CorrectAtom; + int total; + int i; + + /* + * Store each XDCCC_CORRECTION into XDCCC_LINEAR_RGB_CORRECTION property + */ + CorrectAtom = XInternAtom (pDpy, XDCCC_CORRECT_ATOM_NAME, False); + + for (i = 0; pCorrection; i++, pCorrection = pCorrection->next) { + if ((pCorrection->tableType != 0) && (pCorrection->tableType != 1)) { + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: Invalid intensity table type %d.\n", + pCorrection->visual_info.visualid, + pCorrection->tableType); + } else { + fprintf(stderr,"Global RGB Correction: Invalid intensity table type %d.\n", + pCorrection->tableType); + } + return(0); + } + + if (pCorrection->nTables != 1 && pCorrection->nTables != 3) { + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: %d invalid number of tables.\n", + pCorrection->visual_info.visualid, + pCorrection->nTables); + } else { + fprintf(stderr,"Global RGB Correction: %d invalid number of tables.\n", + pCorrection->nTables); + } + return(0); + } + + if (pCorrection->nTables == 1) { + if (pCorrection->pRedTbl->nEntries < 2) { + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: Illegal number of entries in table\n", + pCorrection->visual_info.visualid); + } else { + fprintf(stderr,"Global RGB Correction: Illegal number of entries in table\n"); + } + return (0); + } + switch (targetFormat) { + case 8: + total = 7 + (pCorrection->pRedTbl->nEntries * + (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard8 = pCard8Array = (unsigned char *) calloc (total, + sizeof (unsigned char))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard8++ = (pCorrection->visual_info.visualid >> 24) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid >> 16) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid >> 8) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid) & 0xFF; + *pCard8++ = pCorrection->tableType; /* type */ + *pCard8++ = 1; /* number of tables = 1 */ + if (pCorrection->tableType == 0) { + PutTableType0Card8(pCorrection->pRedTbl, &pCard8); + } else { + PutTableType1Card8(pCorrection->pRedTbl, &pCard8); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 8, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard8Array, total); + free(pCard8Array); + break; + case 16: + total = 5 + (pCorrection->pRedTbl->nEntries * + (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard16 = pCard16Array = (unsigned short *) calloc (total, + sizeof (unsigned short))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard16++ = (pCorrection->visual_info.visualid >> 16) & 0xFFFF; + *pCard16++ = (pCorrection->visual_info.visualid) & 0xFFFF; + *pCard16++ = pCorrection->tableType; /* type */ + *pCard16++ = 1; /* number of tables = 1 */ + if (pCorrection->tableType == 0) { + PutTableType0Card16(pCorrection->pRedTbl, &pCard16); + } else { + PutTableType1Card16(pCorrection->pRedTbl, &pCard16); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 16, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard16Array, total); + free(pCard16Array); + break; + case 32: + total = 4 + (pCorrection->pRedTbl->nEntries * + (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard32 = pCard32Array = + (unsigned long *) calloc (total, + sizeof (unsigned long))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard32++ = pCorrection->visual_info.visualid; + *pCard32++ = pCorrection->tableType; /* type */ + *pCard32++ = 1; /* number of tables = 1 */ + if (pCorrection->tableType == 0) { + PutTableType0Card32(pCorrection->pRedTbl, &pCard32); + } else { + PutTableType1Card32(pCorrection->pRedTbl, &pCard32); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 32, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard32Array, total); + free(pCard32Array); + break; + default: + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: Invalid property format\n", + pCorrection->visual_info.visualid); + } else { + fprintf(stderr,"Global RGB Correction: Invalid property format\n"); + } + return (0); + } + } else { /* pCorrection->nTables == 3 */ + if ((pCorrection->pRedTbl->nEntries < 2) || + (pCorrection->pGreenTbl->nEntries < 2) || + (pCorrection->pBlueTbl->nEntries < 2)) { + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: Illegal number of entries in table\n", + pCorrection->visual_info.visualid); + } else { + fprintf(stderr,"Global RGB Correction: Illegal number of entries in table\n"); + } + return (0); + } + switch (targetFormat) { + case 8: + total = 9 + /* visualID, type, and 3 lengths */ + (pCorrection->pRedTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pGreenTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pBlueTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard8 = pCard8Array = + (unsigned char *) calloc (total, + sizeof (unsigned char))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard8++ = (pCorrection->visual_info.visualid >> 24) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid >> 16) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid >> 8) & 0xFF; + *pCard8++ = (pCorrection->visual_info.visualid) & 0xFF; + *pCard8++ = pCorrection->tableType; /* type */ + *pCard8++ = 3; /* number of tables = 3 */ + if (pCorrection->tableType == 0) { + PutTableType0Card8(pCorrection->pRedTbl, &pCard8); + PutTableType0Card8(pCorrection->pGreenTbl, &pCard8); + PutTableType0Card8(pCorrection->pBlueTbl, &pCard8); + } else { + PutTableType1Card8(pCorrection->pRedTbl, &pCard8); + PutTableType1Card8(pCorrection->pGreenTbl, &pCard8); + PutTableType1Card8(pCorrection->pBlueTbl, &pCard8); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 8, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard8Array, total); + free(pCard8Array); + break; + case 16: + total = 7 + /* visualID, type, and 3 lengths */ + (pCorrection->pRedTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pGreenTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pBlueTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard16 = pCard16Array = + (unsigned short *) calloc (total, + sizeof (unsigned short))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard16++ = (pCorrection->visual_info.visualid >> 16) & 0xFFFF; + *pCard16++ = (pCorrection->visual_info.visualid) & 0xFFFF; + *pCard16++ = pCorrection->tableType; /* type = 0 */ + *pCard16++ = 3; /* number of tables = 3 */ + if (pCorrection->tableType == 0) { + PutTableType0Card16(pCorrection->pRedTbl, &pCard16); + PutTableType0Card16(pCorrection->pGreenTbl, &pCard16); + PutTableType0Card16(pCorrection->pBlueTbl, &pCard16); + } else { + PutTableType1Card16(pCorrection->pRedTbl, &pCard16); + PutTableType1Card16(pCorrection->pGreenTbl, &pCard16); + PutTableType1Card16(pCorrection->pBlueTbl, &pCard16); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 16, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard16Array, total); + free(pCard16Array); + break; + case 32: + total = 6 + /* visualID, type, and 3 lengths */ + (pCorrection->pRedTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pGreenTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)) + + (pCorrection->pBlueTbl->nEntries * (pCorrection->tableType == 0 ? 2 : 1)); + if ((pCard32 = pCard32Array = + (unsigned long *) calloc (total, + sizeof (unsigned long))) == NULL) { + fprintf(stderr,"Unable allocate array of ints\n"); + return (0); + } + *pCard32++ = pCorrection->visual_info.visualid; + *pCard32++ = pCorrection->tableType; /* type */ + *pCard32++ = 3; /* number of tables = 3 */ + if (pCorrection->tableType == 0) { + PutTableType0Card32(pCorrection->pRedTbl, &pCard32); + PutTableType0Card32(pCorrection->pGreenTbl, &pCard32); + PutTableType0Card32(pCorrection->pBlueTbl, &pCard32); + } else { + PutTableType1Card32(pCorrection->pRedTbl, &pCard32); + PutTableType1Card32(pCorrection->pGreenTbl, &pCard32); + PutTableType1Card32(pCorrection->pBlueTbl, &pCard32); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 32, + i ? PropModeAppend : PropModeReplace, + (unsigned char *)pCard32Array, total); + free(pCard32Array); + break; + default: + if (pCorrection->visual_info.visualid) { + fprintf(stderr,"RGB Correction for visualid %d: Invalid property format\n", + pCorrection->visual_info.visualid); + } else { + fprintf(stderr,"Global RGB Correction: Invalid property format\n"); + } + return (0); + } + } + } + + return (1); +} + +#ifdef GRAY + +static int +LoadDataGray(pDpy, root, tableType, pScreenData, targetFormat) + Display *pDpy; + Window root; + LINEAR_RGB_SCCData *pScreenData; + int targetFormat; +{ + unsigned char *ret_prop; + int count; + int nLevels; + unsigned char *pCard8; + unsigned char *pCard8Array = (unsigned char *)NULL; + unsigned short *pCard16; + unsigned short *pCard16Array = (unsigned short *)NULL; + unsigned long *pCard32; + unsigned long *pCard32Array = (unsigned long *)NULL; + unsigned long Card32Array[18]; + int ret_format; + unsigned long ret_len, ret_after; + Atom MatricesAtom, CorrectAtom, ret_atom; + XcmsFloat *pValue; + int total; + + /* Now store the XDCCC_SCREENWHITEPT */ + pCard32 = Card32Array; + pValue = (XcmsFloat *)pScreenData->XYZtoRGBmatrix; + for (count = 0; count < 3; count++) { + *pCard32++ = (unsigned long) (*pValue++ * (XcmsFloat) XDCCC_NUMBER); + } + MatricesAtom = XInternAtom (pDpy,XDCCC_SCREENWHITEPT_ATOM_NAME,False); + XChangeProperty (pDpy, root, MatricesAtom, XA_INTEGER, 32, + PropModeReplace, (unsigned char *)Card32Array, 3); + + /* Now store the XDCCC_GRAY_CORRECTION */ + CorrectAtom = XInternAtom (pDpy, XDCCC_GRAY_CORRECT_ATOM_NAME, False); + + if (tableType == CORR_TYPE_NONE) { + XGetWindowProperty (pDpy, root, CorrectAtom, + 0, 5, False, XA_INTEGER, + &ret_atom, &ret_format, &ret_len, &ret_after, + &ret_prop); + if (ret_format != 0) { + XDeleteProperty (pDpy, root, CorrectAtom); + XFree ((char *)ret_prop); + } + return (1); + } + nLevels = pScreenData->pRedTbl->nEntries; + if (nLevels < 2) { + fprintf(stderr,"Illegal number of entries in table\n"); + return (0); + } + switch (targetFormat) { + case 8: + total = 6 /* visualID, type, length */ + + (nLevels * (tableType == 0 ? 2 : 1)); + if ((pCard8 = pCard8Array = (unsigned char *) + calloc (total, sizeof (unsigned char))) == NULL) { + fprintf(stderr,"Unable allocate array of Card8\n"); + return (0); + } + *pCard8++ = 0; /* VisualID = 0 */ + *pCard8++ = 0; /* VisualID = 0 */ + *pCard8++ = 0; /* VisualID = 0 */ + *pCard8++ = 0; /* VisualID = 0 */ + *pCard8++ = tableType; /* type */ + if (tableType == 0) { + PutTableType0Card8(pScreenData->pRedTbl, &pCard8); + } else { /* tableType == 1 */ + PutTableType1Card8(pScreenData->pRedTbl, &pCard8); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 8, + PropModeReplace, (unsigned char *)pCard8Array, + total); + free (pCard8Array); + break; + case 16: + total = 4 /* visualID, type, length */ + + (nLevels * (tableType == 0 ? 2 : 1)); + if ((pCard16 = pCard16Array = (unsigned short *) + calloc (total, sizeof (unsigned short))) == NULL) { + fprintf(stderr,"Unable allocate array of Card16\n"); + return (0); + } + *pCard16++ = 0; /* VisualID = 0 */ + *pCard16++ = 0; /* VisualID = 0 */ + *pCard16++ = tableType; /* type */ + if (tableType == 0) { + PutTableType0Card16(pScreenData->pRedTbl, &pCard16); + } else { /* tableType == 1 */ + PutTableType1Card16(pScreenData->pRedTbl, &pCard16); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 16, + PropModeReplace, (unsigned char *)pCard16Array, + total); + free (pCard16Array); + break; + case 32: + total = 3 /* visualID, type, length */ + + (nLevels * (tableType == 0 ? 2 : 1)); + if ((pCard32 = pCard32Array = (unsigned long *) + calloc (total, sizeof (unsigned long))) == NULL) { + fprintf(stderr,"Unable allocate array of Card32\n"); + return (0); + } + *pCard32++ = 0; /* VisualID = 0 */ + *pCard32++ = tableType; /* type */ + if (tableType == 0) { + PutTableType0Card32(pScreenData->pRedTbl, &pCard32); + } else { /* tableType == 1 */ + PutTableType1Card32(pScreenData->pRedTbl, &pCard32); + } + XChangeProperty (pDpy, root, CorrectAtom, XA_INTEGER, 32, + PropModeReplace, (unsigned char *)pCard32Array, + total); + free (pCard32Array); + break; + default: + fprintf(stderr,"Invalid property format\n"); + return (0); + } + return (1); +} +#endif /* GRAY */ + + +static void +PrintVisualOptions(pCorrection) + XDCCC_Correction *pCorrection; +{ + if (pCorrection->visual_info_mask & VisualIDMask) { + fprintf(stderr, "\t%s:0x%x\n", + DefineToStr(VisualOptKeyTbl, KEY_VISUALID), + pCorrection->visual_info.visualid); + } + if (pCorrection->visual_info_mask & VisualDepthMask) { + fprintf(stderr, "\t%s:%d\n", + DefineToStr(VisualOptKeyTbl, KEY_DEPTH), + pCorrection->visual_info.depth); + } + if (pCorrection->visual_info_mask & VisualClassMask) { + fprintf(stderr, "\t%s:%s\n", + DefineToStr(VisualOptKeyTbl, KEY_CLASS), + DefineToStr(VisualClassTbl, pCorrection->visual_info.class)); + } + if (pCorrection->visual_info_mask & VisualRedMaskMask) { + fprintf(stderr, "\t%s:0x%x\n", + DefineToStr(VisualOptKeyTbl, KEY_RED_MASK), + pCorrection->visual_info.red_mask); + } + if (pCorrection->visual_info_mask & VisualGreenMaskMask) { + fprintf(stderr, "\t%s:0x%x\n", + DefineToStr(VisualOptKeyTbl, KEY_GREEN_MASK), + pCorrection->visual_info.green_mask); + } + if (pCorrection->visual_info_mask & VisualBlueMaskMask) { + fprintf(stderr, "\t%s:0x%x\n", + DefineToStr(VisualOptKeyTbl, KEY_BLUE_MASK), + pCorrection->visual_info.blue_mask); + } + if (pCorrection->visual_info_mask & VisualColormapSizeMask) { + fprintf(stderr, "\t%s:0x%x\n", + DefineToStr(VisualOptKeyTbl, KEY_COLORMAP_SIZE), + pCorrection->visual_info.colormap_size); + } + if (pCorrection->visual_info_mask & VisualBitsPerRGBMask) { + fprintf(stderr, "\t%s:%d\n", + DefineToStr(VisualOptKeyTbl, KEY_BITS_PER_RGB), + pCorrection->visual_info.bits_per_rgb); + } +} + + +static int +ParseVisualOptions(pDpy, pCorrection, pbuf) + Display *pDpy; + XDCCC_Correction *pCorrection; + char *pbuf; +{ + char *key; + char *value; + XVisualInfo *vinfo; + int n_matches; + char delims[8]; + + strcpy(delims, DATA_DELIMS); + strcat(delims, ":"); + pCorrection->visual_info_mask = VisualNoMask; + key = strtok(pbuf, delims); + do { + value = strtok((char*)NULL, delims); + if ((key == (char*)NULL) || (value == (char*)NULL)) { + return (0); + } + switch (StrToDefine(VisualOptKeyTbl, key)) { + case KEY_VISUALID: + if (sscanf(value, "%li", &pCorrection->visual_info.visualid) != 1) { + fprintf(stderr, + "Line %d: invalid VisualID specified, %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualIDMask; + break; + case KEY_DEPTH: + if (sscanf(value, "%i", &pCorrection->visual_info.depth) != 1) { + fprintf(stderr, + "Line %d: invalid depth specified, %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualDepthMask; + break; + case KEY_CLASS: + switch (pCorrection->visual_info.class = + StrToDefine(VisualClassTbl, value)) { + case StaticColor: + break; + case PseudoColor: + break; + case TrueColor: + break; + case DirectColor: + break; + case StaticGray: + /* invalid, fall through */ + case GrayScale: + /* invalid, fall through */ + default: + fprintf(stderr, + "Line %d: invalid Visual Class -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualClassMask; + break; + case KEY_RED_MASK: + if (sscanf(value, "%li", &pCorrection->visual_info.red_mask) != 1) { + fprintf(stderr, + "Line %d: invalid red_mask specified -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualRedMaskMask; + break; + case KEY_GREEN_MASK: + if (sscanf(value, "%li", &pCorrection->visual_info.green_mask) != 1) { + fprintf(stderr, + "Line %d: invalid green_mask specified -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualGreenMaskMask; + break; + case KEY_BLUE_MASK: + if (sscanf(value, "%li", &pCorrection->visual_info.blue_mask) != 1) { + fprintf(stderr, + "Line %d: invalid blue_mask specified -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualBlueMaskMask; + break; + case KEY_COLORMAP_SIZE: + if (sscanf(value, "%i", &pCorrection->visual_info.colormap_size) != 1) { + fprintf(stderr, + "Line %d: invalid colormap_size specified -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualColormapSizeMask; + break; + case KEY_BITS_PER_RGB: + if (sscanf(value, "%i", &pCorrection->visual_info.bits_per_rgb) != 1) { + fprintf(stderr, + "Line %d: invalid bits_per_rgb specified -- %s\n", + linenum, value); + return (0); + } + pCorrection->visual_info_mask |= VisualBitsPerRGBMask; + break; + default: + fprintf(stderr, + "Line %d: invalid keyword %s\n", linenum, key); + return (0); + } + key = strtok((char*)NULL, delims); + } while (key != (char *)NULL); + + vinfo = XGetVisualInfo(pDpy, + pCorrection->visual_info_mask, + &pCorrection->visual_info, + &n_matches); + + if (!n_matches) { + fprintf(stderr, "Line %d: Cannot find visual matching ...\n", linenum); + PrintVisualOptions(pCorrection); + fprintf(stderr, "\n"); + return(0); + } + if (n_matches > 1) { + fprintf(stderr, "Line %d: Found more than one visual matching ...\n", linenum); + PrintVisualOptions(pCorrection); + fprintf(stderr, " Using VisualId 0x%x\n", vinfo->visualid); + } + memcpy((char*)&pCorrection->visual_info, (char*)vinfo, + sizeof(XVisualInfo)); + return (1); +} + + +/************************************************************************ + * * + * PUBLIC ROUTINES * + * * + ************************************************************************/ + +/* + * NAME + * LoadSCCData - Read and store the screen data + * + * SYNOPSIS + */ +int +LoadSCCData(pDpy, screenNumber, filename, targetFormat) + Display *pDpy; + int screenNumber; + char *filename; + int targetFormat; + +/* + * DESCRIPTION + * Using the X Device Color Characterization Convention (XDCCC) + * read the screen data and store it on the root window of the + * screen. + * + * RETURNS + * Returns 0 if failed; otherwise 1. + * + */ +{ + FILE *stream; + char *pStr; + char buf[BUFSIZ]; + char *keyword, *token1, *token2, *token3; + int state = 0; + int VisualFlag = -2; + Window root; + XDCCC_Matrix matrix; + XDCCC_Correction* CorrectionTail = (XDCCC_Correction*)NULL; + XDCCC_Correction* CorrectionHead = (XDCCC_Correction*)NULL; + XDCCC_Correction* pCurrent; + + if (screenNumber < 0) { + fprintf(stderr,"Invalid Screen Number %d\n", screenNumber); + return(0); + } + root = RootWindow(pDpy, screenNumber); + + if (!root) { + /* if no root window is available then return an error */ + fprintf(stderr,"Could not open root window supplied.\n "); + return (0); + } + /* + * Open the file, determine its size, then read it into memory. + */ + if (filename == NULL) { + stream = stdin; + filename = "stdin"; + } else if ((stream = fopen(filename, "r")) == NULL) { + fprintf(stderr,"Could not open file %s.\n", filename); + return (0); + } + + /* + * Advance to starting keyword + * Anything before this keyword is just treated as comments. + */ + + while((pStr = nextline(buf, BUFSIZ, stream)) != NULL) { + keyword = strtok(buf, DATA_DELIMS); + if (keyword != (char *)NULL && + (strcmp(keyword, SC_BEGIN_KEYWORD) == 0)) { + break; + } /* else ignore the line */ + } + + if (pStr == NULL) { + fprintf(stderr,"File %s is missing %s\n", filename, SC_BEGIN_KEYWORD); + closeS (stream, CorrectionHead); + return (0); + } + + token1 = strtok((char*)NULL, DATA_DELIMS); + if ((strcmp(token1, TXT_FORMAT_VERSION) != 0) && + (strcmp(token1, "0.3") != 0)) { + fprintf(stderr, + "Screen data format version mismatch in file %s-- expected %s, found %s\n", + filename, TXT_FORMAT_VERSION, token1); + closeS (stream, CorrectionHead); + return (0); + } + + while ((pStr = nextline(buf, BUFSIZ, stream)) != NULL) { + token1 = token2 = token3 = (char*)NULL; + keyword = strtok(buf, DATA_DELIMS); + if (keyword != (char*)NULL) { + switch (SCKeyOf(keyword)) { + case COMMENT : + case NAME : + case PART_NUMBER : + case MODEL : + case SERIAL_NUMBER : + case REVISION : + /* Do nothing */ + break; + case SCREEN_CLASS : + token1 = strtok((char*)NULL, DATA_DELIMS); + token2 = strtok((char*)NULL, DATA_DELIMS); + if ((token1 == (char*)NULL) + || ((VisualFlag = SCScrnClassOf(token1)) == -1)) { + closeS (stream, CorrectionHead); + return (0); + } + /*include code to handle screen number input*/ + if (token2 != (char*)NULL) { + screenNumber = atoi(token2); + + if (screenNumber < 0) { + fprintf(stderr,"Invalid Screen Number %d\n", + screenNumber); + } + else { + root = RootWindow(pDpy, screenNumber); + if (!root) { + /* if no root window is available then return an error */ + fprintf(stderr, + "Could not open root window supplied.\n "); + return (0); + } + } + } + break; + case COLORIMETRIC_BEGIN : + if (VisualFlag == -2) { + closeS (stream, CorrectionHead); + return (0); + } + if (!ProcessColorimetric(stream, + &matrix, VisualFlag)) { + closeS (stream, CorrectionHead); + return (0); + } + state |= 0x02; + break; + case IPROFILE_BEGIN : + if (VisualFlag == -2) { + closeS (stream, CorrectionHead); + return (0); + } + token1 = strtok((char*)NULL, DATA_DELIMS); + token2 = strtok((char*)NULL, DATA_DELIMS); + if ((token1 == (char*)NULL) || (token2 == (char*)NULL)) { + fprintf(stderr, + "Line %d: Intensity profile missing TableType and/or nTables.", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + + if ((pCurrent = (XDCCC_Correction *) + calloc(1, sizeof(XDCCC_Correction))) ==NULL) { + fprintf(stderr, + "Line %d: Could not allocate memory for intensity profile.", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + + if (sscanf(token1, "%d", &pCurrent->tableType) != 1 || + (pCurrent->tableType < 0 || pCurrent->tableType > 1)) { + fprintf(stderr, + "Line %d: invalid table type specified -- %s\n", + linenum, buf); + closeS (stream, CorrectionHead); + return (0); + } + + if ((VisualFlag == VIDEO_RGB) && (token2 == (char *)NULL)) { + fprintf(stderr, + "Line %d: invalid number of tables specified -- %s\n", + linenum, buf); + closeS (stream, CorrectionHead); + return (0); + } + + if (VisualFlag == VIDEO_RGB) { + if (sscanf(token2, "%d", &pCurrent->nTables) != 1 || + (pCurrent->nTables != 0 && pCurrent->nTables != 1 + && pCurrent->nTables != 3)) { + fprintf(stderr, + "Line %d: invalid number of tables (must be 0, 1, or 3)\n", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + } else { + pCurrent->nTables = 0; + } + + token3 = strtok((char*)NULL, "\n"); + if (token3 != (char*)NULL) { + if (!ParseVisualOptions(pDpy, pCurrent, token3)) { + goto ByPassThisIProfile; + } + } + + switch (pCurrent->nTables) { + case 3 : + if (!(pCurrent->pRedTbl = (IntensityTbl *) + calloc (1, sizeof (IntensityTbl)))) { + fprintf(stderr, + "Line %d: Could not allocate Red Intensity Table\n", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + if (!(pCurrent->pGreenTbl = (IntensityTbl *) + calloc (1, sizeof (IntensityTbl)))) { + fprintf(stderr, + "Line %d: Could not allocate Green Intensity Table\n", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + if (!(pCurrent->pBlueTbl = (IntensityTbl *) + calloc (1, sizeof (IntensityTbl)))) { + fprintf(stderr, + "Line %d: Could not allocate Blue Intensity Table", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + if (!ProcessIProfile(stream, pCurrent)) { + goto ByPassThisIProfile; + } + break; + case 1 : + if (!(pCurrent->pRedTbl = (IntensityTbl *) + calloc (1, sizeof (IntensityTbl)))) { + fprintf(stderr, + "Line %d: Could not allocate Red Intensity Table", + linenum); + closeS (stream, CorrectionHead); + return (0); + } + pCurrent->pGreenTbl = pCurrent->pRedTbl; + pCurrent->pBlueTbl = pCurrent->pRedTbl; + if (!ProcessIProfile(stream, pCurrent)) { + goto ByPassThisIProfile; + } + break; + default : + /* do nothing */ + break; + } + + if (CorrectionHead == NULL) { + CorrectionHead = CorrectionTail = pCurrent; + } else { + CorrectionTail->next = pCurrent; + CorrectionTail = pCurrent; + } + state |= 0x04; + break; +ByPassThisIProfile: + /* read till INTENSITY_PROFILE_END */ + while ((pStr = nextline(buf, BUFSIZ, stream)) != NULL) { + keyword = strtok(buf, DATA_DELIMS); + if (keyword != (char*)NULL) { + switch (SCKeyOf(keyword)) { + case ITBL_BEGIN: + case ITBL_END: + case COMMENT: + case DATA: + break; + case IPROFILE_END: + goto IProfileProcessed; + default: + closeS (stream, CorrectionHead); + return (0); + } + } + } + free(pCurrent); +IProfileProcessed: + state |= 0x04; + break; + case SC_END : + if (!(state & 0x02)) { + fprintf(stderr, + "File %s is missing Colorimetric data.\n", + filename); + closeS (stream, CorrectionHead); + return (0); + } + if (!(state & 0x04)) { + fprintf(stderr, + "File %s is missing Intensity Profile Data.\n", + filename); + } + if (VisualFlag == VIDEO_RGB) { + LoadMatrix(pDpy, root, &matrix); + if (!LoadCorrections(pDpy, root, CorrectionHead, + targetFormat)) { + closeS (stream, CorrectionHead); + return (0); + } +#ifdef GRAY + } else if (VisualFlag == VIDEO_GRAY) { + if (!LoadDataGray(pDpy, root, + pCurrent->tableType, pScreenData, targetFormat)) { + closeS (stream, CorrectionHead); + return (0); + } +#endif /* GRAY */ + } else { + fprintf(stderr,"File %s Visual missing.", filename); + } + closeS (stream, CorrectionHead); + return (1); +/* NOTREACHED */ break; + default : + fprintf(stderr,"Line %d: extraneous keyword %s\n", + linenum, keyword); + closeS (stream, CorrectionHead); + return (0); + + } + } /* else it was just a blank line */ + } + closeS (stream, CorrectionHead); + return (1); +} diff --git a/xcmsdb.c b/xcmsdb.c new file mode 100644 index 0000000..441e567 --- /dev/null +++ b/xcmsdb.c @@ -0,0 +1,888 @@ +/* $Xorg: xcmsdb.c,v 1.3 2000/08/17 19:54:13 cpqbld Exp $ */ + +/* + * (c) Copyright 1990 Tektronix Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Tektronix not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + * Tektronix disclaims all warranties with regard to this software, including + * all implied warranties of merchantability and fitness, 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 performance of this + * software. + * + * + * NAME + * xcmsdb.c + * + * DESCRIPTION + * Program to load, query or remove the Screen Color + * Characterization Data from the root window of the screen. + * + */ + +/* + * INCLUDES + */ + +#include <stdio.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include <X11/Xos.h> +#include <ctype.h> + +#include "SCCDFile.h" + +static unsigned long _XcmsGetElement(); +static int _XcmsGetProperty(); + +char *ProgramName; + +void Syntax () +{ + fprintf (stderr, + "usage: %s [-options ...] [filename]\n\n", + ProgramName); + fprintf (stderr, + "where options include:\n"); + fprintf (stderr, + " -display host:dpy[.scrn] display to use\n"); + fprintf (stderr, + " -format [ 32 | 16 | 8 ] property format\n"); + fprintf (stderr, + " -query query Screen Color Characterization Data\n"); + fprintf (stderr, + " -remove remove Screen Color Characterization Data\n"); +#ifdef GRAY + fprintf (stderr, + " -color use color as default\n"); + fprintf (stderr, + " -gray use gray-scale as default\n"); +#endif /* GRAY */ + fprintf (stderr, + "\n"); + exit (1); +} + +static Bool optionmatch (opt, arg, minlen) + char *opt; + char *arg; + int minlen; +{ + int arglen; + + if (strcmp(opt, arg) == 0) { + return(True); + } + + if ((arglen = strlen(arg)) >= (int)strlen(opt) || arglen < minlen) { + return(False); + } + + if (strncmp (opt, arg, arglen) == 0) { + return(True); + } + + return(False); +} + +main (argc, argv) + int argc; + char **argv; +{ + Display *dpy; + int i; + char *displayname = NULL; + char *filename = NULL; + int query = 0; + int remove = 0; + int load = 0; + int color = -1; + int targetFormat = 32; + + ProgramName = argv[0]; + + for (i = 1; i < argc; i++) { + char *arg = argv[i]; + + if (arg[0] == '-') { + if (arg[1] == '\0') { + filename = NULL; + continue; + } else if (optionmatch ("-help", arg, 1)) { + Syntax (); + /* doesn't return */ + } else if (optionmatch ("-display", arg, 1)) { + if (++i >= argc) Syntax (); + displayname = argv[i]; + continue; + } else if (optionmatch ("-format", arg, 1)) { + if (++i >= argc) Syntax (); + targetFormat = atoi(argv[i]); + if (targetFormat != 32 && targetFormat != 16 && + targetFormat != 8) Syntax(); + continue; + } else if (optionmatch ("-query", arg, 1)) { + query = 1; + continue; + } else if (optionmatch ("-remove", arg, 1)) { + remove = 1; + continue; +#ifdef GRAY + } else if (optionmatch ("-color", arg, 1)) { + color = 1; + continue; + } else if (optionmatch ("-gray", arg, 1)) { + color = 0; + continue; +#endif /* GRAY */ + } + Syntax (); + } else { + load = 1; + filename = arg; + } + } + + /* Open display */ + if (!(dpy = XOpenDisplay (displayname))) { + fprintf (stderr, "%s: Can't open display '%s'\n", + ProgramName, XDisplayName(displayname)); + exit (1); + } + + if (load && query) { + load = 0; + } + if (load && remove) { + load = 0; + } + + if (!query && !remove) { + LoadSCCData(dpy, DefaultScreen(dpy), filename, targetFormat); + } + + if (query) { + if (color != 0) + QuerySCCDataRGB(dpy, RootWindow(dpy, DefaultScreen(dpy))); +#ifdef GRAY + if (color != 1) + QuerySCCDataGray(dpy, RootWindow(dpy, DefaultScreen(dpy))); +#endif /* GRAY */ + } + + if (remove) { + RemoveSCCData(dpy, RootWindow(dpy, DefaultScreen(dpy)), color); + } + + XCloseDisplay(dpy); + exit (0); + /*NOTREACHED*/ +} + + +Atom +ParseAtom (dpy, name, only_flag) + Display *dpy; + char *name; + int only_flag; +{ + return(XInternAtom(dpy, name, only_flag)); +} + + +/* + * NAME + * PrintTableType0 + * + * SYNOPSIS + */ +static void +PrintTableType0(format, pChar, pCount) + int format; + char **pChar; + unsigned long *pCount; +/* + * DESCRIPTION + * + * RETURNS + * XcmsFailure if failed. + * XcmsSuccess if succeeded. + * + */ +{ + unsigned int nElements; + unsigned short hValue; + XcmsFloat fValue; + + nElements = _XcmsGetElement(format, pChar, pCount) + 1; + printf ("\t length:%d\n", nElements); + + switch (format) { + case 8: + while (nElements--) { + /* 0xFFFF/0xFF = 0x101 */ + hValue = _XcmsGetElement (format, pChar, pCount) * 0x101; + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)255.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + case 16: + while (nElements--) { + hValue = _XcmsGetElement (format, pChar, pCount); + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)65535.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + case 32: + while (nElements--) { + hValue = _XcmsGetElement (format, pChar, pCount); + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)4294967295.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + default: + return; + } +} + + +/* + * NAME + * PrintTableType1 + * + * SYNOPSIS + */ +static void +PrintTableType1(format, pChar, pCount) + int format; + char **pChar; + unsigned long *pCount; +/* + * DESCRIPTION + * + * RETURNS + * XcmsFailure if failed. + * XcmsSuccess if succeeded. + * + */ +{ + int count; + unsigned int max_index; + unsigned short hValue; + XcmsFloat fValue; + + max_index = _XcmsGetElement(format, pChar, pCount); + printf ("\t length:%d\n", max_index + 1); + + switch (format) { + case 8: + for (count = 0; count < max_index+1; count++) { + hValue = (count * 65535) / max_index; + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)255.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + case 16: + for (count = 0; count < max_index+1; count++) { + hValue = (count * 65535) / max_index; + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)65535.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + case 32: + for (count = 0; count < max_index+1; count++) { + hValue = (count * 65535) / max_index; + fValue = _XcmsGetElement (format, pChar, pCount) + / (XcmsFloat)4294967295.0; + printf ("\t\t0x%x\t%8.5lf\n", hValue, fValue); + } + break; + default: + return; + } +} + + +/* + * NAME + * QuerySCCData - Query for the SCC data on the root window + * + * SYNOPSIS + */ +int +QuerySCCDataRGB(dpy, root) + Display *dpy; + Window root; +/* + * DESCRIPTION + * + * RETURNS + * None + */ +{ + char *property_return, *pChar; + int i, j; + int count, format, cType, nTables; + unsigned long nitems, nbytes_return; + Atom MatricesAtom, CorrectAtom; + VisualID visualID; + XVisualInfo vinfo_template, *vinfo_ret; + int nvis; + static char *visual_strings[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" + }; + + /* + * Get Matrices + */ + MatricesAtom = ParseAtom (dpy, XDCCC_MATRIX_ATOM_NAME, True); + if (MatricesAtom != None) { + if (_XcmsGetProperty (dpy, root, MatricesAtom, &format, &nitems, + &nbytes_return, &property_return) == XcmsFailure) { + format = 0; + } else if (nitems != 18) { + printf ("Property %s had invalid length of %d\n", + XDCCC_MATRIX_ATOM_NAME, nitems); + if (property_return) { + XFree (property_return); + } + return; + } + } + if (MatricesAtom == None || !format) { + printf ("Could not find property %s\n", XDCCC_MATRIX_ATOM_NAME); + } else if (format != 32) { + printf ("Data in property %s not in 32 bit format\n", + XDCCC_MATRIX_ATOM_NAME); + } else { + pChar = property_return; + printf ("Screen: %d\n", DefaultScreen(dpy)); + printf ("Querying property %s\n", XDCCC_MATRIX_ATOM_NAME); + printf ("\tXYZtoRGB matrix :\n"); + for (i = 0; i < 3; i++) { + printf ("\t"); + for (j = 0; j < 3; j++) { + printf ("\t%8.5lf", + (long)_XcmsGetElement(format, &pChar, &nitems) + / (XcmsFloat) XDCCC_NUMBER); + } + printf ("\n"); + } + printf ("\tRGBtoXYZ matrix :\n"); + for (i = 0; i < 3; i++) { + printf ("\t"); + for (j = 0; j < 3; j++) { + printf ("\t%8.5lf", + (long) _XcmsGetElement(format, &pChar, &nitems) + / (XcmsFloat) XDCCC_NUMBER); + } + printf ("\n"); + } + XFree (property_return); + } + + + /* + * Get Intensity Tables + */ + CorrectAtom = XInternAtom (dpy, XDCCC_CORRECT_ATOM_NAME, True); + if (CorrectAtom != None) { + if (_XcmsGetProperty (dpy, root, CorrectAtom, &format, &nitems, + &nbytes_return, &property_return) == XcmsFailure) { + format = 0; + } else if (nitems <= 0) { + printf ("Property %s had invalid length of %d\n", + XDCCC_CORRECT_ATOM_NAME, nitems); + if (property_return) { + XFree (property_return); + } + return; + } + } + if (CorrectAtom == None || !format) { + printf ("Could not find property %s\n", XDCCC_CORRECT_ATOM_NAME); + } else { + printf ("\nQuerying property %s\n", XDCCC_CORRECT_ATOM_NAME); + pChar = property_return; + + while (nitems) { + switch (format) { + case 8: + /* + * Must have at least: + * VisualID0 + * VisualID1 + * VisualID2 + * VisualID3 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 9) { + goto IntensityTblError; + } + count = 3; + break; + case 16: + /* + * Must have at least: + * VisualID0 + * VisualID3 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 7) { + goto IntensityTblError; + } + count = 1; + break; + case 32: + /* + * Must have at least: + * VisualID0 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 6) { + goto IntensityTblError; + } + count = 0; + break; + default: + goto IntensityTblError; + } + + /* + * Get VisualID + */ + visualID = _XcmsGetElement(format, &pChar, &nitems); + /* add the depth, class, and bits info in output */ + vinfo_template.visualid = visualID; + vinfo_ret = XGetVisualInfo(dpy, VisualIDMask, &vinfo_template, + &nvis); + while (count--) { + visualID = visualID << format; + visualID |= _XcmsGetElement(format, &pChar, &nitems); + } + + if (vinfo_ret != NULL) { + printf + ("\n\tVisualID: 0x%lx class: %s depth: %d bits_per_rgb: %d\n", + visualID, visual_strings[vinfo_ret->class], + vinfo_ret->depth, vinfo_ret->bits_per_rgb); + } + else + printf ("\n\tVisualID: 0x%lx\n", visualID); + XFree(vinfo_ret); + cType = _XcmsGetElement(format, &pChar, &nitems); + printf ("\ttype: %d\n", cType); + nTables = _XcmsGetElement(format, &pChar, &nitems); + printf ("\tcount: %d\n", nTables); + + switch (cType) { + case 0: + /* Red Table should always exist */ + printf ("\tRed Conversion Table:\n"); + PrintTableType0(format, &pChar, &nitems); + if (nTables > 1) { + printf ("\tGreen Conversion Table:\n"); + PrintTableType0(format, &pChar, &nitems); + printf ("\tBlue Conversion Table:\n"); + PrintTableType0(format, &pChar, &nitems); + } + break; + case 1: + /* Red Table should always exist */ + printf ("\tRed Conversion Table:\n"); + PrintTableType1(format, &pChar, &nitems); + if (nTables > 1) { + printf ("\tGreen Conversion Table:\n"); + PrintTableType1(format, &pChar, &nitems); + printf ("\tBlue Conversion Table:\n"); + PrintTableType1(format, &pChar, &nitems); + } + break; + default: + goto IntensityTblError; + } + } + XFree (property_return); + } + return; + +IntensityTblError: + XFree (property_return); + printf("Fatal error in %s property\n", XDCCC_CORRECT_ATOM_NAME); +} + + +#ifdef GRAY + +/* + * NAME + * QuerySCCDataGray - Query for the SCC data on the root window + * + * SYNOPSIS + */ +int +QuerySCCDataGray(dpy, root) + Display *dpy; + Window root; +/* + * DESCRIPTION + * + * RETURNS + * None + */ +{ + char *property_return, *pChar; + int j; + int count, format, cType; + unsigned long nitems, nbytes_return; + Atom MatricesAtom, CorrectAtom; + VisualID visualID; + + MatricesAtom = ParseAtom (dpy, XDCCC_SCREENWHITEPT_ATOM_NAME, True); + if (MatricesAtom != None) { + if (_XcmsGetProperty (dpy, root, MatricesAtom, &format, &nitems, + &nbytes_return, &property_return) == XcmsFailure) { + format = 0; + } else if (nitems != 3) { + printf ("Property %s had invalid length of %d\n", + XDCCC_SCREENWHITEPT_ATOM_NAME, nitems); + if (property_return) { + XFree (property_return); + } + return; + } + } + if (MatricesAtom == None || !format) { + printf ("Could not find property %s\n", XDCCC_SCREENWHITEPT_ATOM_NAME); + } else { + pChar = property_return; + printf ("\nQuerying property %s\n", XDCCC_SCREENWHITEPT_ATOM_NAME); + printf ("\tWhite Point XYZ :\n"); + printf ("\t"); + for (j = 0; j < 3; j++) { + printf ("\t%8.5lf", + (long) _XcmsGetElement(format, &pChar, &nitems) / + (XcmsFloat) XDCCC_NUMBER); + } + printf ("\n"); + XFree (property_return); + } + + CorrectAtom = XInternAtom (dpy, XDCCC_GRAY_CORRECT_ATOM_NAME, True); + if (CorrectAtom != None) { + if (_XcmsGetProperty (dpy, root, CorrectAtom, &format, &nitems, + &nbytes_return, &property_return) == XcmsFailure) { + format = 0; + } else if (nitems <= 0) { + printf ("Property %s had invalid length of %d\n", + XDCCC_GRAY_CORRECT_ATOM_NAME, nitems); + if (property_return) { + XFree (property_return); + } + return; + } + } + if (CorrectAtom == None || !format) { + printf ("Could not find property %s\n", XDCCC_GRAY_CORRECT_ATOM_NAME); + } else { + printf ("\nQuerying property %s\n\n", XDCCC_GRAY_CORRECT_ATOM_NAME); + pChar = property_return; + + while (nitems) { + switch (format) { + case 8: + /* + * Must have at least: + * VisualID0 + * VisualID1 + * VisualID2 + * VisualID3 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 9) { + goto IntensityTblError; + } + count = 3; + break; + case 16: + /* + * Must have at least: + * VisualID0 + * VisualID3 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 7) { + goto IntensityTblError; + } + count = 1; + break; + case 32: + /* + * Must have at least: + * VisualID0 + * type + * count + * length + * intensity1 + * intensity2 + */ + if (nitems < 6) { + goto IntensityTblError; + } + count = 0; + break; + default: + goto IntensityTblError; + break; + } + + /* + * Get VisualID + */ + visualID = _XcmsGetElement(format, &pChar, &nitems); + while (count--) { + visualID = visualID << format; + visualID |= _XcmsGetElement(format, &pChar, &nitems); + } + + printf ("\n\tVisualID: 0x%lx\n", visualID); + cType = _XcmsGetElement(format, &pChar, &nitems); + printf ("\ttype: %d\n", cType); + printf ("\tGray Conversion Table:\n"); + switch (cType) { + case 0: + PrintTableType0(format, &pChar, &nitems); + break; + case 1: + PrintTableType1(format, &pChar, &nitems); + break; + default: + goto IntensityTblError; + } + } + XFree (property_return); + } + return; +IntensityTblError: + XFree (property_return); + printf("Fatal error in %s property\n", XDCCC_CORRECT_ATOM_NAME); +} +#endif /* GRAY */ + + +/* + * NAME + * RemoveSCCData - Remove for the SCC data on the root window + * + * SYNOPSIS + */ +int +RemoveSCCData(dpy, root, colorFlag) + Display *dpy; + Window root; + int colorFlag; +/* + * DESCRIPTION + * + * RETURNS + * None + */ +{ + unsigned char *ret_prop; + unsigned long ret_len, ret_after; + int ret_format; + Atom MatricesAtom, CorrectAtom, ret_atom; + + if (colorFlag != 0) { + MatricesAtom = ParseAtom (dpy, XDCCC_MATRIX_ATOM_NAME, True); + if (MatricesAtom != None) { + XGetWindowProperty (dpy, root, MatricesAtom, 0, 8192, False, + XA_INTEGER, &ret_atom, &ret_format, &ret_len, + &ret_after, &ret_prop); + } + if (MatricesAtom == None || !ret_format) { + printf ("Could not find property %s\n", XDCCC_MATRIX_ATOM_NAME); + } else { + printf ("Deleting property %s\n", XDCCC_MATRIX_ATOM_NAME); + XDeleteProperty (dpy, root, MatricesAtom); + XFree ((char *)ret_prop); + } + + CorrectAtom = XInternAtom (dpy, XDCCC_CORRECT_ATOM_NAME, True); + if (CorrectAtom != None) { + XGetWindowProperty (dpy, root, CorrectAtom, 0, 8192, False, + XA_INTEGER, &ret_atom, &ret_format, &ret_len, + &ret_after, &ret_prop); + } + if (CorrectAtom == None || !ret_format) { + printf ("Could not find property %s\n", XDCCC_CORRECT_ATOM_NAME); + } else { + printf ("Deleting property %s\n", XDCCC_CORRECT_ATOM_NAME); + XDeleteProperty (dpy, root, CorrectAtom); + XFree ((char *)ret_prop); + } + } +#ifdef GRAY + if (colorFlag != 1) { + MatricesAtom = ParseAtom (dpy, XDCCC_SCREENWHITEPT_ATOM_NAME, True); + if (MatricesAtom != None) { + XGetWindowProperty (dpy, root, MatricesAtom, 0, 8192, False, + XA_INTEGER, &ret_atom, &ret_format, &ret_len, + &ret_after, &ret_prop); + } + if (MatricesAtom == None || !ret_format) { + printf ("Could not find property %s\n", XDCCC_SCREENWHITEPT_ATOM_NAME); + } else { + printf ("Deleting property %s\n", XDCCC_SCREENWHITEPT_ATOM_NAME); + XDeleteProperty (dpy, root, MatricesAtom); + XFree ((char *)ret_prop); + } + + CorrectAtom = XInternAtom (dpy, XDCCC_GRAY_CORRECT_ATOM_NAME, True); + if (CorrectAtom != None) { + XGetWindowProperty (dpy, root, CorrectAtom, 0, 8192, False, + XA_INTEGER, &ret_atom, &ret_format, &ret_len, + &ret_after, &ret_prop); + } + if (CorrectAtom == None || !ret_format) { + printf ("Could not find property %s\n", XDCCC_GRAY_CORRECT_ATOM_NAME); + } else { + printf ("Deleting property %s\n", XDCCC_GRAY_CORRECT_ATOM_NAME); + XDeleteProperty (dpy, root, CorrectAtom); + XFree ((char *)ret_prop); + } + } +#endif /* GRAY */ +} + +static unsigned long +_XcmsGetElement (format, pValue, pCount) + int format; + char **pValue; + unsigned long *pCount; +/* + * DESCRIPTION + * Get the next element from the property and return it. + * Also increment the pointer the amount needed. + * + * Returns + * unsigned long + */ +{ + unsigned long value; + + switch (format) { + case 32: + value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF; + *pValue += sizeof(unsigned long); + *pCount -= 1; + break; + case 16: + value = *((unsigned short *)(*pValue)); + *pValue += sizeof(unsigned short); + *pCount -= 1; + break; + case 8: + value = *((unsigned char *) (*pValue)); + *pValue += 1; + *pCount -= 1; + break; + default: + value = 0; + break; + } + return(value); +} + + +/* + * NAME + * _XcmsGetProperty -- Determine the existance of a property + * + * SYNOPSIS + */ +static int +_XcmsGetProperty (pDpy, w, property, pFormat, pNItems, pNBytes, pValue) + Display *pDpy; + Window w; + Atom property; + int *pFormat; + unsigned long *pNItems; + unsigned long *pNBytes; + char **pValue; +/* + * DESCRIPTION + * + * Returns + * 0 if property does not exist. + * 1 if property exists. + */ +{ + char *prop_ret; + int format_ret; + long len = 6516; + unsigned long nitems_ret, after_ret; + Atom atom_ret; + + while (XGetWindowProperty (pDpy, w, property, 0, len, False, + XA_INTEGER, &atom_ret, &format_ret, + &nitems_ret, &after_ret, + (unsigned char **)&prop_ret)) { + if (after_ret > 0) { + len += nitems_ret * (format_ret >> 3); + XFree (prop_ret); + } else { + break; + } + } + if (format_ret == 0 || nitems_ret == 0) { + /* the property does not exist or is of an unexpected type */ + return(XcmsFailure); + } + + *pFormat = format_ret; + *pNItems = nitems_ret; + *pNBytes = nitems_ret * (format_ret >> 3); + *pValue = prop_ret; + return(XcmsSuccess); +} diff --git a/xcmsdb.man b/xcmsdb.man new file mode 100644 index 0000000..6c7942d --- /dev/null +++ b/xcmsdb.man @@ -0,0 +1,93 @@ +.\" $Xorg: xcmsdb.man,v 1.4 2001/02/09 02:05:39 xorgcvs Exp $ +.\" Copyright 1990, Tektronix Inc. +.\" Copyright 1993, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included in +.\" all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +.\" SOFTWARE. +.\" +.\" Except as contained in this notice, the name of The Open Group shall not +.\" be used in advertising or otherwise to promote the sale, use or other +.\" dealing in this Software without prior written authorization from the +.\" The Open Group. +.TH XCMSDB 1 "Release 6.4" "X Version 11" +.SH NAME +xcmsdb \- Device Color Characterization utility for X Color Management System +.SH SYNOPSIS +.B xcmsdb +[ \fB\-query\fP ] [ \fB\-remove\fP ] +[ \fB\-format\032\fP|\fB16\fP|\fB8\fP ] +[ \fIfilename\fP ] +.SH DESCRIPTION +.I xcmsdb +is used to load, query, or remove Device Color Characterization data +stored in properties on the root window of the screen as specified +in section 7, Device Color Characterization, of the ICCCM. +Device Color Characterization data (also called the Device Profile) +is an integral part of Xlib's X Color Management System (Xcms), necessary +for proper conversion of color specification between device-independent +and device-dependent forms. +Xcms uses 3x3 matrices stored in the XDCCC_LINEAR_RGB_MATRICES property to +convert color specifications between CIEXYZ and RGB Intensity (XcmsRGBi, also +referred to as linear RGB). +Xcms then uses display gamma information stored in the +XDCCC_LINEAR_RGB_CORRECTION property to convert color specifications between +RGBi and RGB device (XcmsRGB, also referred to as device RGB). +.LP +Note that Xcms allows clients to register \fIfunction sets\fP +in addition to its +built-in function set for CRT color monitors. Additional function sets +may store their device profile information in other properties in function +set specific format. +This utility is unaware of these non-standard properties. +.LP +The ASCII readable contents of +.I filename +(or the standard input if no input file is given) +are appropriately transformed for storage in properties, provided the +.B \-query +or +.B \-remove +options are not specified. +.SH "OPTIONS" +.I xcmsdb +program accepts the following options: +.TP 8 +.B \-query +This option attempts to read the XDCCC properties off the screen's root +window. +If successful, it transforms the data into a more readable format, then +sends the data to standard out. +.TP 8 +.B \-remove +This option attempts to remove the XDCCC properties on the screen's root +window. +.TP 8 +\fB\-format\032\fP|\fB16\fP|\fB8\fP +Specifies the property format (32, 16, or 8 bits per entry) for the +XDCCC_LINEAR_RGB_CORRECTION property. +Precision of encoded floating point values increases with the increase +in bits per entry. +The default is 32 bits per entry. +.SH "SEE ALSO" +xprop(1), Xlib documentation +.SH ENVIRONMENT +.TP 8 +.B DISPLAY +to figure out which display and screen to use. +.SH AUTHOR +Chuck Adams, Tektronix Inc. +Al Tabayoyon, SynChromatics Inc. (added multi-visual support) |