Your message dated Fri, 3 Dec 2010 17:28:26 +0100 with message-id <20101203162826.GA26337@debian.org> and subject line Re: Bug#351404: bugs in Debian libx11-dev has caused the Debian Bug report #351404, regarding bugs in Debian libx11-dev to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 351404: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351404 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: bugs in Debian libx11-dev
- From: pascal.dubois6@tiscali.fr
- Date: Sat, 04 Feb 2006 17:58:08 +0100
- Message-id: <43e4dd20.slifk7sgllFDa288%postier@localhost.localdomain>
PACKAGE: libx11-dev_6.8.2.dfsg.1-7_i386.deb SUMMARY: Bugs in libX11-dev (Xcms X ColoriMetrics Spaces). This work fixes them with programs tests, patches and examples. CONTENTS: README This file. test_1.c First program test. patches_1_xcms_fixes.diff First patch. test_2.c Second program test. patches_2_xcms_fixes.diff Second patch. view_xpm.c First example. palette.c First example. xpmcielab.c Second example. glx_cms.c Third example. 65536.c Image for third example. SYSTEMS: Debian: xorg-x11_6.8.2.dfsg.1-7.diff.gz xorg-x11_6.8.2.dfsg.1-7.dsc xorg-x11_6.8.2.dfsg.1.orig.tar.gz XFree86.4.5.0 X.org X11.6.8.2 All UNIX and UNIX-LIKE systems ? COMPILATION: ggc-3.3.5 ggc-4.0.2 USAGE (STEP ONE): gcc -Wall -ansi -o test_1 test_1.c -lm -L /usr/X11R6/lib/ -lX11 -lXpm ./test_1 -display $DISPLAY (one minute with CPU 650 MHz) Click on image for exit. 17 graphics are draw to see colorimetrics spaces. TEKHVC, CIELuv, CIELab spaces are wrong. Trigonometry errors in xc/lib/X11/Xcmsint.h. Definitions of CIELab and CIELuv must be rewrite (xc/lib/X11/Lab.c and xc/lib/X11/Luv.c). Fixes with Debian: cd xorg-x11-6.8.2.dfsg.1/built-tree patch -p0 < patches_1_xcms_fixes.diff cd xc/lib/X11/ make make install cd ../../.. ./test_1 -display $DISPLAY Click on image for exit. USAGE (STEP TWO): gcc -Wall -ansi -o test_2 test_2.c -lm -L /usr/X11R6/lib/ -lX11 -lXpm ./test_2 -display $DISPLAY (ten minutes with CPU 650 MHz) Click on one image for exit. 5 graphics are draw to see limits of CIELab space. Darks limits of the space are not perfect. A colour must move in CIELab space not in RGBi space. Fixes with debian: cd xorg-x11-6.8.2.dfsg.1/built-tree/ patch -p0 < patches_2_xcms_fixes.diff cd xc/lib/X11/ make make install cd ../../.. ./test_2 -display $DISPLAY Click on image for exit. HOW-TO MAKE UNDO: cd xorg-x11-6.8.2.dfsg.1/built-tree/ patch -p0 --reverse < patches_2_xcms_fixes.diff patch -p0 --reverse < patches_1_xcms_fixes.diff cd xc/lib/X11/ make make install cd ../../.. ______________ FIRST EXAMPLE: XPIXMAP WITH PHOTO QUALITY. Use an image (anyone jpeg, png, gif, eps...). Convert this image to plain ppm with 2^48 colours: anytopnm image.anyone | pndepth 65535 | pnmtoplainpnm > image.ppm Here, it is better to install the colour characteristics of your monitor with xcmsdb program, ICCM convention or with xc/lib/X11/LRGB.c and xc/lib/X11/Xcms.txt (optional). The script palette.c reduce the number of colours in CIELab space. Here, the step between two colours is 2.0 CIELab units: gcc -ansi -Wall -o palette -L /usr/X11R6/lib -lX11 palette.c ./palette -display $DISPLAY -delta 2.0 image.ppm > image_delta2.ppm Convert now image_delta2.ppm to pixmap: ppmtoxpm image_delta2.ppm > image_delta2.xpm With ./palette, it is possible to convert any photography to pixmap. Sometimes you can use -delta 3.0, sometimes you must use -delta 1.0. To see any pixmap image: gcc -ansi -Wall -o view_xpm -L /usr/X11R6/lib -lX11 view_xpm.c ./view_xpm -display $DISPLAY -zoom 3 image_delta2.xpm ./view_xpm -display $DISPLAY -zoom 1 image_delta2.xpm _______________ SECOND EXAMPLE: XPIXMAP OEM INDEPENDENT. The script xpmcielab.c convert the pixmap with RGB colormap to pixmap with CIELab colormap and write the new image in a file controle.xpm. gcc -ansi -Wall -o xpmcielab -L /usr/X11R6/lib/ -lX11 -lm xpmcielab.c ./xpmcielab -display $DISPLAY image_delta2.xpm mv controle.xpm example.xpm The image is now OEM independent with absolute colourimetry. head example.xpm ./view_xpm -display $DISPLAY -zoom 1 example.xpm ______________ THIRD EXAMPLE: XCMS VIEW IN 3D. For this example DRI must work. gcc -ansi -Wall -o 65536 65536.c ./65536 > 65536.xpm head 65536.xpm This pixmap image has 256x256 pixels, 65536 colours. ./view_xpm -display $DISPLAY -zoom 1 65536.xpm glx_cms.c show xcms space in 3D. gcc -ansi -Wall -o glx_cms -L /usr/X11R6/lib -lGL -lm glx_cms.c ./glx_cms -display $DISPLAY -type xyY 65536.xpm ./glx_cms -display $DISPLAY -type CIELab 65536.xpm ./glx_cms -display $DISPLAY -type CIELuv 65536.xpm ./glx_cms -display $DISPLAY -type CIELab example.xpm (few seconds with CPU 650 MHz). Use up key, down key, left key or right key, ESC key for exit. ./glx_cms -display $DISPLAY -type TEK 65536.xpm (ten minutes with CPU 650 MHz). END. Thierry GILLES (France). Sorry for my english./* test_1.c * * Compilation : * cc -ansi -Wall -o test_1 -L /usr/X11R6/lib -lX11 -lm -lXpm test_1.c * Usage : * ./test_1 -display <hostname:display_number.screen_number> * * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xlib.h> #include <X11/Xcms.h> #include <math.h> #include <X11/xpm.h> int main (int argc, char *argv[]) { Display *display; XVisualInfo *visual_info, *visual_tmp; unsigned long *pixels, *rmask_return, *gmask_return, *bmask_return; int *n_item; Colormap colormap; char *font_name, *string; int a, b, v, x, y; XcmsCCC ccc; int screen, depth; float reel, L_star, a_star, b_star, u_star, v_star, V_tek, x_tek, y_tek; Window parent, window_cielab_ab, window_cielab_La, window_cielab_Lb, window_cielab_pers1, window_cielab_pers2, window_xyY; Window window_uvY, window_tek_xy, window_tek_Vx, window_tek_Vy, window_tek_pers1, window_tek_pers2; Window window_cieluv_uv, window_cieluv_Lu, window_cieluv_Lv, window_cieluv_pers1, window_cieluv_pers2; Pixmap pixmap_cielab_ab, pixmap_cielab_La, pixmap_cielab_Lb, pixmap_cielab_pers1, pixmap_cielab_pers2, pixmap_xyY; Pixmap pixmap_uvY, pixmap_tek_xy, pixmap_tek_Vx, pixmap_tek_Vy, pixmap_tek_pers1, pixmap_tek_pers2; Pixmap pixmap_cieluv_uv, pixmap_cieluv_Lu, pixmap_cieluv_Lv, pixmap_cieluv_pers1, pixmap_cieluv_pers2; XEvent event; XSetWindowAttributes attributes; GC gc; XGCValues *values; Font font; Bool *test; int **tab_cielab_ab, **tab_cielab_La, **tab_cielab_Lb, **tab_cielab_pers1, **tab_cielab_pers2, **tab_xyY; int **tab_uvY, **tab_tek_xy, **tab_tek_Vx, **tab_tek_Vy, **tab_tek_pers1, **tab_tek_pers2; int **tab_cieluv_uv, **tab_cieluv_Lu, **tab_cieluv_Lv, **tab_cieluv_pers1, **tab_cieluv_pers2; XcmsColor *white_point, *color_return, **cosmetiques; XcmsColor **monochroma_color, **limites_color; XcmsColor **color_pixel, **color_cielab, **color_xyY; XcmsColor **color_uvY, **color_tek, **color_cieluv; Status status; XpmInfo *xpminfo; XImage *image_cielab_ab, *image_cielab_La, *image_cielab_Lb, *image_cielab_pers1, *image_cielab_pers2, *image_xyY; XImage *image_uvY, *image_tek_xy, *image_tek_Vx, *image_tek_Vy, *image_tek_pers1, *image_tek_pers2; XImage *image_cieluv_uv, *image_cieluv_Lu, *image_cieluv_Lv, *image_cieluv_pers1, *image_cieluv_pers2; XpmImage *xpmimage_cielab_ab, *xpmimage_cielab_La, *xpmimage_cielab_Lb, *xpmimage_cielab_pers1, *xpmimage_cielab_pers2, *xpmimage_xyY; XpmImage *xpmimage_uvY, *xpmimage_tek_xy, *xpmimage_tek_Vx, *xpmimage_tek_Vy, *xpmimage_tek_pers1, *xpmimage_tek_pers2; XpmImage *xpmimage_cieluv_uv, *xpmimage_cieluv_Lu, *xpmimage_cieluv_Lv, *xpmimage_cieluv_pers1, *xpmimage_cieluv_pers2; unsigned int n1, n2, n3; static char *printable = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"; float monochromatic_light[401][4] = { /* monochromatics light, * Step 1 nanomètre * interpolation of Lagrange, * (XYZ color space).*/ { 380.0, 0.001368, 3.9e-05, 0.00645 }, { 381.0, 0.001421, 4.108e-05, 0.007026 }, { 382.0, 0.001539, 4.47e-05, 0.007663 }, { 383.0, 0.001718, 4.977e-05, 0.008422 }, { 384.0, 0.001952, 5.623e-05, 0.009364 }, { 385.0, 0.002236, 6.4e-05, 0.01055 }, { 386.0, 0.002537928, 7.24e-05, 0.01197768 }, { 387.0, 0.002887504, 8.212e-05, 0.01363144 }, { 388.0, 0.003286816, 9.324e-05, 0.01552136 }, { 389.0, 0.003737952, 0.00010584, 0.01765752 }, { 390.0, 0.004243, 0.00012, 0.02005 }, { 391.0, 0.004753104, 0.000134808, 0.02246696 }, { 392.0, 0.005334032, 0.000151584, 0.02522088 }, { 393.0, 0.006000608, 0.000170656, 0.02838232 }, { 394.0, 0.006767656, 0.000192352, 0.03202184 }, { 395.0, 0.00765, 0.000217, 0.03621 }, { 396.0, 0.008754816, 0.000246784, 0.04145224 }, { 397.0, 0.009981488, 0.000279712, 0.04727552 }, { 398.0, 0.011321752, 0.000315648, 0.05364168 }, { 399.0, 0.012767344, 0.000354456, 0.06051256 }, { 400.0, 0.01431, 0.000396, 0.06785 }, { 401.0, 0.01561336, 0.000431248, 0.07405072 }, { 402.0, 0.01707928, 0.000471184, 0.08103296 }, { 403.0, 0.01878152, 0.000517896, 0.08914984 }, { 404.0, 0.02079384, 0.000573472, 0.09875448 }, { 405.0, 0.02319, 0.00064, 0.1102 }, { 406.0, 0.02626328, 0.000725552, 0.1248728 }, { 407.0, 0.02981304, 0.000824736, 0.1418344 }, { 408.0, 0.03385816, 0.000938144, 0.1611796 }, { 409.0, 0.03841752, 0.001066368, 0.1830032 }, { 410.0, 0.04351, 0.00121, 0.2074 }, { 411.0, 0.0489468, 0.0013576, 0.2334456 }, { 412.0, 0.0550064, 0.0015248, 0.2625088 }, { 413.0, 0.0617596, 0.0017152, 0.2949392 }, { 414.0, 0.0692772, 0.0019324, 0.3310864 }, { 415.0, 0.07763, 0.00218, 0.3713 }, { 416.0, 0.08714064, 0.00245584, 0.4170496 }, { 417.0, 0.09756512, 0.00277072, 0.4672848 }, { 418.0, 0.10891128, 0.00312968, 0.5220752 }, { 419.0, 0.12118696, 0.00353776, 0.5814904 }, { 420.0, 0.1344, 0.004, 0.6456 }, { 421.0, 0.14970736, 0.00455696, 0.720048 }, { 422.0, 0.16568048, 0.00516928, 0.797936 }, { 423.0, 0.18203992, 0.00583312, 0.87794 }, { 424.0, 0.19850624, 0.00654464, 0.958736 }, { 425.0, 0.2148, 0.0073, 1.039 }, { 426.0, 0.2299464, 0.00808192, 1.1141472 }, { 427.0, 0.2445352, 0.00890336, 1.1869296 }, { 428.0, 0.2584608, 0.00976384, 1.2568384 }, { 429.0, 0.2716176, 0.01066288, 1.3233648 }, { 430.0, 0.2839, 0.0116, 1.386 }, { 431.0, 0.2947896, 0.01257344, 1.442296 }, { 432.0, 0.3046968, 0.01358432, 1.494168 }, { 433.0, 0.3136192, 0.01463248, 1.541592 }, { 434.0, 0.3215544, 0.01571776, 1.584544 }, { 435.0, 0.3285, 0.01684, 1.623 }, { 436.0, 0.3342904, 0.01800736, 1.65604 }, { 437.0, 0.3391272, 0.01920928, 1.68476 }, { 438.0, 0.3430488, 0.02044352, 1.70936 }, { 439.0, 0.3460936, 0.02170784, 1.73004 }, { 440.0, 0.3483, 0.023, 1.747 }, { 441.0, 0.3495944, 0.02428448, 1.759928 }, { 442.0, 0.3501552, 0.02560064, 1.769664 }, { 443.0, 0.3500488, 0.02695456, 1.776536 }, { 444.0, 0.3493416, 0.02835232, 1.780872 }, { 445.0, 0.3481, 0.0298, 1.783 }, { 446.0, 0.3464608, 0.0313152, 1.7836 }, { 447.0, 0.3444024, 0.0328896, 1.78256 }, { 448.0, 0.3419736, 0.0345264, 1.78012 }, { 449.0, 0.3392232, 0.0362288, 1.77652 }, { 450.0, 0.3362, 0.038, 1.772 }, { 451.0, 0.3333016, 0.0398496, 1.76872 }, { 452.0, 0.3301408, 0.0417728, 1.76452 }, { 453.0, 0.3266792, 0.0437712, 1.75916 }, { 454.0, 0.3228784, 0.0458464, 1.7524 }, { 455.0, 0.3187, 0.048, 1.744 }, { 456.0, 0.3139968, 0.0502432, 1.733368 }, { 457.0, 0.3088664, 0.0525656, 1.720704 }, { 458.0, 0.3032976, 0.0549664, 1.705856 }, { 459.0, 0.2972792, 0.0574448, 1.688672 }, { 460.0, 0.2908, 0.06, 1.669 }, { 461.0, 0.2839384, 0.06258704, 1.647136 }, { 462.0, 0.2765712, 0.06526032, 1.622368 }, { 463.0, 0.2686648, 0.06803008, 1.594432 }, { 464.0, 0.2601856, 0.07090656, 1.563064 }, { 465.0, 0.2511, 0.0739, 1.528 }, { 466.0, 0.2406512, 0.07701808, 1.484944 }, { 467.0, 0.2297096, 0.08027424, 1.438672 }, { 468.0, 0.2184224, 0.08367936, 1.389928 }, { 469.0, 0.2069368, 0.08724432, 1.339456 }, { 470.0, 0.1954, 0.09098, 1.288 }, { 471.0, 0.18440592, 0.09493312, 1.238544 }, { 472.0, 0.17354336, 0.09906976, 1.189032 }, { 473.0, 0.16284784, 0.10339184, 1.139648 }, { 474.0, 0.15235488, 0.10790128, 1.090576 }, { 475.0, 0.1421, 0.1126, 1.042 }, { 476.0, 0.13219904, 0.11752576, 0.9943536 }, { 477.0, 0.12258712, 0.12263568, 0.9475088 }, { 478.0, 0.11327968, 0.12792272, 0.9015872 }, { 479.0, 0.10429216, 0.13337984, 0.8567104 }, { 480.0, 0.09564, 0.139, 0.813 }, { 481.0, 0.08730504, 0.144604, 0.7706288 }, { 482.0, 0.07934472, 0.1504, 0.7296544 }, { 483.0, 0.07178288, 0.156424, 0.6901856 }, { 484.0, 0.06464336, 0.162712, 0.6523312 }, { 485.0, 0.05795, 0.1693, 0.6162 }, { 486.0, 0.05192184, 0.176256, 0.5825504 }, { 487.0, 0.04633872, 0.183576, 0.5506792 }, { 488.0, 0.04117568, 0.191288, 0.5205328 }, { 489.0, 0.03640776, 0.19942, 0.4920576 }, { 490.0, 0.03201, 0.208, 0.4652 }, { 491.0, 0.02789344, 0.2171072, 0.439964 }, { 492.0, 0.02411312, 0.2267056, 0.416224 }, { 493.0, 0.02066008, 0.2368104, 0.393912 }, { 494.0, 0.01752536, 0.2474368, 0.37296 }, { 495.0, 0.0147, 0.2586, 0.3533 }, { 496.0, 0.01214592, 0.2701808, 0.33488 }, { 497.0, 0.00989056, 0.2823624, 0.317612 }, { 498.0, 0.00793224, 0.2951936, 0.301424 }, { 499.0, 0.00626928, 0.3087232, 0.286244 }, { 500.0, 0.0049, 0.323, 0.272 }, { 501.0, 0.0037488, 0.33854, 0.258844 }, { 502.0, 0.0029064, 0.354808, 0.246424 }, { 503.0, 0.0023896, 0.371736, 0.234612 }, { 504.0, 0.0022152, 0.389256, 0.22328 }, { 505.0, 0.0024, 0.4073, 0.2123 }, { 506.0, 0.002916, 0.4255888, 0.200968 }, { 507.0, 0.003836, 0.4443184, 0.189876 }, { 508.0, 0.005188, 0.4634736, 0.17904 }, { 509.0, 0.007, 0.4830392, 0.168476 }, { 510.0, 0.0093, 0.503, 0.1582 }, { 511.0, 0.01218096, 0.5236928, 0.1481176 }, { 512.0, 0.01558968, 0.5446624, 0.1383828 }, { 513.0, 0.01953792, 0.5658056, 0.1290392 }, { 514.0, 0.02403744, 0.5870192, 0.1201304 }, { 515.0, 0.0291, 0.6082, 0.1117 }, { 516.0, 0.03485512, 0.6293184, 0.1039852 }, { 517.0, 0.04116736, 0.6501792, 0.0967876 }, { 518.0, 0.04801904, 0.6706608, 0.0901024 }, { 519.0, 0.05539248, 0.6906416, 0.0839248 }, { 520.0, 0.06327, 0.71, 0.07825 }, { 521.0, 0.07164608, 0.7279936, 0.07326328 }, { 522.0, 0.08048784, 0.7452768, 0.06872224 }, { 523.0, 0.08977456, 0.7618832, 0.06457456 }, { 524.0, 0.09948552, 0.7778464, 0.06076792 }, { 525.0, 0.1096, 0.7932, 0.05725 }, { 526.0, 0.12018304, 0.80816, 0.05385968 }, { 527.0, 0.13110672, 0.822532, 0.05068064 }, { 528.0, 0.14232888, 0.836304, 0.04768776 }, { 529.0, 0.15380736, 0.849464, 0.04485592 }, { 530.0, 0.1655, 0.862, 0.04216 }, { 531.0, 0.1771896, 0.8737848, 0.03947408 }, { 532.0, 0.1890528, 0.8849504, 0.03689904 }, { 533.0, 0.2010912, 0.8955136, 0.03443496 }, { 534.0, 0.2133064, 0.9054912, 0.03208192 }, { 535.0, 0.2257, 0.9149, 0.02984 }, { 536.0, 0.2382768, 0.923792, 0.02771408 }, { 537.0, 0.2510344, 0.93214, 0.02569824 }, { 538.0, 0.2639736, 0.939952, 0.02379136 }, { 539.0, 0.2770952, 0.947236, 0.02199232 }, { 540.0, 0.2904, 0.954, 0.0203 }, { 541.0, 0.3038984, 0.9602456, 0.01872128 }, { 542.0, 0.3175792, 0.9659888, 0.01724504 }, { 543.0, 0.3314408, 0.9712392, 0.01586816 }, { 544.0, 0.3454816, 0.9760064, 0.01458752 }, { 545.0, 0.3597, 0.9803, 0.0134 }, { 546.0, 0.3740688, 0.9841072, 0.0123092 }, { 547.0, 0.3886184, 0.9874656, 0.0113036 }, { 548.0, 0.4033536, 0.9903904, 0.0103784 }, { 549.0, 0.4182792, 0.9928968, 0.0095288 }, { 550.0, 0.4334, 0.995, 0.00875 }, { 551.0, 0.4487816, 0.9967856, 0.008034 }, { 552.0, 0.4643528, 0.9981808, 0.00738 }, { 553.0, 0.4801032, 0.9991832, 0.006784 }, { 554.0, 0.4960224, 0.9997904, 0.006242 }, { 555.0, 0.5121, 1, 0.00575 }, { 556.0, 0.5283544, 0.9998448, 0.0053024 }, { 557.0, 0.5447392, 0.9992784, 0.0048972 }, { 558.0, 0.5612368, 0.9982896, 0.0045308 }, { 559.0, 0.5778296, 0.9968672, 0.0041996 }, { 560.0, 0.5945, 0.995, 0.0039 }, { 561.0, 0.6112144, 0.9925936, 0.0036204 }, { 562.0, 0.6279752, 0.9897408, 0.0033672 }, { 563.0, 0.6447688, 0.9864512, 0.0031388 }, { 564.0, 0.6615816, 0.9827344, 0.0029336 }, { 565.0, 0.6784, 0.9786, 0.00275 }, { 566.0, 0.6952552, 0.9740896, 0.0025848 }, { 567.0, 0.7120776, 0.9691728, 0.0024384 }, { 568.0, 0.7288424, 0.9638512, 0.0023096 }, { 569.0, 0.7455248, 0.9581264, 0.0021972 }, { 570.0, 0.7621, 0.952, 0.0021 }, { 571.0, 0.7785496, 0.9454416, 0.0020184 }, { 572.0, 0.7948408, 0.9384928, 0.0019492 }, { 573.0, 0.8109472, 0.9311632, 0.0018908 }, { 574.0, 0.8268424, 0.9234624, 0.0018416 }, { 575.0, 0.8425, 0.9154, 0.0018 }, { 576.0, 0.8579448, 0.907008, 0.001766 }, { 577.0, 0.8730864, 0.898268, 0.001736 }, { 578.0, 0.8878856, 0.889184, 0.001708 }, { 579.0, 0.9023032, 0.87976, 0.00168 }, { 580.0, 0.9163, 0.87, 0.00165 }, { 581.0, 0.9297888, 0.8598376, 0.0016064 }, { 582.0, 0.9427904, 0.8493648, 0.0015592 }, { 583.0, 0.9552776, 0.8386032, 0.0015088 }, { 584.0, 0.9672232, 0.8275744, 0.0014556 }, { 585.0, 0.9786, 0.8163, 0.0014 }, { 586.0, 0.98932, 0.8047984, 0.001336 }, { 587.0, 0.999432, 0.7930952, 0.001272 }, { 588.0, 1.008924, 0.7812128, 0.00121 }, { 589.0, 1.017784, 0.7691736, 0.001152 }, { 590.0, 1.026, 0.757, 0.0011 }, { 591.0, 1.0338192, 0.744772, 0.0010736 }, { 592.0, 1.0409056, 0.73244, 0.0010528 }, { 593.0, 1.0471824, 0.720012, 0.0010352 }, { 594.0, 1.0525728, 0.707496, 0.0010184 }, { 595.0, 1.057, 0.6949, 0.001 }, { 596.0, 1.05992, 0.682216, 0.0009648 }, { 597.0, 1.06184, 0.669472, 0.0009264 }, { 598.0, 1.0628, 0.65668, 0.0008856 }, { 599.0, 1.06284, 0.643852, 0.0008432 }, { 600.0, 1.062, 0.631, 0.0008 }, { 601.0, 1.060672, 0.6181616, 0.00076192 }, { 602.0, 1.058456, 0.6053168, 0.00072336 }, { 603.0, 1.055304, 0.5924712, 0.00068384 }, { 604.0, 1.051168, 0.5796304, 0.00064288 }, { 605.0, 1.046, 0.5668, 0.0006 }, { 606.0, 1.0393872, 0.5539568, 0.00054576 }, { 607.0, 1.0317376, 0.5411424, 0.00049088 }, { 608.0, 1.0230944, 0.5283696, 0.00043712 }, { 609.0, 1.0135008, 0.5156512, 0.00038624 }, { 610.0, 1.003, 0.503, 0.00034 }, { 611.0, 0.9917376, 0.4904928, 0.00031072 }, { 612.0, 0.9796288, 0.4780624, 0.00028696 }, { 613.0, 0.9666912, 0.4657056, 0.00026784 }, { 614.0, 0.9529424, 0.4534192, 0.00025248 }, { 615.0, 0.9384, 0.4412, 0.00024 }, { 616.0, 0.9231392, 0.4290768, 0.00022888 }, { 617.0, 0.9071056, 0.4170064, 0.00021904 }, { 618.0, 0.8903024, 0.4049776, 0.00020976 }, { 619.0, 0.8727328, 0.3929792, 0.00020032 }, { 620.0, 0.8544, 0.381, 0.00019 }, { 621.0, 0.834904, 0.3688624, 0.00017264 }, { 622.0, 0.814752, 0.3567632, 0.00015432 }, { 623.0, 0.794048, 0.3447328, 0.00013568 }, { 624.0, 0.772896, 0.3328016, 0.00011736 }, { 625.0, 0.7514, 0.321, 0.0001 }, { 626.0, 0.729616, 0.309352, 8.712e-05 }, { 627.0, 0.707708, 0.297896, 7.576e-05 }, { 628.0, 0.685792, 0.286664, 6.584e-05 }, { 629.0, 0.663984, 0.275688, 5.728e-05 }, { 630.0, 0.6424, 0.265, 5e-05 }, { 631.0, 0.621684, 0.254824, 4.424e-05 }, { 632.0, 0.601292, 0.244952, 3.952e-05 }, { 633.0, 0.581208, 0.235368, 3.568e-05 }, { 634.0, 0.561416, 0.226056, 3.256e-05 }, { 635.0, 0.5419, 0.217, 3e-05 }, { 636.0, 0.5225672, 0.2081456, 2.752e-05 }, { 637.0, 0.5034976, 0.1995248, 2.536e-05 }, { 638.0, 0.4846944, 0.1911312, 2.344e-05 }, { 639.0, 0.4661608, 0.1829584, 2.168e-05 }, { 640.0, 0.4479, 0.175, 2e-05 }, { 641.0, 0.4298352, 0.1672112, 1.8e-05 }, { 642.0, 0.4120696, 0.1596336, 1.6e-05 }, { 643.0, 0.3946264, 0.1522704, 1.4e-05 }, { 644.0, 0.3775288, 0.1451248, 1.2e-05 }, { 645.0, 0.3608, 0.1382, 1e-05 }, { 646.0, 0.3444696, 0.1315056, 7.68e-06 }, { 647.0, 0.3285528, 0.1250368, 5.44e-06 }, { 648.0, 0.3130712, 0.1187952, 3.36e-06 }, { 649.0, 0.2980464, 0.1127824, 1.52e-06 }, { 650.0, 0.2835, 0.107, 0.0 }, { 651.0, 0.269588, 0.101488, -4.8e-07 }, { 652.0, 0.256164, 0.0962, -6.4e-07 }, { 653.0, 0.243216, 0.091128, -5.6e-07 }, { 654.0, 0.230732, 0.086264, -3.2e-07 }, { 655.0, 0.2187, 0.0816, 0.0 }, { 656.0, 0.2070888, 0.07711584, 0.0 }, { 657.0, 0.1959104, 0.07281872, 0.0 }, { 658.0, 0.1851576, 0.06870368, 0.0 }, { 659.0, 0.1748232, 0.06476576, 0.0 }, { 660.0, 0.1649, 0.061, 0.0 }, { 661.0, 0.1553584, 0.05739248, 0.0 }, { 662.0, 0.1462192, 0.05394944, 0.0 }, { 663.0, 0.1374808, 0.05066816, 0.0 }, { 664.0, 0.1291416, 0.04754592, 0.0 }, { 665.0, 0.1212, 0.04458, 0.0 }, { 666.0, 0.1136448, 0.04175872, 0.0 }, { 667.0, 0.1064864, 0.03909056, 0.0 }, { 668.0, 0.0997256, 0.03657504, 0.0 }, { 669.0, 0.0933632, 0.03421168, 0.0 }, { 670.0, 0.0874, 0.032, 0.0 }, { 671.0, 0.08193696, 0.02997536, 0.0 }, { 672.0, 0.07684968, 0.02809248, 0.0 }, { 673.0, 0.07211392, 0.02634192, 0.0 }, { 674.0, 0.06770544, 0.02471424, 0.0 }, { 675.0, 0.0636, 0.0232, 0.0 }, { 676.0, 0.05980472, 0.02179936, 0.0 }, { 677.0, 0.05625616, 0.02049088, 0.0 }, { 678.0, 0.05292224, 0.01926272, 0.0 }, { 679.0, 0.04977088, 0.01810304, 0.0 }, { 680.0, 0.04677, 0.017, 0.0 }, { 681.0, 0.04373648, 0.0158864, 0.0 }, { 682.0, 0.04082704, 0.0148196, 0.0 }, { 683.0, 0.03804736, 0.0138016, 0.0 }, { 684.0, 0.03540312, 0.0128344, 0.0 }, { 685.0, 0.0329, 0.01192, 0.0 }, { 686.0, 0.03057696, 0.011073104, 0.0 }, { 687.0, 0.02839808, 0.010279832, 0.0 }, { 688.0, 0.02636072, 0.009539008, 0.0 }, { 689.0, 0.02446224, 0.008849456, 0.0 }, { 690.0, 0.0227, 0.00821, 0.0 }, { 691.0, 0.02109152, 0.007626184, 0.0 }, { 692.0, 0.01960896, 0.007088432, 0.0 }, { 693.0, 0.01824464, 0.006593888, 0.0 }, { 694.0, 0.01699088, 0.006139696, 0.0 }, { 695.0, 0.01584, 0.005723, 0.0 }, { 696.0, 0.014790368, 0.005342896, 0.0 }, { 697.0, 0.013826744, 0.004994088, 0.0 }, { 698.0, 0.012939936, 0.004673232, 0.0 }, { 699.0, 0.012120752, 0.004376984, 0.0 }, { 700.0, 0.01136, 0.004102, 0.0 }, { 701.0, 0.010621416, 0.003835176, 0.0 }, { 702.0, 0.009929648, 0.003585368, 0.0 }, { 703.0, 0.009282272, 0.003351672, 0.0 }, { 704.0, 0.008676864, 0.003133184, 0.0 }, { 705.0, 0.008111, 0.002929, 0.0 }, { 706.0, 0.007581776, 0.002737928, 0.0 }, { 707.0, 0.007087368, 0.002559424, 0.0 }, { 708.0, 0.006625472, 0.002392656, 0.0 }, { 709.0, 0.006193784, 0.002236792, 0.0 }, { 710.0, 0.00579, 0.002091, 0.0 }, { 711.0, 0.005408008, 0.001953072, 0.0 }, { 712.0, 0.005050264, 0.001823896, 0.0 }, { 713.0, 0.004715416, 0.001702984, 0.0 }, { 714.0, 0.004402112, 0.001589848, 0.0 }, { 715.0, 0.004109, 0.001484, 0.0 }, { 716.0, 0.003832872, 0.00138428, 0.0 }, { 717.0, 0.003574696, 0.00129104, 0.0 }, { 718.0, 0.003333584, 0.00120396, 0.0 }, { 719.0, 0.003108648, 0.00112272, 0.0 }, { 720.0, 0.002899, 0.001047, 0.0 }, { 721.0, 0.002704008, 0.000976576, 0.0 }, { 722.0, 0.002522464, 0.000911008, 0.0 }, { 723.0, 0.002353416, 0.000849952, 0.0 }, { 724.0, 0.002195912, 0.000793064, 0.0 }, { 725.0, 0.002049, 0.00074, 0.0 }, { 726.0, 0.001910224, 0.000689872, 0.0 }, { 727.0, 0.001780512, 0.000643016, 0.0 }, { 728.0, 0.001659288, 0.000599224, 0.0 }, { 729.0, 0.001545976, 0.000558288, 0.0 }, { 730.0, 0.00144, 0.00052, 0.0 }, { 731.0, 0.001339728, 0.000483768, 0.0 }, { 732.0, 0.001245904, 0.000449864, 0.0 }, { 733.0, 0.001158216, 0.000418176, 0.0 }, { 734.0, 0.001076352, 0.000388592, 0.0 }, { 735.0, 0.001, 0.000361, 0.0 }, { 736.0, 0.000928688, 0.000335224, 0.0 }, { 737.0, 0.000862304, 0.000311232, 0.0 }, { 738.0, 0.000800576, 0.000288928, 0.0 }, { 739.0, 0.000743232, 0.000268216, 0.0 }, { 740.0, 0.00069, 0.000249, 0.0 }, { 741.0, 0.000640352, 0.00023112, 0.0 }, { 742.0, 0.000594336, 0.00021456, 0.0 }, { 743.0, 0.000551744, 0.00019924, 0.0 }, { 744.0, 0.000512368, 0.00018508, 0.0 }, { 745.0, 0.000476, 0.000172, 0.0 }, { 746.0, 0.000442336, 0.000159856, 0.0 }, { 747.0, 0.000411288, 0.000148648, 0.0 }, { 748.0, 0.000382672, 0.000138312, 0.0 }, { 749.0, 0.000356304, 0.000128784, 0.0 }, { 750.0, 0.000332, 0.00012, 0.0 }, { 751.0, 0.000309448, 0.000111864, 0.0 }, { 752.0, 0.000288624, 0.000104352, 0.0 }, { 753.0, 0.000269376, 9.7408e-05, 0.0 }, { 754.0, 0.000251552, 9.0976e-05, 0.0 }, { 755.0, 0.000235, 8.5e-05, 0.0 }, { 756.0, 0.000219216, 7.9296e-05, 0.0 }, { 757.0, 0.000204488, 7.3968e-05, 0.0 }, { 758.0, 0.000190752, 6.8992e-05, 0.0 }, { 759.0, 0.000177944, 6.4344e-05, 0.0 }, { 760.0, 0.000166, 6e-05, 0.0 }, { 761.0, 0.00015476, 5.5872e-05, 0.0 }, { 762.0, 0.00014428, 5.2016e-05, 0.0 }, { 763.0, 0.00013452, 4.8424e-05, 0.0 }, { 764.0, 0.00012544, 4.5088e-05, 0.0 }, { 765.0, 0.000117, 4.2e-05, 0.0 }, { 766.0, 0.00010916, 3.9216e-05, 0.0 }, { 767.0, 0.00010188, 3.6648e-05, 0.0 }, { 768.0, 9.512e-05, 3.4272e-05, 0.0 }, { 769.0, 8.884e-05, 3.2064e-05, 0.0 }, { 770.0, 8.3e-05, 3e-05, 0.0 }, { 771.0, 7.7496e-05, 2.796e-05, 0.0 }, { 772.0, 7.2368e-05, 2.604e-05, 0.0 }, { 773.0, 6.7592e-05, 2.424e-05, 0.0 }, { 774.0, 6.3144e-05, 2.256e-05, 0.0 }, { 775.0, 5.9e-05, 2.1e-05, 0.0 }, { 776.0, 5.512e-05, 1.953e-05, 0.0 }, { 777.0, 5.15e-05, 1.819e-05, 0.0 }, { 778.0, 4.812e-05, 1.698e-05, 0.0 }, { 779.0, 4.496e-05, 1.591e-05, 0.0 }, { 780.0, 4.2e-05, 1.5e-05, 0.0 } }; /* Open. */ if (argc < 3) { printf ("Usage :\n\t./test_1 -display <hostname:number.screen_number>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./test_1 -display <hostname:number.screen_number>.\n"); exit (1); } display = XOpenDisplay(argv[2]); if (! display) { printf("cannot open display.\n"); exit(1); } /*monochroma_color from monochromatic_light * (XYZ color space).*/ monochroma_color = malloc(401*sizeof(XcmsColor)); for (a = 0; a < 402; a++) monochroma_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { monochroma_color[a]->spec.CIEXYZ.X = monochromatic_light[a][1]; monochroma_color[a]->spec.CIEXYZ.Y = monochromatic_light[a][2]; monochroma_color[a]->spec.CIEXYZ.Z =monochromatic_light[a][3]; monochroma_color[a]->format = XcmsCIEXYZFormat; } /* Limites of colors * (RGB color space).*/ limites_color = malloc((256*12+1)*sizeof(XcmsColor)); for (a = 0; a < 3073; a++) limites_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 256; a++) { limites_color[a]->spec.RGB.red = a*257-1; limites_color[a]->spec.RGB.green = 0; limites_color[a]->spec.RGB.blue = 0; limites_color[a+256]->spec.RGB.red = 0; limites_color[a+256]->spec.RGB.green = a*257-1; limites_color[a+256]->spec.RGB.blue = 0; limites_color[a+256*2]->spec.RGB.red = 0; limites_color[a+256*2]->spec.RGB.green = 0; limites_color[a+256*2]->spec.RGB.blue = a*257-1; limites_color[a+256*3]->spec.RGB.red = 65535; limites_color[a+256*3]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*3]->spec.RGB.blue = 0; limites_color[a+256*4]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*4]->spec.RGB.green = 65535; limites_color[a+256*4]->spec.RGB.blue = 0; limites_color[a+256*5]->spec.RGB.red = 0; limites_color[a+256*5]->spec.RGB.green = 65535; limites_color[a+256*5]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.red = 0; limites_color[a+256*6]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.blue = 65535; limites_color[a+256*7]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*7]->spec.RGB.green = 0; limites_color[a+256*7]->spec.RGB.blue = 65535; limites_color[a+256*8]->spec.RGB.red = 65535; limites_color[a+256*8]->spec.RGB.green = 0; limites_color[a+256*8]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.green = 65535; limites_color[a+256*9]->spec.RGB.blue = 65535; limites_color[a+256*10]->spec.RGB.red = 65535; limites_color[a+256*10]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*10]->spec.RGB.blue = 65535; limites_color[a+256*11]->spec.RGB.red = 65535; limites_color[a+256*11]->spec.RGB.green = 65535; limites_color[a+256*11]->spec.RGB.blue = 65535-a*257-1; } for (a = 0; a < 3073; a++) limites_color[a]->format = XcmsRGBFormat; /* 4 cosmetiques */ cosmetiques = malloc(4*sizeof(XcmsColor)); for (a = 0; a < 4; a++) cosmetiques[a] = malloc(sizeof(XcmsColor)); cosmetiques[0]->spec.RGB.red = 0x7fff; cosmetiques[0]->spec.RGB.green = 0x7fff; cosmetiques[0]->spec.RGB.blue = 0x7fff; cosmetiques[0]->format = XcmsRGBFormat; cosmetiques[1]->spec.RGB.red = 0x9600; cosmetiques[1]->spec.RGB.green = 0x9600; cosmetiques[1]->spec.RGB.blue = 0x7fff; cosmetiques[1]->format = XcmsRGBFormat; cosmetiques[2]->spec.RGB.red = 0x6400; cosmetiques[2]->spec.RGB.green = 0x6400; cosmetiques[2]->spec.RGB.blue = 0x6400; cosmetiques[2]->format = XcmsRGBFormat; cosmetiques[3]->spec.RGB.red = 0x4000; cosmetiques[3]->spec.RGB.green = 0x4000; cosmetiques[3]->spec.RGB.blue = 0x4000; cosmetiques[3]->format = XcmsRGBFormat; /* Visual. */ n_item = malloc(sizeof(unsigned int)*8); visual_info = malloc(sizeof(XVisualInfo)*32); visual_tmp = malloc(sizeof(XVisualInfo)); visual_tmp->class = DirectColor; visual_info = XGetVisualInfo(display, VisualClassMask, visual_tmp, n_item); if (! visual_info) printf("cannot open \"Visual DirectColor\"\n"); XFree(visual_tmp); XFree(n_item); /* Colormap */ parent = XDefaultRootWindow(display); rmask_return = malloc(sizeof(unsigned long)*8); gmask_return = malloc(sizeof(unsigned long)*8); bmask_return = malloc(sizeof(unsigned long)*8); pixels = malloc(sizeof(unsigned long)*131070); colormap = XCreateColormap(display, parent, visual_info->visual, AllocNone); if (visual_info->depth == 8) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 3, 3, 2, rmask_return, gmask_return, bmask_return); if ((visual_info->depth == 15) | (visual_info->depth == 24)) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, visual_info->depth/3, visual_info->depth/3, visual_info->depth/3, rmask_return, gmask_return, bmask_return); if (visual_info->depth == 16) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 5, 6, 5, rmask_return, gmask_return, bmask_return); if (status == 0) printf("XAllocColorPlanes status 0\n"); ccc = XcmsCCCOfColormap(display, colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); /* Data to cielab, cieluv, TekHVC, xyY, uvY. */ test = malloc(sizeof(Bool)); color_pixel = malloc((3073+402+4)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+4; a++) color_pixel[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_pixel[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_pixel[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_pixel[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_pixel[a]->format = XcmsCIEXYZFormat; XcmsCIELabClipLab (ccc, color_pixel[a], 1, 0, test); /*VARIANTES POSSIBLES*/ XcmsCIEXYZToRGBi(ccc, color_pixel[a], 1, test); XcmsRGBiToRGB(ccc, color_pixel[a], 1, test); } for (a = 0; a < 3073; a++) { color_pixel[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_pixel[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_pixel[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_pixel[a+402]->format = XcmsRGBFormat; } for (a = 0; a < 4; a++) { color_pixel[a+402+3073]->spec.RGB.red = cosmetiques[a]->spec.RGB.red; color_pixel[a+402+3073]->spec.RGB.green = cosmetiques[a]->spec.RGB.green; color_pixel[a+402+3073]->spec.RGB.blue = cosmetiques[a]->spec.RGB.blue; color_pixel[a+402+3073]->format = XcmsRGBFormat; } for(a = 0; a < 402+3073+4; a++) { if ((visual_info->depth == 15) | (visual_info->depth == 24)) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/(65536/visual_info->colormap_size) + color_pixel[a]->spec.RGB.green/(65536/visual_info->colormap_size) *visual_info->colormap_size + color_pixel[a]->spec.RGB.red/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/2048 + color_pixel[a]->spec.RGB.green/1024*32 + color_pixel[a]->spec.RGB.red/2048*64*32; if (visual_info->depth == 8) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/16384*8*8 + color_pixel[a]->spec.RGB.green/8192*8 + color_pixel[a]->spec.RGB.red/8192; XcmsStoreColor(display, colormap, color_pixel[a]); XcmsQueryColor(display, colormap, color_pixel[a], XcmsRGBFormat); } color_cielab = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_cielab[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_cielab[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_cielab[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_cielab[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_cielab[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIELab(ccc, white_point, color_cielab[a], 1); } for (a = 0; a < 3073; a++) { color_cielab[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_cielab[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_cielab[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_cielab[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_cielab[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cielab[a+402], 1, test); XcmsCIEXYZToCIELab(ccc, white_point, color_cielab[a+402], 1); } color_xyY = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_xyY[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_xyY[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_xyY[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_xyY[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_xyY[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIExyY(ccc, white_point, color_xyY[a], 1); } for (a = 0; a < 3073; a++) { color_xyY[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_xyY[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_xyY[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_xyY[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_xyY[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_xyY[a+402], 1, test); XcmsCIEXYZToCIExyY(ccc, white_point, color_xyY[a+402], 1); } color_uvY = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_uvY[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_uvY[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_uvY[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_uvY[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_uvY[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIEuvY(ccc, white_point, color_uvY[a], 1); } for (a = 0; a < 3073; a++) { color_uvY[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_uvY[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_uvY[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_uvY[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_uvY[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_uvY[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_uvY[a+402], 1); } color_tek = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_tek[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_tek[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_tek[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_tek[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_tek[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIEuvY(ccc, white_point, color_tek[a], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_tek[a], 1); /*Go, go back and go again show the bug in xc/lib/X11/Xcmsint.h*/ XcmsTekHVCToCIEuvY(ccc, white_point, color_tek[a], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_tek[a], 1); } for (a = 0; a < 3073; a++) { color_tek[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_tek[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_tek[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_tek[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_tek[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_tek[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_tek[a+402], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_tek[a+402], 1); /*Go, go back and go again show the bug in xc/lib/X11/Xcmsint.h*/ XcmsTekHVCToCIEuvY(ccc, white_point, color_tek[a+402], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_tek[a+402], 1); } color_cieluv = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_cieluv[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_cieluv[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_cieluv[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_cieluv[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_cieluv[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIEuvY(ccc, white_point, color_cieluv[a], 1); XcmsCIEuvYToCIELuv(ccc, white_point, color_cieluv[a], 1); } for (a = 0; a < 3073; a++) { color_cieluv[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_cieluv[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_cieluv[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_cieluv[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_cieluv[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cieluv[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_cieluv[a+402], 1); XcmsCIEuvYToCIELuv(ccc, white_point, color_cieluv[a+402], 1); } /* Create pixmap.*/ screen = DefaultScreen(display); depth = visual_info->depth; pixmap_cielab_ab = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cielab_La = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cielab_Lb = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cielab_pers1 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cielab_pers2 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_xyY = XCreatePixmap(display, parent, 580, 580, depth); pixmap_uvY = XCreatePixmap(display, parent, 580, 580, depth); pixmap_tek_xy = XCreatePixmap(display, parent, 576, 576, depth); pixmap_tek_Vx = XCreatePixmap(display, parent, 576, 240, depth); pixmap_tek_Vy = XCreatePixmap(display, parent, 576, 240, depth); pixmap_tek_pers1 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_tek_pers2 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cieluv_uv = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cieluv_Lu = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cieluv_Lv = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cieluv_pers1 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cieluv_pers2 = XCreatePixmap(display, parent, 576, 576, depth); /* Create GC. */ font_name = "-adobe-times-medium-r-normal-*-12-120-75-75-p-64-iso8859-1"; font = XLoadFont(display, font_name); values = malloc(sizeof(XGCValues)); values->font = font; values->foreground = color_pixel[402+3073+0]->pixel; gc =XCreateGC(display, parent, GCFont | GCForeground, values); /* Paint pixmap. */ XFillRectangle(display, pixmap_cielab_ab, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cielab_La, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cielab_Lb, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cielab_pers1, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cielab_pers2, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_xyY, gc, 0, 0, 580, 580); XFillRectangle(display, pixmap_uvY, gc, 0, 0, 580, 580); XFillRectangle(display, pixmap_tek_xy, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_tek_Vx, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_tek_Vy, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_tek_pers1, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_tek_pers2, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cieluv_uv, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cieluv_Lu, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cieluv_Lv, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cieluv_pers1, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cieluv_pers2, gc, 0, 0, 576, 576); /* DrawLine pixmap. */ XSetForeground(display, gc, color_pixel[402+3073+1]->pixel); for (v = 1; v < 18; v++) { XDrawLine(display, pixmap_cielab_ab, gc, 576/2+16*v, 0, 576/2+16*v, 576); XDrawLine(display, pixmap_cielab_ab, gc, 576/2-16*v, 0, 576/2-16*v, 576); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2+16*v, 576, 576/2+16*v); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2-16*v, 576, 576/2-16*v); XDrawLine(display, pixmap_tek_xy, gc, 576/2+16*v, 0, 576/2+16*v, 576); XDrawLine(display, pixmap_tek_xy, gc, 576/2-16*v, 0, 576/2-16*v, 576); XDrawLine(display, pixmap_tek_xy, gc, 0, 576/2+16*v, 576, 576/2+16*v); XDrawLine(display, pixmap_tek_xy, gc, 0, 576/2-16*v, 576, 576/2-16*v); XDrawLine(display, pixmap_cieluv_uv, gc, 576/2+16*v, 0, 576/2+16*v, 576); XDrawLine(display, pixmap_cieluv_uv, gc, 576/2-16*v, 0, 576/2-16*v, 576); XDrawLine(display, pixmap_cieluv_uv, gc, 0, 576/2+16*v, 576, 576/2+16*v); XDrawLine(display, pixmap_cieluv_uv, gc, 0, 576/2-16*v, 576, 576/2-16*v); } for (v = 0; v < 11; v++) { XDrawLine(display, pixmap_cielab_La, gc, 0, 240-24*v, 576, 240-24*v); XDrawLine(display, pixmap_tek_Vx, gc, 0, 240-24*v, 576, 240-24*v); XDrawLine(display, pixmap_cieluv_Lu, gc, 0, 240-24*v, 576, 240-24*v); } for (v = 0; v < 13; v++) { XDrawLine(display, pixmap_cielab_La, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cielab_La, gc, 576/2-24*v, 0, 576/2-24*v, 240); XDrawLine(display, pixmap_tek_Vx, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_tek_Vx, gc, 576/2-24*v, 0, 576/2-24*v, 240); XDrawLine(display, pixmap_cieluv_Lu, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cieluv_Lu, gc, 576/2-24*v, 0, 576/2-24*v, 240); } for (v = 0; v < 11; v++) { XDrawLine(display, pixmap_cielab_Lb, gc, 0, 240-24*v, 576, 240-24*v); XDrawLine(display, pixmap_tek_Vy, gc, 0, 240-24*v, 576, 240-24*v); XDrawLine(display, pixmap_cieluv_Lv, gc, 0, 240-24*v, 576, 240-24*v); } for (v = 0; v < 13; v++) { XDrawLine(display, pixmap_cielab_Lb, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cielab_Lb, gc, 576/2-24*v, 0, 576/2-24*v, 240); XDrawLine(display, pixmap_tek_Vy, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_tek_Vy, gc, 576/2-24*v, 0, 576/2-24*v, 240); XDrawLine(display, pixmap_cieluv_Lv, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cieluv_Lv, gc, 576/2-24*v, 0, 576/2-24*v, 240); } for (v = 0; v < 20; v++) { XDrawLine(display, pixmap_xyY, gc, 29*v, 29*v, 29*v, 580); XDrawLine(display, pixmap_xyY, gc, 0, 29*v, 29*v, 29*v); XDrawLine(display, pixmap_xyY, gc, 0, 0, 580, 580); XDrawLine(display, pixmap_uvY, gc, 29*v, 0, 29*v, 580); XDrawLine(display, pixmap_uvY, gc, 0, 29*v, 580, 29*v); } XSetForeground(display, gc, color_pixel[402+3073+2]->pixel); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2, 576, 576/2); XDrawLine(display, pixmap_cielab_ab, gc, 576/2, 0, 576/2, 576); XDrawLine(display, pixmap_cielab_La, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_cielab_Lb, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_tek_xy, gc, 0, 576/2, 576, 576/2); XDrawLine(display, pixmap_tek_xy, gc, 576/2, 0, 576/2, 576); XDrawLine(display, pixmap_tek_Vx, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_tek_Vy, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_cieluv_uv, gc, 0, 576/2, 576, 576/2); XDrawLine(display, pixmap_cieluv_uv, gc, 576/2, 0, 576/2, 576); XDrawLine(display, pixmap_cieluv_Lu, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_cieluv_Lv, gc, 576/2, 0, 576/2, 240); /* DrawString pixmap. */ XSetForeground(display, gc, color_pixel[402+3073+3]->pixel); string = "- a*"; XDrawString(display, pixmap_cielab_ab, gc, 5, 286, string, strlen(string)); XDrawString(display, pixmap_cielab_La, gc, 5, 118, string, strlen(string)); string = "+ a*"; XDrawString(display, pixmap_cielab_ab, gc, 545, 286, string, strlen(string)); XDrawString(display, pixmap_cielab_La, gc, 545, 118, string, strlen(string)); string = "+ b*"; XDrawString(display, pixmap_cielab_ab, gc, 293, 15, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 545, 118, string, strlen(string)); string = "- b*"; XDrawString(display, pixmap_cielab_ab, gc, 293, 569, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 5, 118, string, strlen(string)); string = "L*"; XDrawString(display, pixmap_cielab_La, gc, 5, 15, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 5, 15, string, strlen(string)); string = "x"; XDrawString(display, pixmap_xyY, gc, 565, 575, string, strlen(string)); string = "y"; XDrawString(display, pixmap_xyY, gc, 5, 15, string, strlen(string)); string = "0"; XDrawString(display, pixmap_xyY, gc, 5, 575, string, strlen(string)); string = "u"; XDrawString(display, pixmap_uvY, gc, 565, 575, string, strlen(string)); string = "v"; XDrawString(display, pixmap_uvY, gc, 5, 15, string, strlen(string)); string = "0"; XDrawString(display, pixmap_uvY, gc, 5, 575, string, strlen(string)); string = "- u*"; XDrawString(display, pixmap_cieluv_uv, gc, 5, 286, string, strlen(string)); XDrawString(display, pixmap_cieluv_Lu, gc, 5, 118, string, strlen(string)); string = "+ u*"; XDrawString(display, pixmap_cieluv_uv, gc, 545, 286, string, strlen(string)); XDrawString(display, pixmap_cieluv_Lu, gc, 545, 118, string, strlen(string)); string = "+ v*"; XDrawString(display, pixmap_cieluv_uv, gc, 293, 15, string, strlen(string)); XDrawString(display, pixmap_cieluv_Lv, gc, 545, 118, string, strlen(string)); string = "- v*"; XDrawString(display, pixmap_cieluv_uv, gc, 293, 569, string, strlen(string)); XDrawString(display, pixmap_cieluv_Lv, gc, 5, 118, string, strlen(string)); string = "L*"; XDrawString(display, pixmap_cieluv_Lu, gc, 5, 15, string, strlen(string)); XDrawString(display, pixmap_cieluv_Lv, gc, 5, 15, string, strlen(string)); /* Draw. */ /* Tab of deep:*/ tab_cielab_ab = malloc(576*576*sizeof(int)); tab_cielab_La = malloc(576*240*sizeof(int)); tab_cielab_Lb = malloc(576*240*sizeof(int)); tab_cielab_pers1 = malloc(576*576*sizeof(int)); tab_cielab_pers2 = malloc(576*576*sizeof(int)); tab_xyY = malloc(580*580*sizeof(int)); tab_uvY = malloc(580*580*sizeof(int)); tab_tek_xy = malloc(576*576*sizeof(int)); tab_tek_Vx = malloc(576*240*sizeof(int)); tab_tek_Vy = malloc(576*240*sizeof(int)); tab_tek_pers1 = malloc(576*576*sizeof(int)); tab_tek_pers2 = malloc(576*576*sizeof(int)); tab_cieluv_uv = malloc(576*576*sizeof(int)); tab_cieluv_Lu = malloc(576*240*sizeof(int)); tab_cieluv_Lv = malloc(576*240*sizeof(int)); tab_cieluv_pers1 = malloc(576*576*sizeof(int)); tab_cieluv_pers2 = malloc(576*576*sizeof(int)); for (a = 0; a<576; a++) { tab_cielab_ab[a] = malloc(576*sizeof(int)); tab_cielab_La[a] = malloc(240*sizeof(int)); tab_cielab_Lb[a] = malloc(240*sizeof(int)); tab_cielab_pers1[a] = malloc(576*sizeof(int)); tab_cielab_pers2[a] = malloc(576*sizeof(int)); tab_tek_xy[a] = malloc(576*sizeof(int)); tab_tek_Vx[a] = malloc(240*sizeof(int)); tab_tek_Vy[a] = malloc(240*sizeof(int)); tab_tek_pers1[a] = malloc(576*sizeof(int)); tab_tek_pers2[a] = malloc(576*sizeof(int)); tab_cieluv_uv[a] = malloc(576*sizeof(int)); tab_cieluv_Lu[a] = malloc(240*sizeof(int)); tab_cieluv_Lv[a] = malloc(240*sizeof(int)); tab_cieluv_pers1[a] = malloc(576*sizeof(int)); tab_cieluv_pers2[a] = malloc(576*sizeof(int)); } for (a = 0; a<580; a++) { tab_xyY[a] = malloc(580*sizeof(int)); tab_uvY[a] = malloc(580*sizeof(int)); } for (a = 0; a<576; a++) { for (b = 0; b<576; b++) { tab_cielab_ab[a][b] = -1000; tab_cielab_pers1[a][b] = 10000; tab_cielab_pers2[a][b] = 10000; tab_tek_xy[a][b] = -1000; tab_tek_pers1[a][b] = 10000; tab_tek_pers2[a][b] = 10000; tab_cieluv_uv[a][b] = -1000; tab_cieluv_pers1[a][b] = 10000; tab_cieluv_pers2[a][b] = 10000; } } for (a = 0; a<576; a++) { for (b = 0; b<240; b++) { tab_cielab_La[a][b] = -1000; tab_cielab_Lb[a][b] = -1000; tab_tek_Vx[a][b] = -1000; tab_tek_Vy[a][b] = -1000; tab_cieluv_Lu[a][b] = -1000; tab_cieluv_Lv[a][b] = -1000; } } for (a = 0; a<580; a++) { for (b = 0; b<580; b++) { tab_xyY[a][b] = -1000; tab_uvY[a][b] = -1000; } } /* Draw. */ for (b = 0; b < 402+3073; b++) { XSetForeground(display, gc, color_pixel[b]->pixel); L_star = color_cielab[b]->spec.CIELab.L_star; a_star = color_cielab[b]->spec.CIELab.a_star; b_star = color_cielab[b]->spec.CIELab.b_star; x = (int) ((float) a_star*576/360+576/2); y = (int) ((float) 576-b_star*576/360-576/2); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } a = (int) L_star; if (a > tab_cielab_ab[x][y]) { tab_cielab_ab[x][y] = a; XDrawPoint(display, pixmap_cielab_ab, gc, x, y); } x = (int) ((float) a_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) b_star; if (a > tab_cielab_La[x][y]) { tab_cielab_La[x][y] = a; XDrawPoint(display, pixmap_cielab_La, gc, x, y); } x = (int) ((float) b_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) a_star; if (a > tab_cielab_Lb[x][y]) { tab_cielab_Lb[x][y] = a; XDrawPoint(display, pixmap_cielab_Lb, gc, x, y); } x = (int)((float) (1600*(a_star+200))/(b_star+1000)); y = (int)((float) 576-900-(1600*(L_star-450))/(b_star+1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((a_star+200), 2)+pow((b_star+1000), 2); a = (int) sqrt(reel); if (a < tab_cielab_pers1[x][y]) { tab_cielab_pers1[x][y] = a; XDrawPoint(display, pixmap_cielab_pers1, gc, x, y); } x = (int) ((float) (-1600*(b_star-200))/(a_star-1000)+586); y = (int) ((float) 576-900-(-1600*(L_star-450))/(a_star-1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((a_star-1000), 2)+pow((b_star-200), 2); a = (int) sqrt(reel); if (a < tab_cielab_pers2[x][y]) { tab_cielab_pers2[x][y] = a; XDrawPoint(display, pixmap_cielab_pers2, gc, x, y); } x = (int) ((float) color_xyY[b]->spec.CIExyY.x * 580); y = (int) ((float) 580-color_xyY[b]->spec.CIExyY.y * 580); if ((x < 0) | (x > 579) | (y < 0) | (y > 579)) { y = 0; x = 0; } a = (int) 1000*color_xyY[b]->spec.CIExyY.Y; if (a > tab_xyY[x][y]) { tab_xyY[x][y] = a; XDrawPoint(display, pixmap_xyY, gc, x, y); } x = (int) ((float) color_uvY[b]->spec.CIEuvY.u_prime * 580); y = (int) ((float) 580-color_uvY[b]->spec.CIEuvY.v_prime * 580); if ((x < 0) | (x > 579) | (y < 0) | (y > 579)) { y = 0; x = 0; } a = (int) 1000*color_uvY[b]->spec.CIEuvY.Y; if (a > tab_uvY[x][y]) { tab_uvY[x][y] = a; XDrawPoint(display, pixmap_uvY, gc, x, y); } V_tek = color_tek[b]->spec.TekHVC.V; x_tek = cos(color_tek[b]->spec.TekHVC.H*3.14159/180)*color_tek[b]->spec.TekHVC.C; y_tek = sin(color_tek[b]->spec.TekHVC.H*3.14159/180)*color_tek[b]->spec.TekHVC.C; x = (int) ((float) x_tek*576/360+576/2); y = (int) ((float) 576-y_tek*576/360-576/2); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } a = (int) V_tek; if (a > tab_tek_xy[x][y]) { tab_tek_xy[x][y] = a; XDrawPoint(display, pixmap_tek_xy, gc, x, y); } x = (int) ((float) x_tek*576/240+576/2); y = (int) ((float) 240-V_tek*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) y_tek; if (a > tab_tek_Vx[x][y]) { tab_tek_Vx[x][y] = a; XDrawPoint(display, pixmap_tek_Vx, gc, x, y); } x = (int) ((float) y_tek*576/240+576/2); y = (int) ((float) 240-V_tek*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) x_tek; if (a > tab_tek_Vy[x][y]) { tab_tek_Vy[x][y] = a; XDrawPoint(display, pixmap_tek_Vy, gc, x, y); } x = (int)((float) (1600*(x_tek+200))/(y_tek+1000)); y = (int)((float) 576-900-(1600*(V_tek-450))/(y_tek+1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((V_tek-450), 2)+pow((x_tek+200), 2)+pow((y_tek+1000), 2); a = (int) sqrt(reel); if (a < tab_tek_pers1[x][y]) { tab_tek_pers1[x][y] = a; XDrawPoint(display, pixmap_tek_pers1, gc, x, y); } x = (int) ((float) (-1600*(y_tek-200))/(x_tek-1000)+586); y = (int) ((float) 576-900-(-1600*(V_tek-450))/(x_tek-1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((V_tek-450), 2)+pow((x_tek-1000), 2)+pow((y_tek-200), 2); a = (int) sqrt(reel); if (a < tab_tek_pers2[x][y]) { tab_tek_pers2[x][y] = a; XDrawPoint(display, pixmap_tek_pers2, gc, x, y); } L_star = color_cieluv[b]->spec.CIELuv.L_star; u_star = color_cieluv[b]->spec.CIELuv.u_star; v_star = color_cieluv[b]->spec.CIELuv.v_star; x = (int) ((float) u_star*576/360+576/2); y = (int) ((float) 576-v_star*576/360-576/2); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } a = (int) L_star; if (a > tab_cieluv_uv[x][y]) { tab_cieluv_uv[x][y] = a; XDrawPoint(display, pixmap_cieluv_uv, gc, x, y); } x = (int) ((float) u_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) v_star; if (a > tab_cieluv_Lu[x][y]) { tab_cieluv_Lu[x][y] = a; XDrawPoint(display, pixmap_cieluv_Lu, gc, x, y); } x = (int) ((float) v_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) u_star; if (a > tab_cieluv_Lv[x][y]) { tab_cieluv_Lv[x][y] = a; XDrawPoint(display, pixmap_cieluv_Lv, gc, x, y); } x = (int)((float) (1600*(u_star+200))/(v_star+1000)); y = (int)((float) 576-900-(1600*(L_star-450))/(v_star+1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((u_star+200), 2)+pow((v_star+1000), 2); a = (int) sqrt(reel); if (a < tab_cieluv_pers1[x][y]) { tab_cieluv_pers1[x][y] = a; XDrawPoint(display, pixmap_cieluv_pers1, gc, x, y); } x = (int) ((float) (-1600*(v_star-200))/(u_star-1000)+586); y = (int) ((float) 576-900-(-1600*(L_star-450))/(u_star-1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((u_star-1000), 2)+pow((v_star-200), 2); a = (int) sqrt(reel); if (a < tab_cieluv_pers2[x][y]) { tab_cieluv_pers2[x][y] = a; XDrawPoint(display, pixmap_cieluv_pers2, gc, x, y); } } /* Create windows.*/ attributes.colormap = colormap; attributes.event_mask = ButtonPress; attributes.background_pixmap = pixmap_cieluv_Lu; window_cieluv_Lu = XCreateWindow(display, parent, 0, 0, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cieluv_Lv; window_cieluv_Lv = XCreateWindow(display, parent, 30, 10, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cieluv_pers1; window_cieluv_pers1 = XCreateWindow(display, parent, 60, 20, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cieluv_pers2; window_cieluv_pers2 = XCreateWindow(display, parent, 90, 30, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cieluv_uv; window_cieluv_uv = XCreateWindow(display, parent, 120, 40, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_tek_Vx; window_tek_Vx = XCreateWindow(display, parent, 150, 50, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_tek_Vy; window_tek_Vy = XCreateWindow(display, parent, 180, 60, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_tek_pers1; window_tek_pers1 = XCreateWindow(display, parent, 210, 70, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_tek_pers2; window_tek_pers2 = XCreateWindow(display, parent, 240, 80, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_tek_xy; window_tek_xy = XCreateWindow(display, parent, 270, 90, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_uvY; window_uvY = XCreateWindow(display, parent, 300, 100, 580, 580, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_xyY; window_xyY = XCreateWindow(display, parent, 330, 110, 580, 580, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_La; window_cielab_La = XCreateWindow(display, parent, 360, 120, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_Lb; window_cielab_Lb = XCreateWindow(display, parent, 390, 130, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_pers1; window_cielab_pers1 = XCreateWindow(display, parent, 420, 140, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_pers2; window_cielab_pers2 = XCreateWindow(display, parent, 450, 150, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_ab; window_cielab_ab = XCreateWindow(display, parent, 480, 160, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); XStoreName(display, window_cielab_ab, "cielab a* b*"); XStoreName(display, window_cielab_La, "cielab L* a*"); XStoreName(display, window_cielab_Lb, "cielab L* b*"); XStoreName(display, window_cielab_pers1, "cielab pers1"); XStoreName(display, window_cielab_pers2, "cielab pers2"); XStoreName(display, window_xyY, "xyY"); XStoreName(display, window_uvY, "uvY"); XStoreName(display, window_tek_xy, "TekHVC xy"); XStoreName(display, window_tek_Vx, "TekHVC Vx"); XStoreName(display, window_tek_Vy, "TekHVC Vy"); XStoreName(display, window_tek_pers1, "TekHVC pers1"); XStoreName(display, window_tek_pers2, "TekHvc pers2"); XStoreName(display, window_cieluv_uv, "cieluv u* v*"); XStoreName(display, window_cieluv_Lu, "cieluv L* u*"); XStoreName(display, window_cieluv_Lv, "cieluv L* v*"); XStoreName(display, window_cieluv_pers1, "cieluv pers1"); XStoreName(display, window_cieluv_pers2, "cieluv pers2"); XInstallColormap(display, colormap); XMapWindow(display, window_cieluv_Lu); XMapWindow(display, window_cieluv_Lv); XMapWindow(display, window_cieluv_pers1); XMapWindow(display, window_cieluv_pers2); XMapWindow(display, window_cieluv_uv); XMapWindow(display, window_tek_Vx); XMapWindow(display, window_tek_Vy); XMapWindow(display, window_tek_pers1); XMapWindow(display, window_tek_pers2); XMapWindow(display, window_tek_xy); XMapWindow(display, window_uvY); XMapWindow(display, window_xyY); XMapWindow(display, window_cielab_La); XMapWindow(display, window_cielab_Lb); XMapWindow(display, window_cielab_pers1); XMapWindow(display, window_cielab_pers2); XMapWindow(display, window_cielab_ab); /* Create images (xpm format).*/ image_cielab_ab = XGetImage(display, pixmap_cielab_ab, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cielab_La = XGetImage(display, pixmap_cielab_La, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cielab_Lb = XGetImage(display, pixmap_cielab_Lb, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cielab_pers1 = XGetImage(display, pixmap_cielab_pers1, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cielab_pers2 = XGetImage(display, pixmap_cielab_pers2, 0, 0, 576, 576, 0xffffff, ZPixmap); image_xyY = XGetImage(display, pixmap_xyY, 0, 0, 580, 580, 0xffffff, ZPixmap); image_uvY = XGetImage(display, pixmap_uvY, 0, 0, 580, 580, 0xffffff, ZPixmap); image_tek_xy = XGetImage(display, pixmap_tek_xy, 0, 0, 576, 576, 0xffffff, ZPixmap); image_tek_Vx = XGetImage(display, pixmap_tek_Vx, 0, 0, 576, 240, 0xffffff, ZPixmap); image_tek_Vy = XGetImage(display, pixmap_tek_Vy, 0, 0, 576, 240, 0xffffff, ZPixmap); image_tek_pers1 = XGetImage(display, pixmap_tek_pers1, 0, 0, 576, 576, 0xffffff, ZPixmap); image_tek_pers2 = XGetImage(display, pixmap_tek_pers2, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cieluv_uv = XGetImage(display, pixmap_cieluv_uv, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cieluv_Lu = XGetImage(display, pixmap_cieluv_Lu, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cieluv_Lv = XGetImage(display, pixmap_cieluv_Lv, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cieluv_pers1 = XGetImage(display, pixmap_cieluv_pers1, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cieluv_pers2 = XGetImage(display, pixmap_cieluv_pers2, 0, 0, 576, 576, 0xffffff, ZPixmap); xpmimage_cielab_ab = malloc(sizeof(XpmImage)); xpmimage_cielab_La = malloc(sizeof(XpmImage)); xpmimage_cielab_Lb = malloc(sizeof(XpmImage)); xpmimage_cielab_pers1 = malloc(sizeof(XpmImage)); xpmimage_cielab_pers2 = malloc(sizeof(XpmImage)); xpmimage_xyY = malloc(sizeof(XpmImage)); xpmimage_uvY = malloc(sizeof(XpmImage)); xpmimage_tek_xy = malloc(sizeof(XpmImage)); xpmimage_tek_Vx = malloc(sizeof(XpmImage)); xpmimage_tek_Vy = malloc(sizeof(XpmImage)); xpmimage_tek_pers1 = malloc(sizeof(XpmImage)); xpmimage_tek_pers2 = malloc(sizeof(XpmImage)); xpmimage_cieluv_uv = malloc(sizeof(XpmImage)); xpmimage_cieluv_Lu = malloc(sizeof(XpmImage)); xpmimage_cieluv_Lv = malloc(sizeof(XpmImage)); xpmimage_cieluv_pers1 = malloc(sizeof(XpmImage)); xpmimage_cieluv_pers2 = malloc(sizeof(XpmImage)); a = XpmCreateXpmImageFromImage(display, image_cielab_ab, 0, xpmimage_cielab_ab, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_ab.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_La, 0, xpmimage_cielab_La, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_La.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_Lb, 0, xpmimage_cielab_Lb, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_Lb.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_pers1, 0, xpmimage_cielab_pers1, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_pers1.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_pers2, 0, xpmimage_cielab_pers2, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_pers2.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_xyY, 0, xpmimage_xyY, NULL); if (a == XpmNoMemory) printf("xpmimage_xyY.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_uvY, 0, xpmimage_uvY, NULL); if (a == XpmNoMemory) printf("xpmimage_uvY.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_tek_xy, 0, xpmimage_tek_xy, NULL); if (a == XpmNoMemory) printf("xpmimage_tek_xy.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_tek_Vx, 0, xpmimage_tek_Vx, NULL); if (a == XpmNoMemory) printf("xpmimage_tek_Vx.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_tek_Vy, 0, xpmimage_tek_Vy, NULL); if (a == XpmNoMemory) printf("xpmimage_tek_Vy.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_tek_pers1, 0, xpmimage_tek_pers1, NULL); if (a == XpmNoMemory) printf("xpmimage_tek_pers1.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_tek_pers2, 0, xpmimage_tek_pers2, NULL); if (a == XpmNoMemory) printf("xpmimage_tek_pers2.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cieluv_uv, 0, xpmimage_cieluv_uv, NULL); if (a == XpmNoMemory) printf("xpmimage_cieluv_uv.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cieluv_Lu, 0, xpmimage_cieluv_Lu, NULL); if (a == XpmNoMemory) printf("xpmimage_cieluv_Lu.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cieluv_Lv, 0, xpmimage_cieluv_Lv, NULL); if (a == XpmNoMemory) printf("xpmimage_cieluv_Lv.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cieluv_pers1, 0, xpmimage_cieluv_pers1, NULL); if (a == XpmNoMemory) printf("xpmimage_cieluv_pers1.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cieluv_pers2, 0, xpmimage_cieluv_pers2, NULL); if (a == XpmNoMemory) printf("xpmimage_cieluv_pers2.xpm XpmNoMemory\n"); if (xpmimage_cielab_ab->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_ab->ncolors; a++) { sprintf(xpmimage_cielab_ab->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_La->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_La->ncolors; a++) { sprintf(xpmimage_cielab_La->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_Lb->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_Lb->ncolors; a++) { sprintf(xpmimage_cielab_Lb->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_pers1->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_pers1->ncolors; a++) { sprintf(xpmimage_cielab_pers1->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_pers2->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_pers2->ncolors; a++) { sprintf(xpmimage_cielab_pers2->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_xyY->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_xyY->ncolors; a++) { sprintf(xpmimage_xyY->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_uvY->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_uvY->ncolors; a++) { sprintf(xpmimage_uvY->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_tek_xy->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_tek_xy->ncolors; a++) { sprintf(xpmimage_tek_xy->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_tek_Vx->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_tek_Vx->ncolors; a++) { sprintf(xpmimage_tek_Vx->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_tek_Vy->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_tek_Vy->ncolors; a++) { sprintf(xpmimage_tek_Vy->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_tek_pers1->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_tek_pers1->ncolors; a++) { sprintf(xpmimage_tek_pers1->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_tek_pers2->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_tek_pers2->ncolors; a++) { sprintf(xpmimage_tek_pers2->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cieluv_uv->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cieluv_uv->ncolors; a++) { sprintf(xpmimage_cieluv_uv->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cieluv_Lu->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cieluv_Lu->ncolors; a++) { sprintf(xpmimage_cieluv_Lu->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cieluv_Lv->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cieluv_Lv->ncolors; a++) { sprintf(xpmimage_cieluv_Lv->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cieluv_pers1->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cieluv_pers1->ncolors; a++) { sprintf(xpmimage_cieluv_pers1->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cieluv_pers2->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cieluv_pers2->ncolors; a++) { sprintf(xpmimage_cieluv_pers2->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } xpminfo = malloc(sizeof(XpmInfo)); xpminfo->hints_cmt = " width height ncolors char_per_pixel "; xpminfo->colors_cmt = " colors "; xpminfo->pixels_cmt = " pixels "; xpminfo->valuemask = XpmComments; a = XpmWriteFileFromXpmImage("cielab_ab.xpm", xpmimage_cielab_ab, xpminfo); if (a == XpmNoMemory) printf("cielab_ab.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cielab_La.xpm", xpmimage_cielab_La, xpminfo); if (a == XpmNoMemory) printf("cielab_La.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cielab_Lb.xpm", xpmimage_cielab_Lb, xpminfo); if (a == XpmNoMemory) printf("cielab_Lb.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cielab_pers1.xpm", xpmimage_cielab_pers1, xpminfo); if (a == XpmNoMemory) printf("cielab_pers1.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cielab_pers2.xpm", xpmimage_cielab_pers2, xpminfo); if (a == XpmNoMemory) printf("cielab_pers2.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("xyY.xpm", xpmimage_xyY, xpminfo); if (a == XpmNoMemory) printf("xyY.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("uvY.xpm", xpmimage_uvY, xpminfo); if (a == XpmNoMemory) printf("uvY.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("tek_xy.xpm", xpmimage_tek_xy, xpminfo); if (a == XpmNoMemory) printf("tek_xy.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("tek_Vx.xpm", xpmimage_tek_Vx, xpminfo); if (a == XpmNoMemory) printf("tek_Vx.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("tek_Vy.xpm", xpmimage_tek_Vy, xpminfo); if (a == XpmNoMemory) printf("tek_Vy.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("tek_pers1.xpm", xpmimage_tek_pers1, xpminfo); if (a == XpmNoMemory) printf("tek_pers1.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("tek_pers2.xpm", xpmimage_tek_pers2, xpminfo); if (a == XpmNoMemory) printf("tek_pers2.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cieluv_uv.xpm", xpmimage_cieluv_uv, xpminfo); if (a == XpmNoMemory) printf("cieluv_uv.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cieluv_Lu.xpm", xpmimage_cieluv_Lu, xpminfo); if (a == XpmNoMemory) printf("cieluv_Lu.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cieluv_Lv.xpm", xpmimage_cieluv_Lv, xpminfo); if (a == XpmNoMemory) printf("cieluv_Lv.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cieluv_pers1.xpm", xpmimage_cieluv_pers1, xpminfo); if (a == XpmNoMemory) printf("cieluv_pers1.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("cieluv_pers2.xpm", xpmimage_cieluv_pers2, xpminfo); if (a == XpmNoMemory) printf("cieluv_pers2.xpm XpmNoMemory\n"); /*End.*/ while(1) { XNextEvent(display, &event); if(event.xany.type == ButtonPressMask) break; } /* Close */ XUninstallColormap(display, colormap); XUnmapWindow(display, window_cielab_ab); XUnmapWindow(display, window_cielab_La); XUnmapWindow(display, window_cielab_Lb); XUnmapWindow(display, window_cielab_pers1); XUnmapWindow(display, window_cielab_pers2); XUnmapWindow(display, window_xyY); XUnmapWindow(display, window_uvY); XUnmapWindow(display, window_tek_xy); XUnmapWindow(display, window_tek_Vx); XUnmapWindow(display, window_tek_Vy); XUnmapWindow(display, window_tek_pers1); XUnmapWindow(display, window_tek_pers2); XUnmapWindow(display, window_cieluv_uv); XUnmapWindow(display, window_cieluv_Lu); XUnmapWindow(display, window_cieluv_Lv); XUnmapWindow(display, window_cieluv_pers1); XUnmapWindow(display, window_cieluv_pers2); XFreePixmap(display, pixmap_cielab_ab); XFreePixmap(display, pixmap_cielab_La); XFreePixmap(display, pixmap_cielab_Lb); XFreePixmap(display, pixmap_cielab_pers1); XFreePixmap(display, pixmap_cielab_pers2); XFreePixmap(display, pixmap_xyY); XFreePixmap(display, pixmap_uvY); XFreePixmap(display, pixmap_tek_xy); XFreePixmap(display, pixmap_tek_Vx); XFreePixmap(display, pixmap_tek_Vy); XFreePixmap(display, pixmap_tek_pers1); XFreePixmap(display, pixmap_tek_pers2); XFreePixmap(display, pixmap_cieluv_uv); XFreePixmap(display, pixmap_cieluv_Lu); XFreePixmap(display, pixmap_cieluv_Lv); XFreePixmap(display, pixmap_cieluv_pers1); XFreePixmap(display, pixmap_cieluv_pers2); XFree(image_cielab_ab); XFree(image_cielab_La); XFree(image_cielab_Lb); XFree(image_cielab_pers1); XFree(image_cielab_pers2); XFree(image_xyY); XFree(image_uvY); XFree(image_tek_xy); XFree(image_tek_Vx); XFree(image_tek_Vy); XFree(image_tek_pers1); XFree(image_tek_pers2); XFree(image_cieluv_uv); XFree(image_cieluv_Lu); XFree(image_cieluv_Lv); XFree(image_cieluv_pers1); XFree(image_cieluv_pers2); XpmFree(xpminfo); XpmFree(xpmimage_cielab_ab); XpmFree(xpmimage_cielab_La); XpmFree(xpmimage_cielab_Lb); XpmFree(xpmimage_cielab_pers1); XpmFree(xpmimage_cielab_pers2); XpmFree(xpmimage_xyY); XpmFree(xpmimage_uvY); XpmFree(xpmimage_tek_xy); XpmFree(xpmimage_tek_Vx); XpmFree(xpmimage_tek_Vy); XpmFree(xpmimage_tek_pers1); XpmFree(xpmimage_tek_pers2); XpmFree(xpmimage_cieluv_uv); XpmFree(xpmimage_cieluv_Lu); XpmFree(xpmimage_cieluv_Lv); XpmFree(xpmimage_cieluv_pers1); XpmFree(xpmimage_cieluv_pers2); XFreeGC(display, gc); XDestroyWindow(display, window_cielab_ab); XDestroyWindow(display, window_cielab_La); XDestroyWindow(display, window_cielab_Lb); XDestroyWindow(display, window_cielab_pers1); XDestroyWindow(display, window_cielab_pers2); XDestroyWindow(display, window_xyY); XDestroyWindow(display, window_uvY); XDestroyWindow(display, window_tek_xy); XDestroyWindow(display, window_tek_Vx); XDestroyWindow(display, window_tek_Vy); XDestroyWindow(display, window_tek_pers1); XDestroyWindow(display, window_tek_pers2); XDestroyWindow(display, window_cieluv_uv); XDestroyWindow(display, window_cieluv_Lu); XDestroyWindow(display, window_cieluv_Lv); XDestroyWindow(display, window_cieluv_pers1); XDestroyWindow(display, window_cieluv_pers2); XFree(* tab_cielab_ab); XFree(* tab_cielab_La); XFree(* tab_cielab_Lb); XFree(* tab_cielab_pers1); XFree(* tab_cielab_pers2); XFree(* tab_xyY); XFree(* tab_uvY); XFree(* tab_tek_xy); XFree(* tab_tek_Vx); XFree(* tab_tek_Vy); XFree(* tab_tek_pers1); XFree(* tab_tek_pers2); XFree(* tab_cieluv_uv); XFree(* tab_cieluv_Lu); XFree(* tab_cieluv_Lv); XFree(* tab_cieluv_pers1); XFree(* tab_cieluv_pers2); XFree(* monochroma_color); XFree(* limites_color); XFree(* color_pixel); XFree(* color_cielab); XFree(* color_xyY); XFree(* color_uvY); XFree(* color_tek); XFree(* color_cieluv); XFree(white_point); XFree(color_return); XFree(values); XFree(visual_info); free(test); return 0; }patches1_xcms_fixes.diff Index: xc/lib/X11/Xcmsint.h =================================================================== --- xc.orig/lib/X11/Xcmsint.h 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/Xcmsint.h 2005-11-22 08:33:36.000000000 +0100 @@ -211,13 +211,45 @@ */ #define XCMS_ATAN(x) _XcmsArcTangent(x) -#define XCMS_COS(x) _XcmsCosine(x) +#define XCMS_COS(x) (\ + (XcmsFloat)\ + (x > 0.0)\ + ?\ + ((x<PI) ? _XcmsCosine(x) : -_XcmsCosine(x-PI))\ + :\ + ((x+PI<0.0) ? _XcmsCosine(x+2*PI) : -_XcmsCosine(x+PI))\ + ) #define XCMS_CUBEROOT(x) _XcmsCubeRoot(x) #define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x)) -#define XCMS_SIN(x) _XcmsSine(x) +#define XCMS_SIN(x) (\ + (XcmsFloat)\ + (x > 0.0)\ + ?\ + ((x<PI) ? _XcmsSine(x) : -_XcmsSine(x-PI))\ + :\ + ((x+PI<0.0) ? _XcmsSine(x+2*PI) : -_XcmsSine(x+PI))\ + ) #define XCMS_SQRT(x) _XcmsSquareRoot(x) #define XCMS_TAN(x) (XCMS_SIN(x) / XCMS_COS(x)) - +#define XCMS_ATAN2(x, y)\ + (x == 0.0)\ + ? (y>0.0 ? PI/2 : -PI/2)\ + : ( (x > 0)\ + ?(\ + (y > 0)\ + ?\ + XCMS_ATAN(x/y)\ + :\ + PI-XCMS_ATAN(x/XCMS_FABS(y))\ + )\ + :(\ + (y > 0)\ + ?\ + -XCMS_ATAN(XCMS_FABS(x)/y)\ + :\ + XCMS_ATAN(x/y)-PI\ + )\ + ) double _XcmsArcTangent(double a); double _XcmsCosine(double a); double _XcmsCubeRoot(double a); @@ -241,17 +273,10 @@ # define radians(d) ((XcmsFloat)(d) * PI / 180.0) #endif /* radians */ -#define XCMS_CIEUSTAROFHUE(h,c) \ -((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \ -((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \ -(XcmsFloat)1.0))) -#define XCMS_CIEVSTAROFHUE(h,c) \ -((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \ -((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \ -(XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0))) +#define XCMS_CIEUSTAROFHUE(h,c) XCMS_COS(h)*c +#define XCMS_CIEVSTAROFHUE(h,c) XCMS_SIN(h)*c /* this hue is returned in radians */ -#define XCMS_CIELUV_PMETRIC_HUE(u,v) \ -(((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2))) +#define XCMS_CIELUV_PMETRIC_HUE(u,v) XCMS_ATAN2(v, u) #define XCMS_CIELUV_PMETRIC_CHROMA(u,v) XCMS_SQRT(((u)*(u)) + ((v)*(v))) #define XCMS_CIEASTAROFHUE(h,c) XCMS_CIEUSTAROFHUE((h), (c)) Index: xc/lib/X11/Luv.c =================================================================== --- xc.orig/lib/X11/Luv.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/Luv.c 2005-11-22 08:24:54.000000000 +0100 @@ -282,7 +282,7 @@ uvY_return.u_prime = pLuv_WhitePt->spec.CIEuvY.u_prime; uvY_return.v_prime = pLuv_WhitePt->spec.CIEuvY.v_prime; } else { - tmpVal = 13.0 * (pColor->spec.CIELuv.L_star / 100.0); + tmpVal = 13.0 * pColor->spec.CIELuv.L_star; uvY_return.u_prime = pColor->spec.CIELuv.u_star/tmpVal + pLuv_WhitePt->spec.CIEuvY.u_prime; uvY_return.v_prime = pColor->spec.CIELuv.v_star/tmpVal + @@ -367,7 +367,7 @@ (pColor->spec.CIEuvY.Y * 903.29) : ((XcmsFloat)(XCMS_CUBEROOT(pColor->spec.CIEuvY.Y) * 116.0) - 16.0); - tmpVal = 13.0 * (Luv_return.L_star / 100.0); + tmpVal = 13.0 * Luv_return.L_star; Luv_return.u_star = tmpVal * (pColor->spec.CIEuvY.u_prime - pLuv_WhitePt->spec.CIEuvY.u_prime); Luv_return.v_star = tmpVal * Index: xc/lib/X11/Lab.c =================================================================== --- xc.orig/lib/X11/Lab.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/Lab.c 2005-11-22 08:41:33.000000000 +0100 @@ -31,10 +31,9 @@ * This file contains routines that support the CIE L*a*b* * color space to include conversions to and from the CIE * XYZ space. These conversions are from Principles of - * Color Technology Second Edition, Fred W. Billmeyer, Jr. - * and Max Saltzman, John Wiley & Sons, Inc., 1981. + * Physique de la couleur, R sève. ed Masson, Paris, 1996. * - * Note that the range for L* is 0 to 1. + * Note that the range for L* is 0 to 100. */ /* $XFree86: xc/lib/X11/Lab.c,v 1.4 2003/04/13 19:22:16 dawes Exp $ */ @@ -55,7 +54,6 @@ #else # define XMY_DBL_EPSILON 0.00001 #endif -#define DIV16BY116 0.137931 /* * FORWARD DECLARATIONS @@ -231,7 +229,7 @@ */ { XcmsCIEXYZ XYZ_return; - XcmsFloat tmpFloat, tmpL; + XcmsFloat tmpX, tmpY, tmpZ, tmpX2, tmpY2, tmpZ2; XcmsColor whitePt; int i; XcmsColor *pColor = pColors_in_out; @@ -273,31 +271,22 @@ return(XcmsFailure); } - /* Calculate Y: assume that Yn = 1.0 */ - tmpL = (pColor->spec.CIELab.L_star + 16.0) / 116.0; - XYZ_return.Y = tmpL * tmpL * tmpL; - - if (XYZ_return.Y < 0.008856) { - /* Calculate Y: assume that Yn = 1.0 */ - tmpL = pColor->spec.CIELab.L_star / 9.03292; - - /* Calculate X */ - XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X * - ((pColor->spec.CIELab.a_star / 3893.5) + tmpL); - /* Calculate Y */ - XYZ_return.Y = tmpL; - /* Calculate Z */ - XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z * - (tmpL - (pColor->spec.CIELab.b_star / 1557.4)); - } else { - /* Calculate X */ - tmpFloat = tmpL + (pColor->spec.CIELab.a_star / 5.0); - XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X * tmpFloat * tmpFloat * tmpFloat; - - /* Calculate Z */ - tmpFloat = tmpL - (pColor->spec.CIELab.b_star / 2.0); - XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z * tmpFloat * tmpFloat * tmpFloat; - } + /* Calculate X Y Z: assume that Yn = 1.0 */ + tmpX2 = pColor->spec.CIELab.a_star * 0.232 + pColor->spec.CIELab.L_star; /*116/500 = 0.232*/ + tmpY2 = pColor->spec.CIELab.L_star; + tmpZ2 = pColor->spec.CIELab.L_star - pColor->spec.CIELab.b_star * 0.580; /*116/200 =0.58*/ + tmpY = (tmpY2 + 16.0) / 116.0; + tmpX = (tmpX2 + 16.0) / 116.0; + tmpZ = (tmpZ2 + 16.0) / 116.0; + tmpX = tmpX * tmpX * tmpX; + tmpY = tmpY * tmpY * tmpY; + tmpZ = tmpZ * tmpZ * tmpZ; + if (tmpX2 < 8.0) tmpX = tmpX2 / 903.296296; + if (tmpY2 < 8.0) tmpY = tmpY2 / 903.296296; + if (tmpZ2 < 8.0) tmpZ = tmpZ2 / 903.296296; + XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X * tmpX; + XYZ_return.Y = tmpY; + XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z * tmpZ; memcpy((char *)&pColor->spec.CIEXYZ, (char *)&XYZ_return, sizeof(XcmsCIEXYZ)); @@ -334,7 +323,7 @@ */ { XcmsCIELab Lab_return; - XcmsFloat fX_Xn, fY_Yn, fZ_Zn; + XcmsFloat fX_Xn, fY_Yn, fZ_Zn, tmpX, tmpY, tmpZ; XcmsColor whitePt; int i; XcmsColor *pColor = pColors_in_out; @@ -376,33 +365,19 @@ return(XcmsFailure); } - /* Calculate L*: assume Yn = 1.0 */ - if (pColor->spec.CIEXYZ.Y < 0.008856) { - fY_Yn = (0.07787 * pColor->spec.CIEXYZ.Y) + DIV16BY116; - /* note fY_Yn used to compute Lab_return.a below */ - Lab_return.L_star = 116.0 * (fY_Yn - DIV16BY116); - } else { - fY_Yn = (XcmsFloat)XCMS_CUBEROOT(pColor->spec.CIEXYZ.Y); - /* note fY_Yn used to compute Lab_return.a_star below */ - Lab_return.L_star = (116.0 * fY_Yn) - 16.0; - } - - /* Calculate f(X/Xn) */ - if ((fX_Xn = pColor->spec.CIEXYZ.X / pLab_WhitePt->spec.CIEXYZ.X) < 0.008856) { - fX_Xn = (0.07787 * fX_Xn) + DIV16BY116; - } else { - fX_Xn = (XcmsFloat) XCMS_CUBEROOT(fX_Xn); - } - - /* Calculate f(Z/Zn) */ - if ((fZ_Zn = pColor->spec.CIEXYZ.Z / pLab_WhitePt->spec.CIEXYZ.Z) < 0.008856) { - fZ_Zn = (0.07787 * fZ_Zn) + DIV16BY116; - } else { - fZ_Zn = (XcmsFloat) XCMS_CUBEROOT(fZ_Zn); - } - - Lab_return.a_star = 5.0 * (fX_Xn - fY_Yn); - Lab_return.b_star = 2.0 * (fY_Yn - fZ_Zn); + /* Calculate L* a* b*: assume Yn = 1.0 */ + tmpX = pColor->spec.CIEXYZ.X / pLab_WhitePt->spec.CIEXYZ.X; + tmpY = pColor->spec.CIEXYZ.Y; + tmpZ = pColor->spec.CIEXYZ.Z / pLab_WhitePt->spec.CIEXYZ.Z; + fX_Xn = 116 * (XcmsFloat)XCMS_CUBEROOT(tmpX) - 16; + fY_Yn = 116 * (XcmsFloat)XCMS_CUBEROOT(tmpY) - 16; + fZ_Zn = 116 * (XcmsFloat)XCMS_CUBEROOT(tmpZ) - 16; + if (fX_Xn < 8.0) fX_Xn = tmpX * 903.296296; + if (fY_Yn < 8.0) fY_Yn = tmpY * 903.296296; + if (fZ_Zn < 8.0) fZ_Zn = tmpZ * 903.296296; + Lab_return.L_star = fY_Yn; + Lab_return.a_star = 4.31034 * (fX_Xn - fY_Yn); /* 500/116 = 4.31034*/ + Lab_return.b_star = 1.72414 * (fY_Yn - fZ_Zn); /* 200/116 = 1.72414*/ memcpy((char *)&pColor->spec.CIELab, (char *)&Lab_return, sizeof(XcmsCIELab));/* test_2.c * * Compilation : * cc -ansi -Wall -o test_2 -L /usr/X11R6/lib -lX11 -lm -lXpm test_2.c * Usage : * ./test_2 -display <hostname:display_number.screen_number> * * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xlib.h> #include <X11/Xcms.h> #include <math.h> #include <X11/xpm.h> int main (int argc, char *argv[]) { Display *display; XVisualInfo *visual_info, *visual_tmp; unsigned long *pixels, *rmask_return, *gmask_return, *bmask_return; int *n_item, chroma_int, hue_int, L_int; Colormap colormap; char *font_name, *string; int a, b, v, x, y; XcmsCCC ccc; int screen, depth, count; float reel, L_star, a_star, b_star; Window parent, window_cielab_ab, window_cielab_La, window_cielab_Lb, window_cielab_pers1, window_cielab_pers2; Pixmap pixmap_cielab_ab, pixmap_cielab_La, pixmap_cielab_Lb, pixmap_cielab_pers1, pixmap_cielab_pers2; XEvent event; XSetWindowAttributes attributes; GC gc; XGCValues *values; Font font; Bool *test; int **tab_cielab_ab, **tab_cielab_La, **tab_cielab_Lb, **tab_cielab_pers1, **tab_cielab_pers2; XcmsColor *white_point, *color_return, **cosmetiques; XcmsColor **monochroma_color, **limites_color; XcmsColor **color_pixel, **color_cielab, *color3, *color4; Status status; XpmInfo *xpminfo; XImage *image_cielab_ab, *image_cielab_La, *image_cielab_Lb, *image_cielab_pers1, *image_cielab_pers2; XpmImage *xpmimage_cielab_ab, *xpmimage_cielab_La, *xpmimage_cielab_Lb, *xpmimage_cielab_pers1, *xpmimage_cielab_pers2; unsigned int n1, n2, n3; static char *printable = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"; float monochromatic_light[401][4] = { /* monochromatics light, * Step 1 nanomètre * interpolation of Lagrange, * (XYZ color space).*/ { 380.0, 0.001368, 3.9e-05, 0.00645 }, { 381.0, 0.001421, 4.108e-05, 0.007026 }, { 382.0, 0.001539, 4.47e-05, 0.007663 }, { 383.0, 0.001718, 4.977e-05, 0.008422 }, { 384.0, 0.001952, 5.623e-05, 0.009364 }, { 385.0, 0.002236, 6.4e-05, 0.01055 }, { 386.0, 0.002537928, 7.24e-05, 0.01197768 }, { 387.0, 0.002887504, 8.212e-05, 0.01363144 }, { 388.0, 0.003286816, 9.324e-05, 0.01552136 }, { 389.0, 0.003737952, 0.00010584, 0.01765752 }, { 390.0, 0.004243, 0.00012, 0.02005 }, { 391.0, 0.004753104, 0.000134808, 0.02246696 }, { 392.0, 0.005334032, 0.000151584, 0.02522088 }, { 393.0, 0.006000608, 0.000170656, 0.02838232 }, { 394.0, 0.006767656, 0.000192352, 0.03202184 }, { 395.0, 0.00765, 0.000217, 0.03621 }, { 396.0, 0.008754816, 0.000246784, 0.04145224 }, { 397.0, 0.009981488, 0.000279712, 0.04727552 }, { 398.0, 0.011321752, 0.000315648, 0.05364168 }, { 399.0, 0.012767344, 0.000354456, 0.06051256 }, { 400.0, 0.01431, 0.000396, 0.06785 }, { 401.0, 0.01561336, 0.000431248, 0.07405072 }, { 402.0, 0.01707928, 0.000471184, 0.08103296 }, { 403.0, 0.01878152, 0.000517896, 0.08914984 }, { 404.0, 0.02079384, 0.000573472, 0.09875448 }, { 405.0, 0.02319, 0.00064, 0.1102 }, { 406.0, 0.02626328, 0.000725552, 0.1248728 }, { 407.0, 0.02981304, 0.000824736, 0.1418344 }, { 408.0, 0.03385816, 0.000938144, 0.1611796 }, { 409.0, 0.03841752, 0.001066368, 0.1830032 }, { 410.0, 0.04351, 0.00121, 0.2074 }, { 411.0, 0.0489468, 0.0013576, 0.2334456 }, { 412.0, 0.0550064, 0.0015248, 0.2625088 }, { 413.0, 0.0617596, 0.0017152, 0.2949392 }, { 414.0, 0.0692772, 0.0019324, 0.3310864 }, { 415.0, 0.07763, 0.00218, 0.3713 }, { 416.0, 0.08714064, 0.00245584, 0.4170496 }, { 417.0, 0.09756512, 0.00277072, 0.4672848 }, { 418.0, 0.10891128, 0.00312968, 0.5220752 }, { 419.0, 0.12118696, 0.00353776, 0.5814904 }, { 420.0, 0.1344, 0.004, 0.6456 }, { 421.0, 0.14970736, 0.00455696, 0.720048 }, { 422.0, 0.16568048, 0.00516928, 0.797936 }, { 423.0, 0.18203992, 0.00583312, 0.87794 }, { 424.0, 0.19850624, 0.00654464, 0.958736 }, { 425.0, 0.2148, 0.0073, 1.039 }, { 426.0, 0.2299464, 0.00808192, 1.1141472 }, { 427.0, 0.2445352, 0.00890336, 1.1869296 }, { 428.0, 0.2584608, 0.00976384, 1.2568384 }, { 429.0, 0.2716176, 0.01066288, 1.3233648 }, { 430.0, 0.2839, 0.0116, 1.386 }, { 431.0, 0.2947896, 0.01257344, 1.442296 }, { 432.0, 0.3046968, 0.01358432, 1.494168 }, { 433.0, 0.3136192, 0.01463248, 1.541592 }, { 434.0, 0.3215544, 0.01571776, 1.584544 }, { 435.0, 0.3285, 0.01684, 1.623 }, { 436.0, 0.3342904, 0.01800736, 1.65604 }, { 437.0, 0.3391272, 0.01920928, 1.68476 }, { 438.0, 0.3430488, 0.02044352, 1.70936 }, { 439.0, 0.3460936, 0.02170784, 1.73004 }, { 440.0, 0.3483, 0.023, 1.747 }, { 441.0, 0.3495944, 0.02428448, 1.759928 }, { 442.0, 0.3501552, 0.02560064, 1.769664 }, { 443.0, 0.3500488, 0.02695456, 1.776536 }, { 444.0, 0.3493416, 0.02835232, 1.780872 }, { 445.0, 0.3481, 0.0298, 1.783 }, { 446.0, 0.3464608, 0.0313152, 1.7836 }, { 447.0, 0.3444024, 0.0328896, 1.78256 }, { 448.0, 0.3419736, 0.0345264, 1.78012 }, { 449.0, 0.3392232, 0.0362288, 1.77652 }, { 450.0, 0.3362, 0.038, 1.772 }, { 451.0, 0.3333016, 0.0398496, 1.76872 }, { 452.0, 0.3301408, 0.0417728, 1.76452 }, { 453.0, 0.3266792, 0.0437712, 1.75916 }, { 454.0, 0.3228784, 0.0458464, 1.7524 }, { 455.0, 0.3187, 0.048, 1.744 }, { 456.0, 0.3139968, 0.0502432, 1.733368 }, { 457.0, 0.3088664, 0.0525656, 1.720704 }, { 458.0, 0.3032976, 0.0549664, 1.705856 }, { 459.0, 0.2972792, 0.0574448, 1.688672 }, { 460.0, 0.2908, 0.06, 1.669 }, { 461.0, 0.2839384, 0.06258704, 1.647136 }, { 462.0, 0.2765712, 0.06526032, 1.622368 }, { 463.0, 0.2686648, 0.06803008, 1.594432 }, { 464.0, 0.2601856, 0.07090656, 1.563064 }, { 465.0, 0.2511, 0.0739, 1.528 }, { 466.0, 0.2406512, 0.07701808, 1.484944 }, { 467.0, 0.2297096, 0.08027424, 1.438672 }, { 468.0, 0.2184224, 0.08367936, 1.389928 }, { 469.0, 0.2069368, 0.08724432, 1.339456 }, { 470.0, 0.1954, 0.09098, 1.288 }, { 471.0, 0.18440592, 0.09493312, 1.238544 }, { 472.0, 0.17354336, 0.09906976, 1.189032 }, { 473.0, 0.16284784, 0.10339184, 1.139648 }, { 474.0, 0.15235488, 0.10790128, 1.090576 }, { 475.0, 0.1421, 0.1126, 1.042 }, { 476.0, 0.13219904, 0.11752576, 0.9943536 }, { 477.0, 0.12258712, 0.12263568, 0.9475088 }, { 478.0, 0.11327968, 0.12792272, 0.9015872 }, { 479.0, 0.10429216, 0.13337984, 0.8567104 }, { 480.0, 0.09564, 0.139, 0.813 }, { 481.0, 0.08730504, 0.144604, 0.7706288 }, { 482.0, 0.07934472, 0.1504, 0.7296544 }, { 483.0, 0.07178288, 0.156424, 0.6901856 }, { 484.0, 0.06464336, 0.162712, 0.6523312 }, { 485.0, 0.05795, 0.1693, 0.6162 }, { 486.0, 0.05192184, 0.176256, 0.5825504 }, { 487.0, 0.04633872, 0.183576, 0.5506792 }, { 488.0, 0.04117568, 0.191288, 0.5205328 }, { 489.0, 0.03640776, 0.19942, 0.4920576 }, { 490.0, 0.03201, 0.208, 0.4652 }, { 491.0, 0.02789344, 0.2171072, 0.439964 }, { 492.0, 0.02411312, 0.2267056, 0.416224 }, { 493.0, 0.02066008, 0.2368104, 0.393912 }, { 494.0, 0.01752536, 0.2474368, 0.37296 }, { 495.0, 0.0147, 0.2586, 0.3533 }, { 496.0, 0.01214592, 0.2701808, 0.33488 }, { 497.0, 0.00989056, 0.2823624, 0.317612 }, { 498.0, 0.00793224, 0.2951936, 0.301424 }, { 499.0, 0.00626928, 0.3087232, 0.286244 }, { 500.0, 0.0049, 0.323, 0.272 }, { 501.0, 0.0037488, 0.33854, 0.258844 }, { 502.0, 0.0029064, 0.354808, 0.246424 }, { 503.0, 0.0023896, 0.371736, 0.234612 }, { 504.0, 0.0022152, 0.389256, 0.22328 }, { 505.0, 0.0024, 0.4073, 0.2123 }, { 506.0, 0.002916, 0.4255888, 0.200968 }, { 507.0, 0.003836, 0.4443184, 0.189876 }, { 508.0, 0.005188, 0.4634736, 0.17904 }, { 509.0, 0.007, 0.4830392, 0.168476 }, { 510.0, 0.0093, 0.503, 0.1582 }, { 511.0, 0.01218096, 0.5236928, 0.1481176 }, { 512.0, 0.01558968, 0.5446624, 0.1383828 }, { 513.0, 0.01953792, 0.5658056, 0.1290392 }, { 514.0, 0.02403744, 0.5870192, 0.1201304 }, { 515.0, 0.0291, 0.6082, 0.1117 }, { 516.0, 0.03485512, 0.6293184, 0.1039852 }, { 517.0, 0.04116736, 0.6501792, 0.0967876 }, { 518.0, 0.04801904, 0.6706608, 0.0901024 }, { 519.0, 0.05539248, 0.6906416, 0.0839248 }, { 520.0, 0.06327, 0.71, 0.07825 }, { 521.0, 0.07164608, 0.7279936, 0.07326328 }, { 522.0, 0.08048784, 0.7452768, 0.06872224 }, { 523.0, 0.08977456, 0.7618832, 0.06457456 }, { 524.0, 0.09948552, 0.7778464, 0.06076792 }, { 525.0, 0.1096, 0.7932, 0.05725 }, { 526.0, 0.12018304, 0.80816, 0.05385968 }, { 527.0, 0.13110672, 0.822532, 0.05068064 }, { 528.0, 0.14232888, 0.836304, 0.04768776 }, { 529.0, 0.15380736, 0.849464, 0.04485592 }, { 530.0, 0.1655, 0.862, 0.04216 }, { 531.0, 0.1771896, 0.8737848, 0.03947408 }, { 532.0, 0.1890528, 0.8849504, 0.03689904 }, { 533.0, 0.2010912, 0.8955136, 0.03443496 }, { 534.0, 0.2133064, 0.9054912, 0.03208192 }, { 535.0, 0.2257, 0.9149, 0.02984 }, { 536.0, 0.2382768, 0.923792, 0.02771408 }, { 537.0, 0.2510344, 0.93214, 0.02569824 }, { 538.0, 0.2639736, 0.939952, 0.02379136 }, { 539.0, 0.2770952, 0.947236, 0.02199232 }, { 540.0, 0.2904, 0.954, 0.0203 }, { 541.0, 0.3038984, 0.9602456, 0.01872128 }, { 542.0, 0.3175792, 0.9659888, 0.01724504 }, { 543.0, 0.3314408, 0.9712392, 0.01586816 }, { 544.0, 0.3454816, 0.9760064, 0.01458752 }, { 545.0, 0.3597, 0.9803, 0.0134 }, { 546.0, 0.3740688, 0.9841072, 0.0123092 }, { 547.0, 0.3886184, 0.9874656, 0.0113036 }, { 548.0, 0.4033536, 0.9903904, 0.0103784 }, { 549.0, 0.4182792, 0.9928968, 0.0095288 }, { 550.0, 0.4334, 0.995, 0.00875 }, { 551.0, 0.4487816, 0.9967856, 0.008034 }, { 552.0, 0.4643528, 0.9981808, 0.00738 }, { 553.0, 0.4801032, 0.9991832, 0.006784 }, { 554.0, 0.4960224, 0.9997904, 0.006242 }, { 555.0, 0.5121, 1, 0.00575 }, { 556.0, 0.5283544, 0.9998448, 0.0053024 }, { 557.0, 0.5447392, 0.9992784, 0.0048972 }, { 558.0, 0.5612368, 0.9982896, 0.0045308 }, { 559.0, 0.5778296, 0.9968672, 0.0041996 }, { 560.0, 0.5945, 0.995, 0.0039 }, { 561.0, 0.6112144, 0.9925936, 0.0036204 }, { 562.0, 0.6279752, 0.9897408, 0.0033672 }, { 563.0, 0.6447688, 0.9864512, 0.0031388 }, { 564.0, 0.6615816, 0.9827344, 0.0029336 }, { 565.0, 0.6784, 0.9786, 0.00275 }, { 566.0, 0.6952552, 0.9740896, 0.0025848 }, { 567.0, 0.7120776, 0.9691728, 0.0024384 }, { 568.0, 0.7288424, 0.9638512, 0.0023096 }, { 569.0, 0.7455248, 0.9581264, 0.0021972 }, { 570.0, 0.7621, 0.952, 0.0021 }, { 571.0, 0.7785496, 0.9454416, 0.0020184 }, { 572.0, 0.7948408, 0.9384928, 0.0019492 }, { 573.0, 0.8109472, 0.9311632, 0.0018908 }, { 574.0, 0.8268424, 0.9234624, 0.0018416 }, { 575.0, 0.8425, 0.9154, 0.0018 }, { 576.0, 0.8579448, 0.907008, 0.001766 }, { 577.0, 0.8730864, 0.898268, 0.001736 }, { 578.0, 0.8878856, 0.889184, 0.001708 }, { 579.0, 0.9023032, 0.87976, 0.00168 }, { 580.0, 0.9163, 0.87, 0.00165 }, { 581.0, 0.9297888, 0.8598376, 0.0016064 }, { 582.0, 0.9427904, 0.8493648, 0.0015592 }, { 583.0, 0.9552776, 0.8386032, 0.0015088 }, { 584.0, 0.9672232, 0.8275744, 0.0014556 }, { 585.0, 0.9786, 0.8163, 0.0014 }, { 586.0, 0.98932, 0.8047984, 0.001336 }, { 587.0, 0.999432, 0.7930952, 0.001272 }, { 588.0, 1.008924, 0.7812128, 0.00121 }, { 589.0, 1.017784, 0.7691736, 0.001152 }, { 590.0, 1.026, 0.757, 0.0011 }, { 591.0, 1.0338192, 0.744772, 0.0010736 }, { 592.0, 1.0409056, 0.73244, 0.0010528 }, { 593.0, 1.0471824, 0.720012, 0.0010352 }, { 594.0, 1.0525728, 0.707496, 0.0010184 }, { 595.0, 1.057, 0.6949, 0.001 }, { 596.0, 1.05992, 0.682216, 0.0009648 }, { 597.0, 1.06184, 0.669472, 0.0009264 }, { 598.0, 1.0628, 0.65668, 0.0008856 }, { 599.0, 1.06284, 0.643852, 0.0008432 }, { 600.0, 1.062, 0.631, 0.0008 }, { 601.0, 1.060672, 0.6181616, 0.00076192 }, { 602.0, 1.058456, 0.6053168, 0.00072336 }, { 603.0, 1.055304, 0.5924712, 0.00068384 }, { 604.0, 1.051168, 0.5796304, 0.00064288 }, { 605.0, 1.046, 0.5668, 0.0006 }, { 606.0, 1.0393872, 0.5539568, 0.00054576 }, { 607.0, 1.0317376, 0.5411424, 0.00049088 }, { 608.0, 1.0230944, 0.5283696, 0.00043712 }, { 609.0, 1.0135008, 0.5156512, 0.00038624 }, { 610.0, 1.003, 0.503, 0.00034 }, { 611.0, 0.9917376, 0.4904928, 0.00031072 }, { 612.0, 0.9796288, 0.4780624, 0.00028696 }, { 613.0, 0.9666912, 0.4657056, 0.00026784 }, { 614.0, 0.9529424, 0.4534192, 0.00025248 }, { 615.0, 0.9384, 0.4412, 0.00024 }, { 616.0, 0.9231392, 0.4290768, 0.00022888 }, { 617.0, 0.9071056, 0.4170064, 0.00021904 }, { 618.0, 0.8903024, 0.4049776, 0.00020976 }, { 619.0, 0.8727328, 0.3929792, 0.00020032 }, { 620.0, 0.8544, 0.381, 0.00019 }, { 621.0, 0.834904, 0.3688624, 0.00017264 }, { 622.0, 0.814752, 0.3567632, 0.00015432 }, { 623.0, 0.794048, 0.3447328, 0.00013568 }, { 624.0, 0.772896, 0.3328016, 0.00011736 }, { 625.0, 0.7514, 0.321, 0.0001 }, { 626.0, 0.729616, 0.309352, 8.712e-05 }, { 627.0, 0.707708, 0.297896, 7.576e-05 }, { 628.0, 0.685792, 0.286664, 6.584e-05 }, { 629.0, 0.663984, 0.275688, 5.728e-05 }, { 630.0, 0.6424, 0.265, 5e-05 }, { 631.0, 0.621684, 0.254824, 4.424e-05 }, { 632.0, 0.601292, 0.244952, 3.952e-05 }, { 633.0, 0.581208, 0.235368, 3.568e-05 }, { 634.0, 0.561416, 0.226056, 3.256e-05 }, { 635.0, 0.5419, 0.217, 3e-05 }, { 636.0, 0.5225672, 0.2081456, 2.752e-05 }, { 637.0, 0.5034976, 0.1995248, 2.536e-05 }, { 638.0, 0.4846944, 0.1911312, 2.344e-05 }, { 639.0, 0.4661608, 0.1829584, 2.168e-05 }, { 640.0, 0.4479, 0.175, 2e-05 }, { 641.0, 0.4298352, 0.1672112, 1.8e-05 }, { 642.0, 0.4120696, 0.1596336, 1.6e-05 }, { 643.0, 0.3946264, 0.1522704, 1.4e-05 }, { 644.0, 0.3775288, 0.1451248, 1.2e-05 }, { 645.0, 0.3608, 0.1382, 1e-05 }, { 646.0, 0.3444696, 0.1315056, 7.68e-06 }, { 647.0, 0.3285528, 0.1250368, 5.44e-06 }, { 648.0, 0.3130712, 0.1187952, 3.36e-06 }, { 649.0, 0.2980464, 0.1127824, 1.52e-06 }, { 650.0, 0.2835, 0.107, 0.0 }, { 651.0, 0.269588, 0.101488, -4.8e-07 }, { 652.0, 0.256164, 0.0962, -6.4e-07 }, { 653.0, 0.243216, 0.091128, -5.6e-07 }, { 654.0, 0.230732, 0.086264, -3.2e-07 }, { 655.0, 0.2187, 0.0816, 0.0 }, { 656.0, 0.2070888, 0.07711584, 0.0 }, { 657.0, 0.1959104, 0.07281872, 0.0 }, { 658.0, 0.1851576, 0.06870368, 0.0 }, { 659.0, 0.1748232, 0.06476576, 0.0 }, { 660.0, 0.1649, 0.061, 0.0 }, { 661.0, 0.1553584, 0.05739248, 0.0 }, { 662.0, 0.1462192, 0.05394944, 0.0 }, { 663.0, 0.1374808, 0.05066816, 0.0 }, { 664.0, 0.1291416, 0.04754592, 0.0 }, { 665.0, 0.1212, 0.04458, 0.0 }, { 666.0, 0.1136448, 0.04175872, 0.0 }, { 667.0, 0.1064864, 0.03909056, 0.0 }, { 668.0, 0.0997256, 0.03657504, 0.0 }, { 669.0, 0.0933632, 0.03421168, 0.0 }, { 670.0, 0.0874, 0.032, 0.0 }, { 671.0, 0.08193696, 0.02997536, 0.0 }, { 672.0, 0.07684968, 0.02809248, 0.0 }, { 673.0, 0.07211392, 0.02634192, 0.0 }, { 674.0, 0.06770544, 0.02471424, 0.0 }, { 675.0, 0.0636, 0.0232, 0.0 }, { 676.0, 0.05980472, 0.02179936, 0.0 }, { 677.0, 0.05625616, 0.02049088, 0.0 }, { 678.0, 0.05292224, 0.01926272, 0.0 }, { 679.0, 0.04977088, 0.01810304, 0.0 }, { 680.0, 0.04677, 0.017, 0.0 }, { 681.0, 0.04373648, 0.0158864, 0.0 }, { 682.0, 0.04082704, 0.0148196, 0.0 }, { 683.0, 0.03804736, 0.0138016, 0.0 }, { 684.0, 0.03540312, 0.0128344, 0.0 }, { 685.0, 0.0329, 0.01192, 0.0 }, { 686.0, 0.03057696, 0.011073104, 0.0 }, { 687.0, 0.02839808, 0.010279832, 0.0 }, { 688.0, 0.02636072, 0.009539008, 0.0 }, { 689.0, 0.02446224, 0.008849456, 0.0 }, { 690.0, 0.0227, 0.00821, 0.0 }, { 691.0, 0.02109152, 0.007626184, 0.0 }, { 692.0, 0.01960896, 0.007088432, 0.0 }, { 693.0, 0.01824464, 0.006593888, 0.0 }, { 694.0, 0.01699088, 0.006139696, 0.0 }, { 695.0, 0.01584, 0.005723, 0.0 }, { 696.0, 0.014790368, 0.005342896, 0.0 }, { 697.0, 0.013826744, 0.004994088, 0.0 }, { 698.0, 0.012939936, 0.004673232, 0.0 }, { 699.0, 0.012120752, 0.004376984, 0.0 }, { 700.0, 0.01136, 0.004102, 0.0 }, { 701.0, 0.010621416, 0.003835176, 0.0 }, { 702.0, 0.009929648, 0.003585368, 0.0 }, { 703.0, 0.009282272, 0.003351672, 0.0 }, { 704.0, 0.008676864, 0.003133184, 0.0 }, { 705.0, 0.008111, 0.002929, 0.0 }, { 706.0, 0.007581776, 0.002737928, 0.0 }, { 707.0, 0.007087368, 0.002559424, 0.0 }, { 708.0, 0.006625472, 0.002392656, 0.0 }, { 709.0, 0.006193784, 0.002236792, 0.0 }, { 710.0, 0.00579, 0.002091, 0.0 }, { 711.0, 0.005408008, 0.001953072, 0.0 }, { 712.0, 0.005050264, 0.001823896, 0.0 }, { 713.0, 0.004715416, 0.001702984, 0.0 }, { 714.0, 0.004402112, 0.001589848, 0.0 }, { 715.0, 0.004109, 0.001484, 0.0 }, { 716.0, 0.003832872, 0.00138428, 0.0 }, { 717.0, 0.003574696, 0.00129104, 0.0 }, { 718.0, 0.003333584, 0.00120396, 0.0 }, { 719.0, 0.003108648, 0.00112272, 0.0 }, { 720.0, 0.002899, 0.001047, 0.0 }, { 721.0, 0.002704008, 0.000976576, 0.0 }, { 722.0, 0.002522464, 0.000911008, 0.0 }, { 723.0, 0.002353416, 0.000849952, 0.0 }, { 724.0, 0.002195912, 0.000793064, 0.0 }, { 725.0, 0.002049, 0.00074, 0.0 }, { 726.0, 0.001910224, 0.000689872, 0.0 }, { 727.0, 0.001780512, 0.000643016, 0.0 }, { 728.0, 0.001659288, 0.000599224, 0.0 }, { 729.0, 0.001545976, 0.000558288, 0.0 }, { 730.0, 0.00144, 0.00052, 0.0 }, { 731.0, 0.001339728, 0.000483768, 0.0 }, { 732.0, 0.001245904, 0.000449864, 0.0 }, { 733.0, 0.001158216, 0.000418176, 0.0 }, { 734.0, 0.001076352, 0.000388592, 0.0 }, { 735.0, 0.001, 0.000361, 0.0 }, { 736.0, 0.000928688, 0.000335224, 0.0 }, { 737.0, 0.000862304, 0.000311232, 0.0 }, { 738.0, 0.000800576, 0.000288928, 0.0 }, { 739.0, 0.000743232, 0.000268216, 0.0 }, { 740.0, 0.00069, 0.000249, 0.0 }, { 741.0, 0.000640352, 0.00023112, 0.0 }, { 742.0, 0.000594336, 0.00021456, 0.0 }, { 743.0, 0.000551744, 0.00019924, 0.0 }, { 744.0, 0.000512368, 0.00018508, 0.0 }, { 745.0, 0.000476, 0.000172, 0.0 }, { 746.0, 0.000442336, 0.000159856, 0.0 }, { 747.0, 0.000411288, 0.000148648, 0.0 }, { 748.0, 0.000382672, 0.000138312, 0.0 }, { 749.0, 0.000356304, 0.000128784, 0.0 }, { 750.0, 0.000332, 0.00012, 0.0 }, { 751.0, 0.000309448, 0.000111864, 0.0 }, { 752.0, 0.000288624, 0.000104352, 0.0 }, { 753.0, 0.000269376, 9.7408e-05, 0.0 }, { 754.0, 0.000251552, 9.0976e-05, 0.0 }, { 755.0, 0.000235, 8.5e-05, 0.0 }, { 756.0, 0.000219216, 7.9296e-05, 0.0 }, { 757.0, 0.000204488, 7.3968e-05, 0.0 }, { 758.0, 0.000190752, 6.8992e-05, 0.0 }, { 759.0, 0.000177944, 6.4344e-05, 0.0 }, { 760.0, 0.000166, 6e-05, 0.0 }, { 761.0, 0.00015476, 5.5872e-05, 0.0 }, { 762.0, 0.00014428, 5.2016e-05, 0.0 }, { 763.0, 0.00013452, 4.8424e-05, 0.0 }, { 764.0, 0.00012544, 4.5088e-05, 0.0 }, { 765.0, 0.000117, 4.2e-05, 0.0 }, { 766.0, 0.00010916, 3.9216e-05, 0.0 }, { 767.0, 0.00010188, 3.6648e-05, 0.0 }, { 768.0, 9.512e-05, 3.4272e-05, 0.0 }, { 769.0, 8.884e-05, 3.2064e-05, 0.0 }, { 770.0, 8.3e-05, 3e-05, 0.0 }, { 771.0, 7.7496e-05, 2.796e-05, 0.0 }, { 772.0, 7.2368e-05, 2.604e-05, 0.0 }, { 773.0, 6.7592e-05, 2.424e-05, 0.0 }, { 774.0, 6.3144e-05, 2.256e-05, 0.0 }, { 775.0, 5.9e-05, 2.1e-05, 0.0 }, { 776.0, 5.512e-05, 1.953e-05, 0.0 }, { 777.0, 5.15e-05, 1.819e-05, 0.0 }, { 778.0, 4.812e-05, 1.698e-05, 0.0 }, { 779.0, 4.496e-05, 1.591e-05, 0.0 }, { 780.0, 4.2e-05, 1.5e-05, 0.0 } }; /* Open. */ if (argc < 3) { printf ("Usage :\n\t./test_2 -display <hostname:number.screen_number>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./test_2 -display <hostname:number.screen_number>.\n"); exit (1); } display = XOpenDisplay(argv[2]); if (! display) { printf("cannot open display.\n"); exit(1); } /*monochroma_color from monochromatic_light * (XYZ color space).*/ monochroma_color = malloc(401*sizeof(XcmsColor)); for (a = 0; a < 402; a++) monochroma_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { monochroma_color[a]->spec.CIEXYZ.X = monochromatic_light[a][1]; monochroma_color[a]->spec.CIEXYZ.Y = monochromatic_light[a][2]; monochroma_color[a]->spec.CIEXYZ.Z =monochromatic_light[a][3]; monochroma_color[a]->format = XcmsCIEXYZFormat; } /* Limites of colors * (RGB color space).*/ limites_color = malloc((256*12+1)*sizeof(XcmsColor)); for (a = 0; a < 3073; a++) limites_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 256; a++) { limites_color[a]->spec.RGB.red = a*257-1; limites_color[a]->spec.RGB.green = 0; limites_color[a]->spec.RGB.blue = 0; limites_color[a+256]->spec.RGB.red = 0; limites_color[a+256]->spec.RGB.green = a*257-1; limites_color[a+256]->spec.RGB.blue = 0; limites_color[a+256*2]->spec.RGB.red = 0; limites_color[a+256*2]->spec.RGB.green = 0; limites_color[a+256*2]->spec.RGB.blue = a*257-1; limites_color[a+256*3]->spec.RGB.red = 65535; limites_color[a+256*3]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*3]->spec.RGB.blue = 0; limites_color[a+256*4]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*4]->spec.RGB.green = 65535; limites_color[a+256*4]->spec.RGB.blue = 0; limites_color[a+256*5]->spec.RGB.red = 0; limites_color[a+256*5]->spec.RGB.green = 65535; limites_color[a+256*5]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.red = 0; limites_color[a+256*6]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.blue = 65535; limites_color[a+256*7]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*7]->spec.RGB.green = 0; limites_color[a+256*7]->spec.RGB.blue = 65535; limites_color[a+256*8]->spec.RGB.red = 65535; limites_color[a+256*8]->spec.RGB.green = 0; limites_color[a+256*8]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.green = 65535; limites_color[a+256*9]->spec.RGB.blue = 65535; limites_color[a+256*10]->spec.RGB.red = 65535; limites_color[a+256*10]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*10]->spec.RGB.blue = 65535; limites_color[a+256*11]->spec.RGB.red = 65535; limites_color[a+256*11]->spec.RGB.green = 65535; limites_color[a+256*11]->spec.RGB.blue = 65535-a*257-1; } for (a = 0; a < 3073; a++) limites_color[a]->format = XcmsRGBFormat; /* 4 cosmetiques */ cosmetiques = malloc(4*sizeof(XcmsColor)); for (a = 0; a < 4; a++) cosmetiques[a] = malloc(sizeof(XcmsColor)); cosmetiques[0]->spec.RGB.red = 0x7fff; cosmetiques[0]->spec.RGB.green = 0x7fff; cosmetiques[0]->spec.RGB.blue = 0x7fff; cosmetiques[0]->format = XcmsRGBFormat; cosmetiques[1]->spec.RGB.red = 0x9600; cosmetiques[1]->spec.RGB.green = 0x9600; cosmetiques[1]->spec.RGB.blue = 0x7fff; cosmetiques[1]->format = XcmsRGBFormat; cosmetiques[2]->spec.RGB.red = 0x6400; cosmetiques[2]->spec.RGB.green = 0x6400; cosmetiques[2]->spec.RGB.blue = 0x6400; cosmetiques[2]->format = XcmsRGBFormat; cosmetiques[3]->spec.RGB.red = 0x4000; cosmetiques[3]->spec.RGB.green = 0x4000; cosmetiques[3]->spec.RGB.blue = 0x4000; cosmetiques[3]->format = XcmsRGBFormat; /* Visual. */ n_item = malloc(sizeof(unsigned int)*8); visual_info = malloc(sizeof(XVisualInfo)*32); visual_tmp = malloc(sizeof(XVisualInfo)); visual_tmp->class = DirectColor; visual_info = XGetVisualInfo(display, VisualClassMask, visual_tmp, n_item); if (! visual_info) printf("cannot open \"Visual DirectColor\"\n"); XFree(visual_tmp); XFree(n_item); /* Colormap */ parent = XDefaultRootWindow(display); rmask_return = malloc(sizeof(unsigned long)*8); gmask_return = malloc(sizeof(unsigned long)*8); bmask_return = malloc(sizeof(unsigned long)*8); pixels = malloc(sizeof(unsigned long)*131070); colormap = XCreateColormap(display, parent, visual_info->visual, AllocNone); if (visual_info->depth == 8) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 3, 3, 2, rmask_return, gmask_return, bmask_return); if ((visual_info->depth == 15) | (visual_info->depth == 24)) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, visual_info->depth/3, visual_info->depth/3, visual_info->depth/3, rmask_return, gmask_return, bmask_return); if (visual_info->depth == 16) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 5, 6, 5, rmask_return, gmask_return, bmask_return); if (status == 0) printf("XAllocColorPlanes status 0\n"); ccc = XcmsCCCOfColormap(display, colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); /* Data to cielab, cieluv, TekHVC, xyY, uvY. */ test = malloc(sizeof(Bool)); color_pixel = malloc((3073+402+4)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+4; a++) color_pixel[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_pixel[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_pixel[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_pixel[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_pixel[a]->format = XcmsCIEXYZFormat; XcmsCIELabClipLab (ccc, color_pixel[a], 1, 0, test); /*VARIANTES POSSIBLES*/ XcmsCIEXYZToRGBi(ccc, color_pixel[a], 1, test); XcmsRGBiToRGB(ccc, color_pixel[a], 1, test); } for (a = 0; a < 3073; a++) { color_pixel[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_pixel[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_pixel[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_pixel[a+402]->format = XcmsRGBFormat; } for (a = 0; a < 4; a++) { color_pixel[a+402+3073]->spec.RGB.red = cosmetiques[a]->spec.RGB.red; color_pixel[a+402+3073]->spec.RGB.green = cosmetiques[a]->spec.RGB.green; color_pixel[a+402+3073]->spec.RGB.blue = cosmetiques[a]->spec.RGB.blue; color_pixel[a+402+3073]->format = XcmsRGBFormat; } for(a = 0; a < 402+3073+4; a++) { if ((visual_info->depth == 15) | (visual_info->depth == 24)) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/(65536/visual_info->colormap_size) + color_pixel[a]->spec.RGB.green/(65536/visual_info->colormap_size) *visual_info->colormap_size + color_pixel[a]->spec.RGB.red/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/2048 + color_pixel[a]->spec.RGB.green/1024*32 + color_pixel[a]->spec.RGB.red/2048*64*32; if (visual_info->depth == 8) color_pixel[a]->pixel = color_pixel[a]->spec.RGB.blue/16384*8*8 + color_pixel[a]->spec.RGB.green/8192*8 + color_pixel[a]->spec.RGB.red/8192; XcmsStoreColor(display, colormap, color_pixel[a]); XcmsQueryColor(display, colormap, color_pixel[a], XcmsRGBFormat); } color_cielab = malloc((3073+402+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+1; a++) color_cielab[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_cielab[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_cielab[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_cielab[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_cielab[a]->format = XcmsCIEXYZFormat; XcmsCIEXYZToCIELab(ccc, white_point, color_cielab[a], 1); } for (a = 0; a < 3073; a++) { color_cielab[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_cielab[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_cielab[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_cielab[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_cielab[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cielab[a+402], 1, test); XcmsCIEXYZToCIELab(ccc, white_point, color_cielab[a+402], 1); } /* Create pixmap.*/ screen = DefaultScreen(display); depth = visual_info->depth; pixmap_cielab_ab = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cielab_La = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cielab_Lb = XCreatePixmap(display, parent, 576, 240, depth); pixmap_cielab_pers1 = XCreatePixmap(display, parent, 576, 576, depth); pixmap_cielab_pers2 = XCreatePixmap(display, parent, 576, 576, depth); /* Create GC. */ font_name = "-adobe-times-medium-r-normal-*-12-120-75-75-p-64-iso8859-1"; font = XLoadFont(display, font_name); values = malloc(sizeof(XGCValues)); values->font = font; values->foreground = color_pixel[402+3073+0]->pixel; gc =XCreateGC(display, parent, GCFont | GCForeground, values); /* Paint pixmap. */ XFillRectangle(display, pixmap_cielab_ab, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cielab_La, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cielab_Lb, gc, 0, 0, 576, 240); XFillRectangle(display, pixmap_cielab_pers1, gc, 0, 0, 576, 576); XFillRectangle(display, pixmap_cielab_pers2, gc, 0, 0, 576, 576); /* DrawLine pixmap. */ XSetForeground(display, gc, color_pixel[402+3073+1]->pixel); for (v = 1; v < 18; v++) { XDrawLine(display, pixmap_cielab_ab, gc, 576/2+16*v, 0, 576/2+16*v, 576); XDrawLine(display, pixmap_cielab_ab, gc, 576/2-16*v, 0, 576/2-16*v, 576); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2+16*v, 576, 576/2+16*v); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2-16*v, 576, 576/2-16*v); } for (v = 0; v < 11; v++) { XDrawLine(display, pixmap_cielab_La, gc, 0, 240-24*v, 576, 240-24*v); } for (v = 0; v < 13; v++) { XDrawLine(display, pixmap_cielab_La, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cielab_La, gc, 576/2-24*v, 0, 576/2-24*v, 240); } for (v = 0; v < 11; v++) { XDrawLine(display, pixmap_cielab_Lb, gc, 0, 240-24*v, 576, 240-24*v); } for (v = 0; v < 13; v++) { XDrawLine(display, pixmap_cielab_Lb, gc, 576/2+24*v, 0, 576/2+24*v, 240); XDrawLine(display, pixmap_cielab_Lb, gc, 576/2-24*v, 0, 576/2-24*v, 240); } XSetForeground(display, gc, color_pixel[402+3073+2]->pixel); XDrawLine(display, pixmap_cielab_ab, gc, 0, 576/2, 576, 576/2); XDrawLine(display, pixmap_cielab_ab, gc, 576/2, 0, 576/2, 576); XDrawLine(display, pixmap_cielab_La, gc, 576/2, 0, 576/2, 240); XDrawLine(display, pixmap_cielab_Lb, gc, 576/2, 0, 576/2, 240); /* DrawString pixmap. */ XSetForeground(display, gc, color_pixel[402+3073+3]->pixel); string = "- a*"; XDrawString(display, pixmap_cielab_ab, gc, 5, 286, string, strlen(string)); XDrawString(display, pixmap_cielab_La, gc, 5, 118, string, strlen(string)); string = "+ a*"; XDrawString(display, pixmap_cielab_ab, gc, 545, 286, string, strlen(string)); XDrawString(display, pixmap_cielab_La, gc, 545, 118, string, strlen(string)); string = "+ b*"; XDrawString(display, pixmap_cielab_ab, gc, 293, 15, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 545, 118, string, strlen(string)); string = "- b*"; XDrawString(display, pixmap_cielab_ab, gc, 293, 569, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 5, 118, string, strlen(string)); string = "L*"; XDrawString(display, pixmap_cielab_La, gc, 5, 15, string, strlen(string)); XDrawString(display, pixmap_cielab_Lb, gc, 5, 15, string, strlen(string)); /* Draw. */ /* Tab of deep:*/ tab_cielab_ab = malloc(576*576*sizeof(int)); tab_cielab_La = malloc(576*240*sizeof(int)); tab_cielab_Lb = malloc(576*240*sizeof(int)); tab_cielab_pers1 = malloc(576*576*sizeof(int)); tab_cielab_pers2 = malloc(576*576*sizeof(int)); for (a = 0; a<576; a++) { tab_cielab_ab[a] = malloc(576*sizeof(int)); tab_cielab_La[a] = malloc(240*sizeof(int)); tab_cielab_Lb[a] = malloc(240*sizeof(int)); tab_cielab_pers1[a] = malloc(576*sizeof(int)); tab_cielab_pers2[a] = malloc(576*sizeof(int)); } for (a = 0; a<576; a++) { for (b = 0; b<576; b++) { tab_cielab_ab[a][b] = -1000; tab_cielab_pers1[a][b] = 10000; tab_cielab_pers2[a][b] = 10000; } } for (a = 0; a<576; a++) { for (b = 0; b<240; b++) { tab_cielab_La[a][b] = -1000; tab_cielab_Lb[a][b] = -1000; } } /* Draw. */ for (b = 0; b < 402+3073; b++) { XSetForeground(display, gc, color_pixel[b]->pixel); L_star = color_cielab[b]->spec.CIELab.L_star; a_star = color_cielab[b]->spec.CIELab.a_star; b_star = color_cielab[b]->spec.CIELab.b_star; x = (int) ((float) a_star*576/360+576/2); y = (int) ((float) 576-b_star*576/360-576/2); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } a = (int) L_star; if (a > tab_cielab_ab[x][y]) { tab_cielab_ab[x][y] = a; XDrawPoint(display, pixmap_cielab_ab, gc, x, y); } x = (int) ((float) a_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) b_star; if (a > tab_cielab_La[x][y]) { tab_cielab_La[x][y] = a; XDrawPoint(display, pixmap_cielab_La, gc, x, y); } x = (int) ((float) b_star*576/240+576/2); y = (int) ((float) 240-L_star*576/240); if ((x < 0) | (x > 575) | (y < 0) | (y > 239)) { y = 0; x = 0; } a = (int) a_star; if (a > tab_cielab_Lb[x][y]) { tab_cielab_Lb[x][y] = a; XDrawPoint(display, pixmap_cielab_Lb, gc, x, y); } x = (int)((float) (1600*(a_star+200))/(b_star+1000)); y = (int)((float) 576-900-(1600*(L_star-450))/(b_star+1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((a_star+200), 2)+pow((b_star+1000), 2); a = (int) sqrt(reel); if (a < tab_cielab_pers1[x][y]) { tab_cielab_pers1[x][y] = a; XDrawPoint(display, pixmap_cielab_pers1, gc, x, y); } x = (int) ((float) (-1600*(b_star-200))/(a_star-1000)+586); y = (int) ((float) 576-900-(-1600*(L_star-450))/(a_star-1000)); if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) { y = 0; x = 0; } reel = pow((L_star-450), 2)+pow((a_star-1000), 2)+pow((b_star-200), 2); a = (int) sqrt(reel); if (a < tab_cielab_pers2[x][y]) { tab_cielab_pers2[x][y] = a; XDrawPoint(display, pixmap_cielab_pers2, gc, x, y); } } /* Create windows.*/ attributes.colormap = colormap; attributes.event_mask = ButtonPress; attributes.background_pixmap = pixmap_cielab_La; window_cielab_La = XCreateWindow(display, parent, 360, 120, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_Lb; window_cielab_Lb = XCreateWindow(display, parent, 390, 130, 576, 240, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_pers1; window_cielab_pers1 = XCreateWindow(display, parent, 420, 140, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_pers2; window_cielab_pers2 = XCreateWindow(display, parent, 450, 150, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); attributes.background_pixmap = pixmap_cielab_ab; window_cielab_ab = XCreateWindow(display, parent, 480, 160, 576, 576, 1, depth, InputOutput, visual_info->visual, CWColormap | CWBackPixmap | CWEventMask, &attributes); XStoreName(display, window_cielab_ab, "cielab a* b*"); XStoreName(display, window_cielab_La, "cielab L* a*"); XStoreName(display, window_cielab_Lb, "cielab L* b*"); XStoreName(display, window_cielab_pers1, "cielab pers1"); XStoreName(display, window_cielab_pers2, "cielab pers2"); XInstallColormap(display, colormap); XMapWindow(display, window_cielab_La); XMapWindow(display, window_cielab_Lb); XMapWindow(display, window_cielab_pers1); XMapWindow(display, window_cielab_pers2); XMapWindow(display, window_cielab_ab); XClearArea(display, window_cielab_ab, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_La, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_Lb, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_pers1, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_pers2, 0, 0, 576, 576, 0); /* Test XcmsCIELabQueryMinL XcmsCIELabQueryMaxL.*/ color3 = malloc(sizeof(XcmsColor)); color4 = malloc(sizeof(XcmsColor)); count = 0; for (chroma_int = 0; chroma_int < 14; chroma_int++) { for (hue_int = 0; hue_int < 721; hue_int++) { count++; XcmsCIELabQueryMinL(ccc, hue_int*0.5, chroma_int*10.0, color3); color4->spec.CIELab.L_star = color3->spec.CIELab.L_star; color4->spec.CIELab.a_star = color3->spec.CIELab.a_star; color4->spec.CIELab.b_star = color3->spec.CIELab.b_star; color4->format = XcmsCIELabFormat; L_star = color3->spec.CIELab.L_star; a_star = color3->spec.CIELab.a_star; b_star = color3->spec.CIELab.b_star; XcmsCIELabToCIEXYZ(ccc, white_point, color4, 1); XcmsCIEXYZToRGBi(ccc, color4, 1, test); XcmsRGBiToRGB(ccc, color4, 1, test); if ((visual_info->depth == 15) | (visual_info->depth == 24)) color4->pixel = color4->spec.RGB.blue/(65536/visual_info->colormap_size) + color4->spec.RGB.green/(65536/visual_info->colormap_size) *visual_info->colormap_size + color4->spec.RGB.red/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color4->pixel = color4->spec.RGB.blue/2048 + color4->spec.RGB.green/1024*32 + color4->spec.RGB.red/2048*64*32; if (visual_info->depth == 8) color4->pixel = color4->spec.RGB.blue/16384*8*8 + color4->spec.RGB.green/8192*8 + color4->spec.RGB.red/8192; XcmsStoreColor(display, colormap, color4); XcmsQueryColor(display, colormap, color4, XcmsRGBFormat); XSetForeground(display, gc, color4->pixel); /*Drawing face a* b* of CIELab space.*/ x = a_star*576/360+576/2; y = 576-b_star*576/360-576/2; a = L_star; if (a > tab_cielab_ab[x][y]) { tab_cielab_ab[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_ab, gc, x, y); } /*Drawing face L* a* of CIELab space.*/ x = a_star*576/240+576/2; y = 240-L_star*576/240; a = b_star; if (a > tab_cielab_La[x][y]) { tab_cielab_La[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_La, gc, x, y); } /*Drawing face L* b* of CIELab space.*/ x = b_star*576/240+576/2; y = 240-L_star*576/240; a = a_star; if (a > tab_cielab_Lb[x][y]) { tab_cielab_Lb[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_Lb, gc, x, y); } /*CIELab space in perpective .*/ x = (1600*(a_star+200))/(b_star+1000); y = 576-900-(1600*(L_star-450))/(b_star+1000); a = pow((L_star-450), 2)+pow((a_star+200), 2)+pow((b_star+1000), 2); a = sqrt(a); if (a < tab_cielab_pers1[x][y]) { tab_cielab_pers1[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers1, gc, x, y); } /*CIELab space with an other point of vue.*/ x = (-1600*(b_star-200))/(a_star-1000)+586; y = 576-900-(-1600*(L_star-450))/(a_star-1000); a = pow((L_star-450), 2)+pow((a_star-1000), 2)+pow((b_star-200), 2); a = sqrt(a); if (x < 0) x = 0; if (x > 575) x = 576; if (y < 0) y = 0; if (y > 575) y = 576; if (a < tab_cielab_pers2[x][y]) { tab_cielab_pers2[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers2, gc, x, y); } XcmsCIELabQueryMaxL(ccc, hue_int*0.5, chroma_int*10.0, color3); color4->spec.CIELab.L_star = color3->spec.CIELab.L_star; color4->spec.CIELab.a_star = color3->spec.CIELab.a_star; color4->spec.CIELab.b_star = color3->spec.CIELab.b_star; color4->format = XcmsCIELabFormat; L_star = color3->spec.CIELab.L_star; a_star = color3->spec.CIELab.a_star; b_star = color3->spec.CIELab.b_star; XcmsCIELabToCIEXYZ(ccc, white_point, color4, 1); XcmsCIEXYZToRGBi(ccc, color4, 1, test); XcmsRGBiToRGB(ccc, color4, 1, test); if ((visual_info->depth == 15) | (visual_info->depth == 24)) color4->pixel = color4->spec.RGB.blue/(65536/visual_info->colormap_size) + color4->spec.RGB.green/(65536/visual_info->colormap_size) *visual_info->colormap_size + color4->spec.RGB.red/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color4->pixel = color4->spec.RGB.blue/2048 + color4->spec.RGB.green/1024*32 + color4->spec.RGB.red/2048*64*32; if (visual_info->depth == 8) color4->pixel = color4->spec.RGB.blue/16384*8*8 + color4->spec.RGB.green/8192*8 + color4->spec.RGB.red/8192; XcmsStoreColor(display, colormap, color4); XcmsQueryColor(display, colormap, color4, XcmsRGBFormat); XSetForeground(display, gc, color4->pixel); /*Drawing face a* b* of CIELab space.*/ x = a_star*576/360+576/2; y = 576-b_star*576/360-576/2; a = L_star; if (a > tab_cielab_ab[x][y]) { tab_cielab_ab[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_ab, gc, x, y); } /*Drawing face L* a* of CIELab space.*/ x = a_star*576/240+576/2; y = 240-L_star*576/240; a = b_star; if (a > tab_cielab_La[x][y]) { tab_cielab_La[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_La, gc, x, y); } /*Drawing face L* b* of CIELab space.*/ x = b_star*576/240+576/2; y = 240-L_star*576/240; a = a_star; if (a > tab_cielab_Lb[x][y]) { tab_cielab_Lb[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_Lb, gc, x, y); } /*CIELab space in perpective .*/ x = (1600*(a_star+200))/(b_star+1000); y = 576-900-(1600*(L_star-450))/(b_star+1000); a = pow((L_star-450), 2)+pow((a_star+200), 2)+pow((b_star+1000), 2); a = sqrt(a); if (a < tab_cielab_pers1[x][y]) { tab_cielab_pers1[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers1, gc, x, y); } /*CIELab space with an other point of vue.*/ x = (-1600*(b_star-200))/(a_star-1000)+586; y = 576-900-(-1600*(L_star-450))/(a_star-1000); a = pow((L_star-450), 2)+pow((a_star-1000), 2)+pow((b_star-200), 2); a = sqrt(a); if (x < 0) x = 0; if (x > 575) x = 576; if (y < 0) y = 0; if (y > 575) y = 576; if (a < tab_cielab_pers2[x][y]) { tab_cielab_pers2[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers2, gc, x, y); } if (count > 32) { count = 0; XClearArea(display, window_cielab_ab, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_La, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_Lb, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_pers1, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_pers2, 0, 0, 576, 576, 0); } }} /* Test XcmsCIELabQueryMaxC.*/ for (L_int = 0; L_int < 501; L_int++) { for (hue_int = 0; hue_int < 36; hue_int++) { XcmsCIELabQueryMaxC(ccc, hue_int*10.0, L_int*0.2, color3); color4->spec.CIELab.L_star = color3->spec.CIELab.L_star; color4->spec.CIELab.a_star = color3->spec.CIELab.a_star; color4->spec.CIELab.b_star = color3->spec.CIELab.b_star; color4->format = XcmsCIELabFormat; XcmsAllocColor(display, colormap, color4, XcmsRGBFormat); XSetForeground(display, gc, color4->pixel); L_star = color3->spec.CIELab.L_star; a_star = color3->spec.CIELab.a_star; b_star = color3->spec.CIELab.b_star; XcmsCIELabToCIEXYZ(ccc, white_point, color4, 1); XcmsCIEXYZToRGBi(ccc, color4, 1, test); XcmsRGBiToRGB(ccc, color4, 1, test); if ((visual_info->depth == 15) | (visual_info->depth == 24)) color4->pixel = color4->spec.RGB.blue/(65536/visual_info->colormap_size) + color4->spec.RGB.green/(65536/visual_info->colormap_size) *visual_info->colormap_size + color4->spec.RGB.red/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color4->pixel = color4->spec.RGB.blue/2048 + color4->spec.RGB.green/1024*32 + color4->spec.RGB.red/2048*64*32; if (visual_info->depth == 8) color4->pixel = color4->spec.RGB.blue/16384*8*8 + color4->spec.RGB.green/8192*8 + color4->spec.RGB.red/8192; XcmsStoreColor(display, colormap, color4); XcmsQueryColor(display, colormap, color4, XcmsRGBFormat); XSetForeground(display, gc, color4->pixel); /*Drawing face a* b* of CIELab space.*/ x = a_star*576/360+576/2; y = 576-b_star*576/360-576/2; a = L_star; if (a > tab_cielab_ab[x][y]) { tab_cielab_ab[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_ab, gc, x, y); } /*Drawing face L* a* of CIELab space.*/ x = a_star*576/240+576/2; y = 240-L_star*576/240; a = b_star; if (a > tab_cielab_La[x][y]) { tab_cielab_La[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_La, gc, x, y); } /*Drawing face L* b* of CIELab space.*/ x = b_star*576/240+576/2; y = 240-L_star*576/240; a = a_star; if (a > tab_cielab_Lb[x][y]) { tab_cielab_Lb[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_Lb, gc, x, y); } /*CIELab space in perpective .*/ x = (1600*(a_star+200))/(b_star+1000); y = 576-900-(1600*(L_star-450))/(b_star+1000); a = pow((L_star-450), 2)+pow((a_star+200), 2)+pow((b_star+1000), 2); a = sqrt(a); if (a < tab_cielab_pers1[x][y]) { tab_cielab_pers1[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers1, gc, x, y); } /*CIELab space with an other point of vue.*/ x = (-1600*(b_star-200))/(a_star-1000)+586; y = 576-900-(-1600*(L_star-450))/(a_star-1000); a = pow((L_star-450), 2)+pow((a_star-1000), 2)+pow((b_star-200), 2); a = sqrt(a); if (x < 0) x = 0; if (x > 575) x = 576; if (y < 0) y = 0; if (y > 575) y = 576; if (a < tab_cielab_pers2[x][y]) { tab_cielab_pers2[x][y] = a; if ((x < 0) | (x > 575) | (y < 0) | (y > 575)) {y = 0; x= 0;} XDrawPoint(display, pixmap_cielab_pers2, gc, x, y); } if (count > 32) { count = 0; XClearArea(display, window_cielab_ab, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_La, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_Lb, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_pers1, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_pers2, 0, 0, 576, 576, 0); } } } XClearArea(display, window_cielab_ab, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_La, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_Lb, 0, 0, 576, 240, 0); XClearArea(display, window_cielab_pers1, 0, 0, 576, 576, 0); XClearArea(display, window_cielab_pers2, 0, 0, 576, 576, 0); /* Create images (xpm format).*/ image_cielab_ab = XGetImage(display, pixmap_cielab_ab, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cielab_La = XGetImage(display, pixmap_cielab_La, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cielab_Lb = XGetImage(display, pixmap_cielab_Lb, 0, 0, 576, 240, 0xffffff, ZPixmap); image_cielab_pers1 = XGetImage(display, pixmap_cielab_pers1, 0, 0, 576, 576, 0xffffff, ZPixmap); image_cielab_pers2 = XGetImage(display, pixmap_cielab_pers2, 0, 0, 576, 576, 0xffffff, ZPixmap); xpmimage_cielab_ab = malloc(sizeof(XpmImage)); xpmimage_cielab_La = malloc(sizeof(XpmImage)); xpmimage_cielab_Lb = malloc(sizeof(XpmImage)); xpmimage_cielab_pers1 = malloc(sizeof(XpmImage)); xpmimage_cielab_pers2 = malloc(sizeof(XpmImage)); a = XpmCreateXpmImageFromImage(display, image_cielab_ab, 0, xpmimage_cielab_ab, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_ab.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_La, 0, xpmimage_cielab_La, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_La.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_Lb, 0, xpmimage_cielab_Lb, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_Lb.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_pers1, 0, xpmimage_cielab_pers1, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_pers1.xpm XpmNoMemory\n"); a = XpmCreateXpmImageFromImage(display, image_cielab_pers2, 0, xpmimage_cielab_pers2, NULL); if (a == XpmNoMemory) printf("xpmimage_cielab_pers2.xpm XpmNoMemory\n"); if (xpmimage_cielab_ab->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_ab->ncolors; a++) { sprintf(xpmimage_cielab_ab->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_La->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_La->ncolors; a++) { sprintf(xpmimage_cielab_La->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_Lb->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_Lb->ncolors; a++) { sprintf(xpmimage_cielab_Lb->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_pers1->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_pers1->ncolors; a++) { sprintf(xpmimage_cielab_pers1->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } if (xpmimage_cielab_pers2->cpp == 3) { n1 = 0; n2 = 0; n3 = 0; for (a = 0; a < xpmimage_cielab_pers2->ncolors; a++) { sprintf(xpmimage_cielab_pers2->colorTable[a].string, "%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } } xpminfo = malloc(sizeof(XpmInfo)); xpminfo->hints_cmt = " width height ncolors char_per_pixel "; xpminfo->colors_cmt = " colors "; xpminfo->pixels_cmt = " pixels "; xpminfo->valuemask = XpmComments; a = XpmWriteFileFromXpmImage("2_cielab_ab.xpm", xpmimage_cielab_ab, xpminfo); if (a == XpmNoMemory) printf("2_cielab_ab.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("2_cielab_La.xpm", xpmimage_cielab_La, xpminfo); if (a == XpmNoMemory) printf("2_cielab_La.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("2_cielab_Lb.xpm", xpmimage_cielab_Lb, xpminfo); if (a == XpmNoMemory) printf("2_cielab_Lb.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("2_cielab_pers1.xpm", xpmimage_cielab_pers1, xpminfo); if (a == XpmNoMemory) printf("2_cielab_pers1.xpm XpmNoMemory\n"); a = XpmWriteFileFromXpmImage("2_cielab_pers2.xpm", xpmimage_cielab_pers2, xpminfo); if (a == XpmNoMemory) printf("2_cielab_pers2.xpm XpmNoMemory\n"); /*End.*/ while(1) { XNextEvent(display, &event); if(event.xany.type == ButtonPressMask) break; } /* Close */ XUninstallColormap(display, colormap); XUnmapWindow(display, window_cielab_ab); XUnmapWindow(display, window_cielab_La); XUnmapWindow(display, window_cielab_Lb); XUnmapWindow(display, window_cielab_pers1); XUnmapWindow(display, window_cielab_pers2); XFreePixmap(display, pixmap_cielab_ab); XFreePixmap(display, pixmap_cielab_La); XFreePixmap(display, pixmap_cielab_Lb); XFreePixmap(display, pixmap_cielab_pers1); XFreePixmap(display, pixmap_cielab_pers2); XFree(image_cielab_ab); XFree(image_cielab_La); XFree(image_cielab_Lb); XFree(image_cielab_pers1); XFree(image_cielab_pers2); XpmFree(xpminfo); XpmFree(xpmimage_cielab_ab); XpmFree(xpmimage_cielab_La); XpmFree(xpmimage_cielab_Lb); XpmFree(xpmimage_cielab_pers1); XpmFree(xpmimage_cielab_pers2); XFreeGC(display, gc); XDestroyWindow(display, window_cielab_ab); XDestroyWindow(display, window_cielab_La); XDestroyWindow(display, window_cielab_Lb); XDestroyWindow(display, window_cielab_pers1); XDestroyWindow(display, window_cielab_pers2); XFree(* tab_cielab_ab); XFree(* tab_cielab_La); XFree(* tab_cielab_Lb); XFree(* tab_cielab_pers1); XFree(* tab_cielab_pers2); XFree(* monochroma_color); XFree(* limites_color); XFree(* color_pixel); XFree(* color_cielab); XFree(white_point); XFree(color_return); XFree(values); XFree(visual_info); free(test); return 22; }patches2_xcms_fixes.diff Index: xc/lib/X11/LabGcL.c =================================================================== --- xc.orig/lib/X11/LabGcL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabGcL.c 2005-11-22 08:17:39.000000000 +0100 @@ -101,7 +101,7 @@ */ return(XcmsFailure); } else { - /* Convert from CIEXYZ to CIE L*u*v* format */ + /* Convert from CIEXYZ to CIE L*a*b* format */ if (_XcmsDIConvertColors(&myCCC, pColor, ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat) == XcmsFailure) { @@ -115,10 +115,13 @@ /* Step 1: compute the maximum L* and chroma for this hue. */ /* This copy may be overkill but it preserves the pixel etc. */ memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor)); - if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max, - (XcmsRGBi *)NULL) == XcmsFailure) { - return (XcmsFailure); + + if (XcmsCIELabQueryMaxLC(&myCCC, degrees(hue), &Lab_max) + == XcmsFailure) + { + return (XcmsFailure); } + maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star, Lab_max.spec.CIELab.b_star); @@ -133,7 +136,9 @@ /* When the chroma input is greater than the maximum chroma */ /* merely return the L* and chroma for the given hue. */ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor)); - return (XcmsFailure); + retval = _XcmsDIConvertColors(&myCCC, pColor, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); + /* return (XcmsFailure); Principle of ClipL is to return something.*/ } else if (pColor->spec.CIELab.L_star < Lab_max.spec.CIELab.L_star) { /* Find the minimum lightness for the given chroma. */ if (pColor->format != XcmsCIELabFormat) { Index: xc/lib/X11/LabGcLC.c =================================================================== --- xc.orig/lib/X11/LabGcLC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabGcLC.c 2005-11-22 08:18:31.000000000 +0100 @@ -42,7 +42,7 @@ * Internal defines that need NOT be exported to any package or * program using this package. */ -#define MAXBISECTCOUNT 100 +#define EPS (XcmsFloat) 0.5 /*CIELab units*/ /************************************************************************ @@ -69,7 +69,7 @@ * DESCRIPTION * This routine will find the closest L* and chroma * for a specific hue. The color input is converted to - * CIE L*u*v* format and returned as CIE XYZ format. + * CIE L*a*b* format and returned as CIE XYZ format. * * Since this routine works with the L* within * pColor_in_out intermediate results may be returned @@ -84,13 +84,12 @@ Status retval; XcmsCCCRec myCCC; XcmsColor *pColor; - XcmsColor Lab_max; - XcmsFloat hue, chroma, maxChroma; - XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar; - XcmsFloat bestLstar, bestastar, bestbstar; - XcmsFloat nT, saveDist, tmpDist; - XcmsRGBi rgb_max; - int nCount, nMaxCount, nI, nILast; + XcmsColor Lab_max, tmp; + XcmsFloat hue, Lstar, chroma; + XcmsFloat maxLstar, maxChroma, saveDist; + XcmsFloat tmpLstar, tmpChroma, tmpDist; + XcmsFloat nMaxCountLstar, nMinCountLstar, count; + int nCount; /* Use my own CCC */ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec)); @@ -129,94 +128,63 @@ return(XcmsFailure); } - /* Step 1: compute the maximum L* and chroma for this hue. */ - /* This copy may be overkill but it preserves the pixel etc. */ - saveLstar = pColor->spec.CIELab.L_star; + Lstar = pColor->spec.CIELab.L_star; hue = XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star, pColor->spec.CIELab.b_star); chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star, pColor->spec.CIELab.b_star); + + /* Step 1: compute the maximum L* and chroma for this hue. */ + /* This copy may be overkill but it preserves the pixel etc. */ + memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor)); - if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max, &rgb_max) + if (XcmsCIELabQueryMaxLC (&myCCC, degrees(hue), &Lab_max) == XcmsFailure) { return (XcmsFailure); } + maxLstar = Lab_max.spec.CIELab.L_star; - - /* Now check and return the appropriate L* */ - if (saveLstar == maxLstar) { - /* When the L* input is equal to the maximum L* */ - /* merely return the maximum Lab point. */ - memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor)); - retval = _XcmsDIConvertColors(&myCCC, pColor, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); - } else { - /* return the closest point on the hue leaf. */ - /* must do a bisection here to compute the delta e. */ - maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star, - Lab_max.spec.CIELab.b_star); - nMaxCount = MAXBISECTCOUNT; - nI = nMaxCount / 2; - bestLstar = Lstar = pColor->spec.CIELab.L_star; - bestastar = pColor->spec.CIELab.a_star; - bestbstar = pColor->spec.CIELab.b_star; - bestChroma = Chroma = chroma; - saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) + + maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star, + Lab_max.spec.CIELab.b_star); + saveDist = XCMS_SQRT(((chroma - maxChroma) * (chroma - maxChroma)) + ((Lstar - maxLstar) * (Lstar - maxLstar))); - for (nCount = 0; nCount < nMaxCount; nCount++) { - nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount; - if (saveLstar > maxLstar) { - pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT; - pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT; - pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT; - } else { - pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT); - pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT); - pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT); - } - pColor->format = XcmsRGBiFormat; - - /* Convert from RGBi to CIE Lab */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat, - (Bool *) NULL) == XcmsFailure) { - return (XcmsFailure); - } - chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star, - pColor->spec.CIELab.b_star); - tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) + - ((Lstar - pColor->spec.CIELab.L_star) * - (Lstar - pColor->spec.CIELab.L_star))); - nILast = nI; - if (tmpDist > saveDist) { - nI /= 2; - } else { - nI = (nMaxCount + nI) / 2; + memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor)); + + /* Initialized the variables.*/ + + nMaxCountLstar = 100; + nMinCountLstar = 0; + + if (Lstar < maxLstar) { + nMaxCountLstar = maxLstar; + } + if (Lstar > maxLstar) { + nMinCountLstar = maxLstar; + } + + /* Now check and return the appropriate L* */ + + for(nCount = 0; nCount <= (nMaxCountLstar-nMinCountLstar)/EPS; nCount ++) + { + count = nCount*EPS + nMinCountLstar; + XcmsCIELabQueryMaxC(&myCCC, degrees(hue), nCount, &tmp); + tmpLstar = tmp.spec.CIELab.L_star; + tmpChroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, + tmp.spec.CIELab.b_star); + tmpDist = XCMS_SQRT(((chroma - tmpChroma) * (chroma - tmpChroma)) + + ((Lstar - tmpLstar) * (Lstar - tmpLstar))); + if (tmpDist < saveDist) + { saveDist = tmpDist; - bestLstar = pColor->spec.CIELab.L_star; - bestastar = pColor->spec.CIELab.a_star; - bestbstar = pColor->spec.CIELab.b_star; - bestChroma = chroma; - } - if (nI == nILast || nI == 0) { - break; - } - } - if (bestChroma >= maxChroma) { - pColor->spec.CIELab.L_star = maxLstar; - pColor->spec.CIELab.a_star = Lab_max.spec.CIELab.a_star; - pColor->spec.CIELab.b_star = Lab_max.spec.CIELab.b_star; - } else { - pColor->spec.CIELab.L_star = bestLstar; - pColor->spec.CIELab.a_star = bestastar; - pColor->spec.CIELab.b_star = bestbstar; + memcpy((char *)pColor, (char *)&tmp, sizeof(XcmsColor)); } + } + retval = _XcmsDIConvertColors(&myCCC, pColor, ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); if (retval != XcmsFailure && pCompressed != NULL) { *(pCompressed + i) = True; } - } return(retval); } Index: xc/lib/X11/LabMnL.c =================================================================== --- xc.orig/lib/X11/LabMnL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabMnL.c 2005-11-22 08:20:00.000000000 +0100 @@ -41,9 +41,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_L_STAR (XcmsFloat)40.0 +#define START_L_STAR (XcmsFloat)0.0 /*black.*/ /************************************************************************ @@ -54,7 +54,7 @@ /* * NAME - * XcmsCIELabQueryMinL - Compute max Lstar for a hue and chroma + * XcmsCIELabQueryMinL - Compute min Lstar for a hue and chroma * * SYNOPSIS */ @@ -66,7 +66,7 @@ XcmsColor *pColor_return; /* * DESCRIPTION - * Return the maximum Lstar for a specified hue_angle and chroma. + * Return the minumum Lstar for a specified hue_angle and chroma. * * ASSUMPTIONS * This routine assumes that the white point associated with @@ -81,11 +81,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor max_lc, tmp, prev; - XcmsFloat max_chroma, tmp_chroma; - XcmsFloat hue, nT, nChroma, lastChroma, prevChroma; - XcmsFloat rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_L_star, prev_L_star; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -108,108 +106,56 @@ } hue = radians(hue_angle); - tmp.spec.CIELab.L_star = START_L_STAR; - tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); - tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELabFormat; - - /* Step 1: Obtain the maximum L_star and chroma for this hue. */ - if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star, - max_lc.spec.CIELab.b_star); - - if (max_chroma <= chroma) { - /* - * If the chroma is greater than the chroma for the - * maximum L/chroma point then the L_star is the - * the L_star for the maximum L_star/chroma point. - * This is an error but I return the best approximation I can. - * Thus the inconsistency. - */ - memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - return(XcmsSuccess); - } - - /* - * If the chroma is equal to the chroma for the - * maximum L_star/chroma point then the L_star is the - * the L_star for the maximum L* and chroma point. - */ - /* if (max_chroma == chroma) { - * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - * return(XcmsSuccess); - * } - */ - - /* must do a bisection here to compute the maximum L* */ - /* save the structure input so that any elements that */ - /* are not touched are recopied later in the routine. */ - nChroma = chroma; - tmp_chroma = max_chroma; - lastChroma = -1.0; + tmp_L_star = START_L_STAR; + prev_L_star = tmp_L_star; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; + Factor = 10.0; for (nCount = 0; nCount < nMaxCount; nCount++) { - prevChroma = lastChroma; - lastChroma = tmp_chroma; - nT = (nChroma - max_chroma) / max_chroma * rFactor; - memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor)); - tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT); - tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT); - tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT); - tmp.format = XcmsRGBiFormat; - - /* convert from RGB to CIELab */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } - /* Now check the return against what is expected */ - tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, - tmp.spec.CIELab.b_star); - if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) { - /* Found It! */ - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); + tmp.spec.CIELab.L_star = tmp_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + + /* convert from CIELab to RGBi */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + if ((tmp.spec.RGBi.red >= 0.0) & (tmp.spec.RGBi.green >= 0.0) & + (tmp.spec.RGBi.blue >= 0.0) & (tmp.spec.RGBi.red <= 1.0) & + (tmp.spec.RGBi.green <= 1.0) & (tmp.spec.RGBi.blue <= 1.0)) + { + tmp_L_star = prev_L_star; + Factor = Factor/10.0; } - nChroma += chroma - tmp_chroma; - if (nChroma > max_chroma) { - nChroma = max_chroma; - rFactor *= 0.5; /* selective relaxation employed */ - } else if (nChroma < 0.0) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); - } - return(XcmsSuccess); - } else if (tmp_chroma <= prevChroma + EPS && - tmp_chroma >= prevChroma - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ + if (Factor <= EPS) { + /* Found It! */ + tmp.spec.CIELab.L_star = tmp_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); + return(XcmsSuccess); } - } - if (nCount >= nMaxCount) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); + prev_L_star = tmp_L_star; + tmp_L_star = tmp_L_star + Factor; + + if (tmp_L_star >= 100.0) + { + XcmsCIELabQueryMaxLC(&myCCC, hue_angle, pColor_return); + return(XcmsSuccess); } - } - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); +} + +if (nCount >= nMaxCount) { + tmp.spec.CIELab.L_star = prev_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); +} + +return(XcmsSuccess); } Index: xc/lib/X11/LabMxC.c =================================================================== --- xc.orig/lib/X11/LabMxC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabMxC.c 2005-11-22 08:21:30.000000000 +0100 @@ -43,10 +43,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_CHROMA (XcmsFloat)3.6 -#define TOPL (XcmsFloat)100.0 +#define START_CHROMA (XcmsFloat)0.0 /************************************************************************ @@ -86,11 +85,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor tmp; - XcmsColor max_lc; - XcmsFloat n_L_star, last_L_star, prev_L_star; - XcmsFloat hue, lastaStar, lastbStar, /*lastChroma,*/ maxDist, nT, rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_chroma, prev_chroma; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -113,90 +110,63 @@ } hue = radians(hue_angle); - tmp.spec.CIELab.L_star = L_star; - tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA); - tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELabFormat; - - /* Step 1: compute the maximum L_star and chroma for this hue. */ - memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor)); - if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - /* - * Step 2: Do a bisection here to compute the maximum chroma - * Note the differences between when the point to be found - * is above the maximum LC point and when it is below. - */ - if (L_star <= max_lc.spec.CIELab.L_star) { - maxDist = max_lc.spec.CIELab.L_star; - } else { - maxDist = TOPL - max_lc.spec.CIELab.L_star; - } - - n_L_star = L_star; - last_L_star = -1.0; + tmp_chroma = START_CHROMA; + prev_chroma = tmp_chroma; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; - - for (nCount = 0; nCount < nMaxCount; nCount++) { - prev_L_star = last_L_star; - last_L_star = tmp.spec.CIELab.L_star; -/* lastChroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, */ -/* tmp.spec.CIELab.b_star); */ - lastaStar = tmp.spec.CIELab.a_star; - lastbStar = tmp.spec.CIELab.b_star; - nT = (n_L_star - max_lc.spec.CIELab.L_star) / maxDist * rFactor; - if (nT > 0) { - tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT; - tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT; - tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT; - } else { - tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT); - tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT); - tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT); - } - tmp.format = XcmsRGBiFormat; + Factor = 10.0; - /* convert from RGB to CIELab */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } + for (nCount = 0; nCount < nMaxCount; nCount++) + { - /* - * Now check if we've reached the target L_star - */ - /* printf("result Lstar = %lf\n", tmp.spec.CIELab.L_star); */ - if (tmp.spec.CIELab.L_star <= L_star + EPS && - tmp.spec.CIELab.L_star >= L_star - EPS) { + tmp.spec.CIELab.L_star = L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, tmp_chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, tmp_chroma); + tmp.format = XcmsCIELabFormat; + + if (((L_star == 0.0) & (tmp_chroma == 0.0)) | + ((L_star == 100.0) & (tmp_chroma == 0.0))) + { + tmp.spec.CIELab.L_star = L_star; + tmp.spec.CIELab.a_star = 0.0; + tmp.spec.CIELab.b_star = 0.0; + tmp.format = XcmsCIELabFormat; memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); return(XcmsSuccess); } - if (nT > 0) { - n_L_star += ((TOPL - n_L_star) * - (L_star - tmp.spec.CIELab.L_star)) / (TOPL - L_star); - } else { - n_L_star *= L_star / tmp.spec.CIELuv.L_star; + + + /* convert from CIELab to RGBi. */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + + if ((tmp.spec.RGBi.red < 0.0) | (tmp.spec.RGBi.green < 0.0) | + (tmp.spec.RGBi.blue < 0.0) | (tmp.spec.RGBi.red > 1.0) | + (tmp.spec.RGBi.green > 1.0) | (tmp.spec.RGBi.blue > 1.0)) + { + tmp_chroma = prev_chroma; + Factor = Factor/10.0; } - if (tmp.spec.CIELab.L_star <= prev_L_star + EPS && - tmp.spec.CIELab.L_star >= prev_L_star - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ - /* printf("rFactor = %lf\n", rFactor); */ + if (Factor <= EPS) + { + tmp.spec.CIELab.L_star = L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, tmp_chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, tmp_chroma); + tmp.format = XcmsCIELabFormat; + memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); + return(XcmsSuccess); } + prev_chroma = tmp_chroma; + tmp_chroma = tmp_chroma + Factor; } - if (XCMS_FABS(last_L_star - L_star) < - XCMS_FABS(tmp.spec.CIELab.L_star - L_star)) { - tmp.spec.CIELab.a_star = lastaStar; - tmp.spec.CIELab.b_star = lastbStar; -/* tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, lastChroma); */ -/* tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, lastChroma); */ + + if (nCount >= nMaxCount) + { + tmp.spec.CIELab.L_star = L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, prev_chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, prev_chroma); + tmp.format = XcmsCIELabFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); } - tmp.spec.CIELab.L_star = L_star; - memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); - return(XcmsSuccess); +return(XcmsSuccess); } Index: xc/lib/X11/LabMxL.c =================================================================== --- xc.orig/lib/X11/LabMxL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabMxL.c 2005-11-22 08:22:29.000000000 +0100 @@ -41,9 +41,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_L_STAR (XcmsFloat)40 +#define START_L_STAR (XcmsFloat)100.0 /*white.*/ /************************************************************************ @@ -61,7 +61,7 @@ Status XcmsCIELabQueryMaxL(ccc, hue_angle, chroma, pColor_return) XcmsCCC ccc; - XcmsFloat hue_angle; /* hue in degrees */ + XcmsFloat hue_angle; /* hue angle in degrees */ XcmsFloat chroma; XcmsColor *pColor_return; /* @@ -81,11 +81,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor max_lc, tmp, prev; - XcmsFloat max_chroma, tmp_chroma; - XcmsFloat hue, nT, nChroma, lastChroma, prevChroma; - XcmsFloat rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_L_star, prev_L_star; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -108,108 +106,56 @@ } hue = radians(hue_angle); - tmp.spec.CIELab.L_star = START_L_STAR; - tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); - tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELabFormat; - - /* Step 1: Obtain the maximum L_star and chroma for this hue. */ - if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star, - max_lc.spec.CIELab.b_star); - - if (max_chroma <= chroma) { - /* - * If the chroma is greater than the chroma for the - * maximum L/chroma point then the L_star is the - * the L_star for the maximum L_star/chroma point. - * This is an error but I return the best approximation I can. - * Thus the inconsistency. - */ - memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - return(XcmsSuccess); - } - - /* - * If the chroma is equal to the chroma for the - * maximum L_star/chroma point then the L_star is the - * the L_star for the maximum L* and chroma point. - */ - /* if (max_chroma == chroma) { - * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - * return(XcmsSuccess); - * } - */ - - /* must do a bisection here to compute the maximum L* */ - /* save the structure input so that any elements that */ - /* are not touched are recopied later in the routine. */ - nChroma = chroma; - tmp_chroma = max_chroma; - lastChroma = -1.0; + tmp_L_star = START_L_STAR; + prev_L_star = tmp_L_star; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; + Factor = 10.0; for (nCount = 0; nCount < nMaxCount; nCount++) { - prevChroma = lastChroma; - lastChroma = tmp_chroma; - nT = (1.0 - (nChroma / max_chroma)) * rFactor; - memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor)); - tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT; - tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT; - tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT; - tmp.format = XcmsRGBiFormat; - - /* convert from RGB to CIELab */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } - /* Now check the return against what is expected */ - tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, - tmp.spec.CIELab.b_star); - if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) { - /* Found It! */ - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); + tmp.spec.CIELab.L_star = tmp_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + + /* convert from CIELab to RGBi */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + if ((tmp.spec.RGBi.red >= 0.0) & (tmp.spec.RGBi.green >= 0.0) & + (tmp.spec.RGBi.blue >= 0.0) & (tmp.spec.RGBi.red <= 1.0) & + (tmp.spec.RGBi.green <= 1.0) & (tmp.spec.RGBi.blue <= 1.0)) + { + tmp_L_star = prev_L_star; + Factor = Factor/10.0; } - nChroma += chroma - tmp_chroma; - if (nChroma > max_chroma) { - nChroma = max_chroma; - rFactor *= 0.5; /* selective relaxation employed */ - } else if (nChroma < 0.0) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); - } - return(XcmsSuccess); - } else if (tmp_chroma <= prevChroma + EPS && - tmp_chroma >= prevChroma - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ + if (Factor <= EPS) { + /* Found It! */ + tmp.spec.CIELab.L_star = tmp_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); + return(XcmsSuccess); } - } - if (nCount >= nMaxCount) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); + prev_L_star = tmp_L_star; + tmp_L_star = tmp_L_star - Factor; + + if (tmp_L_star <= 0.0) + { + XcmsCIELabQueryMaxLC(&myCCC, hue_angle, pColor_return); + return(XcmsSuccess); } - } - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); +} + +if (nCount >= nMaxCount) { + tmp.spec.CIELab.L_star = prev_L_star; + tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma); + tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELabFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); +} + +return(XcmsSuccess); } Index: xc/lib/X11/LabMxLC.c =================================================================== --- xc.orig/lib/X11/LabMxLC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LabMxLC.c 2005-11-22 08:23:53.000000000 +0100 @@ -53,109 +53,11 @@ #define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z)))) #define START_LSTAR (XcmsFloat)40.0 #define START_CHROMA (XcmsFloat)3.6 +#define START_LSTAR2 (XcmsFloat)0.0 +#define START_CHROMA2 (XcmsFloat)0.0 +#define MAXBISECTCOUNT 200 +#define EPS (XcmsFloat)0.001 - -/************************************************************************ - * * - * API PRIVATE ROUTINES * - * * - ************************************************************************/ - -/* - * NAME - * _XcmsCIELabQueryMaxLCRGB - Compute maximum L* and chroma. - * - * SYNOPSIS - */ -Status -_XcmsCIELabQueryMaxLCRGB( - XcmsCCC ccc, - XcmsFloat hue, /* hue in radians */ - XcmsColor *pColor_return, - XcmsRGBi *pRGB_return) -/* - * DESCRIPTION - * Return the maximum psychometric chroma for a specified - * hue, and the corresponding L*. This is computed - * by a binary search of all possible chromas. An assumption - * is made that there are no local maxima. Use the unrounded - * Max psychometric chroma because the difference check can be - * small. - * - * NOTE: No local CCC is used because this is a private - * routine and all routines that call it are expected - * to behave properly, i.e. send a local CCC with - * no white adjust function and no gamut compression - * function. - * - * This routine only accepts hue in radians as input and outputs - * Lab and RGBi. - * - * RETURNS - * XcmsFailure - Failure - * XcmsSuccess - Succeeded - * - */ -{ - XcmsFloat nSmall, nLarge; - XcmsColor tmp; - - tmp.format = XcmsCIELabFormat; - /* Use some unreachable color on the given hue */ - tmp.spec.CIELab.L_star = START_LSTAR; - tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA); - tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA); - /* - * Convert from Lab to RGB - * - * Note that the CIEXYZ to RGBi conversion routine must stuff the - * out of bounds RGBi values in tmp when the ccc->gamutCompProc - * is NULL. - */ - if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc), - (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL) - == XcmsFailure) && tmp.format != XcmsRGBiFormat) { - return (XcmsFailure); - } - - /* Now pick the smallest RGB */ - nSmall = MIN3(tmp.spec.RGBi.red, - tmp.spec.RGBi.green, - tmp.spec.RGBi.blue); - /* Make the smallest RGB equal to zero */ - tmp.spec.RGBi.red -= nSmall; - tmp.spec.RGBi.green -= nSmall; - tmp.spec.RGBi.blue -= nSmall; - - /* Now pick the largest RGB */ - nLarge = MAX3(tmp.spec.RGBi.red, - tmp.spec.RGBi.green, - tmp.spec.RGBi.blue); - /* Scale the RGB values based on the largest one */ - tmp.spec.RGBi.red /= nLarge; - tmp.spec.RGBi.green /= nLarge; - tmp.spec.RGBi.blue /= nLarge; - tmp.format = XcmsRGBiFormat; - - /* If the calling routine wants RGB value give them the ones used. */ - if (pRGB_return) { - pRGB_return->red = tmp.spec.RGBi.red; - pRGB_return->green = tmp.spec.RGBi.green; - pRGB_return->blue = tmp.spec.RGBi.blue; - } - - /* Convert from RGBi to Lab */ - if (_XcmsConvertColorsWithWhitePt(ccc, &tmp, - ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat, (Bool *) NULL) - == XcmsFailure) { - return (XcmsFailure); - } - - memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); - return (XcmsSuccess); -} - - /************************************************************************ * * * PUBLIC ROUTINES * @@ -192,6 +94,11 @@ */ { XcmsCCCRec myCCC; + XcmsFloat tmp_chroma, prev1_chroma, prev2_chroma; + XcmsFloat tmp_L_star, prev1_L_star, prev2_L_star; + XcmsFloat hue, Factor; + XcmsColor tmp_color; + int nCount, nMaxCount; /* * Check Arguments @@ -212,6 +119,55 @@ hue_angle -= 360.0; } - return(_XcmsCIELabQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return, - (XcmsRGBi *)NULL)); + hue = radians(hue_angle); + tmp_L_star = START_LSTAR2; + prev1_L_star = tmp_L_star; + prev2_L_star = prev1_L_star; + tmp_chroma = START_CHROMA2; + prev1_chroma = tmp_chroma; + prev2_chroma = prev1_chroma; + nMaxCount = MAXBISECTCOUNT; + Factor = 10.0; + + for (nCount = 0; nCount < nMaxCount; nCount++) { + + XcmsCIELabQueryMaxC(&myCCC, hue_angle, tmp_L_star, &tmp_color); + + prev2_chroma = prev1_chroma; + prev1_chroma = tmp_chroma; + tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp_color.spec.CIELab.a_star, + tmp_color.spec.CIELab.b_star); + if (tmp_chroma <= prev1_chroma) + { + tmp_chroma = prev2_chroma; + prev1_chroma = prev2_chroma; + tmp_L_star = prev2_L_star; + prev1_L_star = prev2_L_star; + Factor = Factor/10.0; + + if (Factor <= EPS) + { + tmp_color.spec.CIELab.L_star = tmp_L_star; + tmp_color.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, tmp_chroma); + tmp_color.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, tmp_chroma); + tmp_color.format = XcmsCIELabFormat; + memcpy((char *)pColor_return, (char *)&tmp_color, sizeof(XcmsColor)); + return(XcmsSuccess); + } + } + prev2_L_star = prev1_L_star; + prev1_L_star = tmp_L_star; + tmp_L_star = tmp_L_star + Factor; + if (tmp_L_star >= 100.0) {tmp_L_star = 100.0;} + } + +if (nCount >= nMaxCount) { + tmp_color.spec.CIELab.L_star = prev1_L_star; + tmp_color.spec.CIELab .a_star = XCMS_CIEASTAROFHUE(hue, prev1_chroma); + tmp_color.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, prev1_chroma); + tmp_color.format = XcmsCIELabFormat; + memcpy((char *)pColor_return, (char *)&tmp_color, sizeof(XcmsColor)); +} + +return(XcmsSuccess); } Index: xc/lib/X11/LuvGcL.c =================================================================== --- xc.orig/lib/X11/LuvGcL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvGcL.c 2005-11-22 08:26:38.000000000 +0100 @@ -115,10 +115,13 @@ /* Step 1: compute the maximum L* and chroma for this hue. */ /* This copy may be overkill but it preserves the pixel etc. */ memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor)); - if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max, - (XcmsRGBi *)NULL) == XcmsFailure) { - return (XcmsFailure); + + if (XcmsCIELuvQueryMaxLC(&myCCC, degrees(hue), &Luv_max) + == XcmsFailure) + { + return (XcmsFailure); } + maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star, Luv_max.spec.CIELuv.v_star); @@ -133,7 +136,9 @@ /* When the chroma input is greater than the maximum chroma */ /* merely return the L* and chroma for the given hue. */ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor)); - return (XcmsFailure); + retval = _XcmsDIConvertColors(&myCCC, pColor, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); +/* return (XcmsFailure); Principle of ClipL is to return something.*/ } else if (pColor->spec.CIELuv.L_star < Luv_max.spec.CIELuv.L_star) { /* Find the minimum lightness for the given chroma. */ if (pColor->format != XcmsCIELuvFormat) { Index: xc/lib/X11/LuvGcLC.c =================================================================== --- xc.orig/lib/X11/LuvGcLC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvGcLC.c 2005-11-22 08:25:48.000000000 +0100 @@ -42,7 +42,7 @@ * Internal defines that need NOT be exported to any package or * program using this package. */ -#define MAXBISECTCOUNT 100 +#define EPS (XcmsFloat) 0.5 /*CIELuv units*/ /************************************************************************ @@ -84,13 +84,12 @@ Status retval; XcmsCCCRec myCCC; XcmsColor *pColor; - XcmsColor Luv_max; - XcmsFloat hue, chroma, maxChroma; - XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar; - XcmsFloat bestLstar, bestustar, bestvstar; - XcmsFloat nT, saveDist, tmpDist; - XcmsRGBi rgb_max; - int nCount, nMaxCount, nI, nILast; + XcmsColor Luv_max, tmp; + XcmsFloat hue, Lstar, chroma; + XcmsFloat maxLstar, maxChroma, saveDist; + XcmsFloat tmpLstar, tmpChroma, tmpDist; + XcmsFloat nMaxCountLstar, nMinCountLstar, count; + int nCount; /* Use my own CCC */ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec)); @@ -129,94 +128,64 @@ return(XcmsFailure); } - /* Step 1: compute the maximum L* and chroma for this hue. */ - /* This copy may be overkill but it preserves the pixel etc. */ - saveLstar = pColor->spec.CIELuv.L_star; + Lstar = pColor->spec.CIELuv.L_star; hue = XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star, pColor->spec.CIELuv.v_star); chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star, pColor->spec.CIELuv.v_star); + + /* Step 1: compute the maximum L* and chroma for this hue. */ + /* This copy may be overkill but it preserves the pixel etc. */ + memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor)); - if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max, &rgb_max) + if (XcmsCIELuvQueryMaxLC (&myCCC, degrees(hue), &Luv_max) == XcmsFailure) { return (XcmsFailure); } maxLstar = Luv_max.spec.CIELuv.L_star; - - /* Now check and return the appropriate L* */ - if (saveLstar == maxLstar) { - /* When the L* input is equal to the maximum L* */ - /* merely return the maximum Luv point. */ - memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor)); - retval = _XcmsDIConvertColors(&myCCC, pColor, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); - } else { - /* return the closest point on the hue leaf. */ - /* must do a bisection here to compute the delta e. */ - maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star, - Luv_max.spec.CIELuv.v_star); - nMaxCount = MAXBISECTCOUNT; - nI = nMaxCount / 2; - bestLstar = Lstar = pColor->spec.CIELuv.L_star; - bestustar = pColor->spec.CIELuv.u_star; - bestvstar = pColor->spec.CIELuv.v_star; - bestChroma = Chroma = chroma; - saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) + + maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star, + Luv_max.spec.CIELuv.v_star); + + saveDist = XCMS_SQRT(((chroma - maxChroma) * (chroma - maxChroma)) + ((Lstar - maxLstar) * (Lstar - maxLstar))); - for (nCount = 0; nCount < nMaxCount; nCount++) { - nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount; - if (saveLstar > maxLstar) { - pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT; - pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT; - pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT; - } else { - pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT); - pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT); - pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT); - } - pColor->format = XcmsRGBiFormat; - - /* Convert from RGBi to CIE Luv */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat, - (Bool *) NULL) == XcmsFailure) { - return (XcmsFailure); - } - chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star, - pColor->spec.CIELuv.v_star); - tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) + - ((Lstar - pColor->spec.CIELuv.L_star) * - (Lstar - pColor->spec.CIELuv.L_star))); - nILast = nI; - if (tmpDist > saveDist) { - nI /= 2; - } else { - nI = (nMaxCount + nI) / 2; + + memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor)); + + /* Initialized the variables.*/ + + nMaxCountLstar = 100; + nMinCountLstar = 0; + + if (Lstar < maxLstar) { + nMaxCountLstar = maxLstar; + } + if (Lstar > maxLstar) { + nMinCountLstar = maxLstar; + } + + /* Now check and return the appropriate L* */ + + for(nCount = 0; nCount <= (nMaxCountLstar-nMinCountLstar)/EPS; nCount ++) + { + count = nCount*EPS + nMinCountLstar; + XcmsCIELuvQueryMaxC(&myCCC, degrees(hue), nCount, &tmp); + tmpLstar = tmp.spec.CIELuv.L_star; + tmpChroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, + tmp.spec.CIELuv.v_star); + tmpDist = XCMS_SQRT(((chroma - tmpChroma) * (chroma - tmpChroma)) + + ((Lstar - tmpLstar) * (Lstar - tmpLstar))); + if (tmpDist < saveDist) + { saveDist = tmpDist; - bestLstar = pColor->spec.CIELuv.L_star; - bestustar = pColor->spec.CIELuv.u_star; - bestvstar = pColor->spec.CIELuv.v_star; - bestChroma = chroma; - } - if (nI == nILast || nI == 0) { - break; - } - } - if (bestChroma >= maxChroma) { - pColor->spec.CIELuv.L_star = maxLstar; - pColor->spec.CIELuv.u_star = Luv_max.spec.CIELuv.u_star; - pColor->spec.CIELuv.v_star = Luv_max.spec.CIELuv.v_star; - } else { - pColor->spec.CIELuv.L_star = bestLstar; - pColor->spec.CIELuv.u_star = bestustar; - pColor->spec.CIELuv.v_star = bestvstar; + memcpy((char *)pColor, (char *)&tmp, sizeof(XcmsColor)); } + } + retval = _XcmsDIConvertColors(&myCCC, pColor, ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat); if (retval != XcmsFailure && pCompressed != NULL) { *(pCompressed + i) = True; } - } return(retval); } Index: xc/lib/X11/LuvMnL.c =================================================================== --- xc.orig/lib/X11/LuvMnL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvMnL.c 2005-11-22 08:28:20.000000000 +0100 @@ -41,9 +41,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_L_STAR (XcmsFloat)40.0 +#define START_L_STAR (XcmsFloat)0.0 /*black.*/ /************************************************************************ @@ -54,7 +54,7 @@ /* * NAME - * XcmsCIELuvQueryMinL - Compute max Lstar for a hue and chroma + * XcmsCIELuvQueryMinL - Compute min Lstar for a hue and chroma * * SYNOPSIS */ @@ -66,7 +66,7 @@ XcmsColor *pColor_return; /* * DESCRIPTION - * Return the maximum Lstar for a specified hue_angle and chroma. + * Return the minumum Lstar for a specified hue_angle and chroma. * * ASSUMPTIONS * This routine assumes that the white point associated with @@ -81,11 +81,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor max_lc, tmp, prev; - XcmsFloat max_chroma, tmp_chroma; - XcmsFloat hue, nT, nChroma, lastChroma, prevChroma; - XcmsFloat rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_L_star, prev_L_star; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -108,108 +106,55 @@ } hue = radians(hue_angle); - tmp.spec.CIELuv.L_star = START_L_STAR; - tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); - tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELuvFormat; - - /* Step 1: Obtain the maximum L_star and chroma for this hue. */ - if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star, - max_lc.spec.CIELuv.v_star); - - if (max_chroma <= chroma) { - /* - * If the chroma is greater than the chroma for the - * maximum L/chroma point then the L_star is the - * the L_star for the maximum L_star/chroma point. - * This is an error but I return the best approximation I can. - * Thus the inconsistency. - */ - memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - return(XcmsSuccess); - } - - /* - * If the chroma is equal to the chroma for the - * maximum L_star/chroma point then the L_star is the - * the L_star for the maximum L* and chroma point. - */ - /* if (max_chroma == chroma) { - * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - * return(XcmsSuccess); - * } - */ - - /* must do a bisection here to compute the maximum L* */ - /* save the structure input so that any elements that */ - /* are not touched are recopied later in the routine. */ - nChroma = chroma; - tmp_chroma = max_chroma; - lastChroma = -1.0; + tmp_L_star = START_L_STAR; + prev_L_star = tmp_L_star; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; + Factor = 10.0; for (nCount = 0; nCount < nMaxCount; nCount++) { - prevChroma = lastChroma; - lastChroma = tmp_chroma; - nT = (nChroma - max_chroma) / max_chroma * rFactor; - memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor)); - tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT); - tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT); - tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT); - tmp.format = XcmsRGBiFormat; - - /* convert from RGB to CIELuv */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } - /* Now check the return against what is expected */ - tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, - tmp.spec.CIELuv.v_star); - if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) { - /* Found It! */ - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); + tmp.spec.CIELuv.L_star = tmp_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + + /* convert from CIELuv to RGBi */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + if ((tmp.spec.RGBi.red >= 0.0) & (tmp.spec.RGBi.green >= 0.0) & + (tmp.spec.RGBi.blue >= 0.0) & (tmp.spec.RGBi.red <= 1.0) & + (tmp.spec.RGBi.green <= 1.0) & (tmp.spec.RGBi.blue <= 1.0)) + { + tmp_L_star = prev_L_star; + Factor = Factor/10.0; } - nChroma += chroma - tmp_chroma; - if (nChroma > max_chroma) { - nChroma = max_chroma; - rFactor *= 0.5; /* selective relaxation employed */ - } else if (nChroma < 0.0) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); - } - return(XcmsSuccess); - } else if (tmp_chroma <= prevChroma + EPS && - tmp_chroma >= prevChroma - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ + if (Factor <= EPS) { + /* Found It! */ + tmp.spec.CIELuv.L_star = tmp_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); + return(XcmsSuccess); } - } + prev_L_star = tmp_L_star; + tmp_L_star = tmp_L_star + Factor; - if (nCount >= nMaxCount) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); + if (tmp_L_star >= 100.0) + { + XcmsCIELuvQueryMaxLC(&myCCC, hue_angle, pColor_return); + return(XcmsSuccess); } - } - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); +} + +if (nCount >= nMaxCount) { + tmp.spec.CIELuv.L_star = prev_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); +} + +return(XcmsSuccess); } Index: xc/lib/X11/LuvMxC.c =================================================================== --- xc.orig/lib/X11/LuvMxC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvMxC.c 2005-11-22 08:29:21.000000000 +0100 @@ -43,10 +43,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_CHROMA (XcmsFloat)2.2 -#define TOPL (XcmsFloat)100.0 +#define START_CHROMA (XcmsFloat)0.0 /************************************************************************ @@ -86,11 +85,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor tmp; - XcmsColor max_lc; - XcmsFloat n_L_star, last_L_star, prev_L_star; - XcmsFloat hue, lastuStar, lastvStar, /*lastChroma,*/ maxDist, nT, rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_chroma, prev_chroma; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -100,7 +97,7 @@ return(XcmsFailure); } - /* Use my own CCC and inherit screen white Pt */ + /* Use my own CCC and inherit screen white Pt */ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec)); myCCC.clientWhitePt.format = XcmsUndefinedFormat; myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */ @@ -113,91 +110,62 @@ } hue = radians(hue_angle); - tmp.spec.CIELuv.L_star = L_star; - tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA); - tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELuvFormat; - - /* Step 1: compute the maximum L_star and chroma for this hue. */ - memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor)); - if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - /* - * Step 2: Do a bisection here to compute the maximum chroma - * Note the differences between when the point to be found - * is above the maximum LC point and when it is below. - */ - if (L_star <= max_lc.spec.CIELuv.L_star) { - maxDist = max_lc.spec.CIELuv.L_star; - } else { - maxDist = TOPL - max_lc.spec.CIELuv.L_star; - } - - n_L_star = L_star; - last_L_star = -1.0; + tmp_chroma = START_CHROMA; + prev_chroma = tmp_chroma; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; + Factor = 10.0; - for (nCount = 0; nCount < nMaxCount; nCount++) { - prev_L_star = last_L_star; - last_L_star = tmp.spec.CIELuv.L_star; -/* lastChroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, */ -/* tmp.spec.CIELuv.v_star); */ - lastuStar = tmp.spec.CIELuv.u_star; - lastvStar = tmp.spec.CIELuv.v_star; - nT = (n_L_star - max_lc.spec.CIELuv.L_star) / maxDist * rFactor; - /* printf("(n_L_star, nT) = %lf %lf ", n_L_star, nT); */ - if (nT > 0) { - tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT; - tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT; - tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT; - } else { - tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT); - tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT); - tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT); - } - tmp.format = XcmsRGBiFormat; + for (nCount = 0; nCount < nMaxCount; nCount++) + { - /* convert from RGB to CIELuv */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } - - /* - * Now check if we've reached the target L_star - */ - /* printf("result Lstar = %lf\n", tmp.spec.CIELuv.L_star); */ - if (tmp.spec.CIELuv.L_star <= L_star + EPS && - tmp.spec.CIELuv.L_star >= L_star - EPS) { + tmp.spec.CIELuv.L_star = L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, tmp_chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, tmp_chroma); + tmp.format = XcmsCIELuvFormat; + + if (((L_star == 0.0) & (tmp_chroma == 0.0)) | + ((L_star == 100.0) & (tmp_chroma == 0.0))) + { + tmp.spec.CIELuv.L_star = L_star; + tmp.spec.CIELuv.u_star = 0.0; + tmp.spec.CIELuv.v_star = 0.0; + tmp.format = XcmsCIELuvFormat; memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); return(XcmsSuccess); } - if (nT > 0) { - n_L_star += ((TOPL - n_L_star) * - (L_star - tmp.spec.CIELuv.L_star)) / (TOPL - L_star); - } else { - n_L_star *= L_star / tmp.spec.CIELuv.L_star; + + /* convert from CIELuv to RGBi. */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + + if ((tmp.spec.RGBi.red < 0.0) | (tmp.spec.RGBi.green < 0.0) | + (tmp.spec.RGBi.blue < 0.0) | (tmp.spec.RGBi.red > 1.0) | + (tmp.spec.RGBi.green > 1.0) | (tmp.spec.RGBi.blue > 1.0)) + { + tmp_chroma = prev_chroma; + Factor = Factor/10.0; } - if (tmp.spec.CIELuv.L_star <= prev_L_star + EPS && - tmp.spec.CIELuv.L_star >= prev_L_star - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ - /* printf("rFactor = %lf\n", rFactor); */ + if (Factor <= EPS) + { + tmp.spec.CIELuv.L_star = L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, tmp_chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, tmp_chroma); + tmp.format = XcmsCIELuvFormat; + memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); + return(XcmsSuccess); } + prev_chroma = tmp_chroma; + tmp_chroma = tmp_chroma + Factor; } - if (XCMS_FABS(last_L_star - L_star) < - XCMS_FABS(tmp.spec.CIELuv.L_star - L_star)) { - tmp.spec.CIELuv.u_star = lastuStar; - tmp.spec.CIELuv.v_star = lastvStar; -/* tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, lastChroma); */ -/* tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, lastChroma); */ + + if (nCount >= nMaxCount) + { + tmp.spec.CIELuv.L_star = L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, prev_chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, prev_chroma); + tmp.format = XcmsCIELuvFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); } - tmp.spec.CIELuv.L_star = L_star; - memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); - return(XcmsSuccess); +return(XcmsSuccess); } Index: xc/lib/X11/LuvMxL.c =================================================================== --- xc.orig/lib/X11/LuvMxL.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvMxL.c 2005-11-22 08:30:29.000000000 +0100 @@ -41,9 +41,9 @@ /* * DEFINES */ -#define MAXBISECTCOUNT 100 +#define MAXBISECTCOUNT 200 #define EPS (XcmsFloat)0.001 -#define START_L_STAR (XcmsFloat)40.0 +#define START_L_STAR (XcmsFloat)100.0 /*white.*/ /************************************************************************ @@ -54,7 +54,7 @@ /* * NAME - * XcmsCIELuvQueryMaxL - Compute max Lstar for a hue and chroma + * XcmsCIELuvQueryMaxL - Compute min Lstar for a hue and chroma * * SYNOPSIS */ @@ -81,11 +81,9 @@ */ { XcmsCCCRec myCCC; - XcmsColor max_lc, tmp, prev; - XcmsFloat max_chroma, tmp_chroma; - XcmsFloat hue, nT, nChroma, lastChroma, prevChroma; - XcmsFloat rFactor; - XcmsRGBi rgb_saved; + XcmsColor tmp; + XcmsFloat tmp_L_star, prev_L_star; + XcmsFloat hue, Factor; int nCount, nMaxCount; /* @@ -108,108 +106,55 @@ } hue = radians(hue_angle); - tmp.spec.CIELuv.L_star = START_L_STAR; - tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); - tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); - tmp.pixel = pColor_return->pixel; - tmp.format = XcmsCIELuvFormat; - - /* Step 1: Obtain the maximum L_star and chroma for this hue. */ - if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved) - == XcmsFailure) { - return(XcmsFailure); - } - - max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star, - max_lc.spec.CIELuv.v_star); - - if (max_chroma <= chroma) { - /* - * If the chroma is greater than the chroma for the - * maximum L/chroma point then the L_star is the - * the L_star for the maximum L_star/chroma point. - * This is an error but I return the best approximation I can. - * Thus the inconsistency. - */ - memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - return(XcmsSuccess); - } - - /* - * If the chroma is equal to the chroma for the - * maximum L_star/chroma point then the L_star is the - * the L_star for the maximum L* and chroma point. - */ - /* if (max_chroma == chroma) { - * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor)); - * return(XcmsSuccess); - * } - */ - - /* must do a bisection here to compute the maximum L* */ - /* save the structure input so that any elements that */ - /* are not touched are recopied later in the routine. */ - nChroma = chroma; - tmp_chroma = max_chroma; - lastChroma = -1.0; + tmp_L_star = START_L_STAR; + prev_L_star = tmp_L_star; nMaxCount = MAXBISECTCOUNT; - rFactor = 1.0; + Factor = 10.0; for (nCount = 0; nCount < nMaxCount; nCount++) { - prevChroma = lastChroma; - lastChroma = tmp_chroma; - nT = (1.0 - (nChroma / max_chroma)) * rFactor; - memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor)); - tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT; - tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT; - tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT; - tmp.format = XcmsRGBiFormat; - - /* convert from RGB to CIELuv */ - if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp, - ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat, - (Bool *) NULL) == XcmsFailure) { - return(XcmsFailure); - } - /* Now check the return against what is expected */ - tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, - tmp.spec.CIELuv.v_star); - if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) { - /* Found It! */ - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); + tmp.spec.CIELuv.L_star = tmp_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + + /* convert from CIELuv to RGBi */ + _XcmsConvertColorsWithWhitePt(&myCCC, &tmp, + ScreenWhitePointOfCCC(&myCCC), 1, XcmsRGBiFormat, + (Bool *) NULL); + if ((tmp.spec.RGBi.red >= 0.0) & (tmp.spec.RGBi.green >= 0.0) & + (tmp.spec.RGBi.blue >= 0.0) & (tmp.spec.RGBi.red <= 1.0) & + (tmp.spec.RGBi.green <= 1.0) & (tmp.spec.RGBi.blue <= 1.0)) + { + tmp_L_star = prev_L_star; + Factor = Factor/10.0; } - nChroma += chroma - tmp_chroma; - if (nChroma > max_chroma) { - nChroma = max_chroma; - rFactor *= 0.5; /* selective relaxation employed */ - } else if (nChroma < 0.0) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); - } - return(XcmsSuccess); - } else if (tmp_chroma <= prevChroma + EPS && - tmp_chroma >= prevChroma - EPS) { - rFactor *= 0.5; /* selective relaxation employed */ + if (Factor <= EPS) { + /* Found It! */ + tmp.spec.CIELuv.L_star = tmp_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); + return(XcmsSuccess); } - } + prev_L_star = tmp_L_star; + tmp_L_star = tmp_L_star - Factor; - if (nCount >= nMaxCount) { - if (XCMS_FABS(lastChroma - chroma) < - XCMS_FABS(tmp_chroma - chroma)) { - memcpy ((char *)pColor_return, (char *)&prev, - sizeof(XcmsColor)); - } else { - memcpy ((char *)pColor_return, (char *)&tmp, - sizeof(XcmsColor)); + if (tmp_L_star <= 0.0) + { + XcmsCIELuvQueryMaxLC(&myCCC, hue_angle, pColor_return); + return(XcmsSuccess); } - } - memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor)); - return(XcmsSuccess); +} + +if (nCount >= nMaxCount) { + tmp.spec.CIELuv.L_star = prev_L_star; + tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma); + tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma); + tmp.format = XcmsCIELuvFormat; + memcpy ((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); + } + +return(XcmsSuccess); } Index: xc/lib/X11/LuvMxLC.c =================================================================== --- xc.orig/lib/X11/LuvMxLC.c 2005-11-22 08:07:53.000000000 +0100 +++ xc/lib/X11/LuvMxLC.c 2005-11-22 08:31:36.000000000 +0100 @@ -52,108 +52,11 @@ #define MAX(x,y) ((x) > (y) ? (x) : (y)) #define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z)))) #define START_LSTAR (XcmsFloat)40.0 -#define START_CHROMA (XcmsFloat)2.2 - - -/************************************************************************ - * * - * API PRIVATE ROUTINES * - * * - ************************************************************************/ - -/* - * NAME - * _XcmsCIELuvQueryMaxLCRGB - Compute maximum L* and chroma. - * - * SYNOPSIS - */ -Status -_XcmsCIELuvQueryMaxLCRGB( - XcmsCCC ccc, - XcmsFloat hue, /* hue in radians */ - XcmsColor *pColor_return, - XcmsRGBi *pRGB_return) -/* - * DESCRIPTION - * Return the maximum psychometric chroma for a specified - * hue angle(radians), and the corresponding L*. This is computed - * by a binary search of all possible chromas. An assumption - * is made that there are no local maxima. Use the unrounded - * Max psychometric chroma because the difference check can be - * small. - * - * NOTE: No local CCC is used because this is a private - * routine and all routines that call it are expected - * to behave properly, i.e. send a local CCC with - * no white adjust function and no gamut compression - * function. - * - * This routine only accepts hue as input and outputs - * Luv and RGBi. - * - * RETURNS - * XcmsFailure - Failure - * XcmsSuccess - Succeeded - * - */ -{ - XcmsFloat nSmall, nLarge; - XcmsColor tmp; - - tmp.format = XcmsCIELuvFormat; - /* Use some unreachable color on the given hue angle */ - tmp.spec.CIELuv.L_star = START_LSTAR; - tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA); - tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA); - /* - * Convert from Luv to RGB - * - * Note that the CIEXYZ to RGBi conversion routine must stuff the - * out of bounds RGBi values in tmp when the ccc->gamutCompProc - * is NULL. - */ - if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc), - (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL) - == XcmsFailure) && tmp.format != XcmsRGBiFormat) { - return (XcmsFailure); - } - - /* Now pick the smallest RGB */ - nSmall = MIN3(tmp.spec.RGBi.red, - tmp.spec.RGBi.green, - tmp.spec.RGBi.blue); - /* Make the smallest RGB equal to zero */ - tmp.spec.RGBi.red -= nSmall; - tmp.spec.RGBi.green -= nSmall; - tmp.spec.RGBi.blue -= nSmall; - - /* Now pick the largest RGB */ - nLarge = MAX3(tmp.spec.RGBi.red, - tmp.spec.RGBi.green, - tmp.spec.RGBi.blue); - /* Scale the RGB values based on the largest one */ - tmp.spec.RGBi.red /= nLarge; - tmp.spec.RGBi.green /= nLarge; - tmp.spec.RGBi.blue /= nLarge; - tmp.format = XcmsRGBiFormat; - - /* If the calling routine wants RGB value give them the ones used. */ - if (pRGB_return) { - pRGB_return->red = tmp.spec.RGBi.red; - pRGB_return->green = tmp.spec.RGBi.green; - pRGB_return->blue = tmp.spec.RGBi.blue; - } - - /* Convert from RGBi to Luv */ - if (_XcmsConvertColorsWithWhitePt(ccc, &tmp, - ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat, (Bool *) NULL) - == XcmsFailure) { - return (XcmsFailure); - } - - memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor)); - return (XcmsSuccess); -} +#define START_CHROMA (XcmsFloat)3.6 +#define START_LSTAR2 (XcmsFloat)0.0 +#define START_CHROMA2 (XcmsFloat)0.0 +#define MAXBISECTCOUNT 200 +#define EPS (XcmsFloat)0.001 /************************************************************************ @@ -192,6 +95,11 @@ */ { XcmsCCCRec myCCC; + XcmsFloat tmp_chroma, prev1_chroma, prev2_chroma; + XcmsFloat tmp_L_star, prev1_L_star, prev2_L_star; + XcmsFloat hue, Factor; + XcmsColor tmp_color; + int nCount, nMaxCount; /* * Check Arguments @@ -211,7 +119,56 @@ while (hue_angle >= 360.0) { hue_angle -= 360.0; } + hue = radians(hue_angle); + tmp_L_star = START_LSTAR2; + prev1_L_star = tmp_L_star; + prev2_L_star = prev1_L_star; + tmp_chroma = START_CHROMA2; + prev1_chroma = tmp_chroma; + prev2_chroma = prev1_chroma; + nMaxCount = MAXBISECTCOUNT; + Factor = 10.0; + + for (nCount = 0; nCount < nMaxCount; nCount++) { - return(_XcmsCIELuvQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return, - (XcmsRGBi *)NULL)); + XcmsCIELuvQueryMaxC(&myCCC, hue_angle, tmp_L_star, &tmp_color); + + prev2_chroma = prev1_chroma; + prev1_chroma = tmp_chroma; + tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp_color.spec.CIELuv.u_star, + tmp_color.spec.CIELuv.v_star); + if (tmp_chroma <= prev1_chroma) + { + tmp_chroma = prev2_chroma; + prev1_chroma = prev2_chroma; + tmp_L_star = prev2_L_star; + prev1_L_star = prev2_L_star; + Factor = Factor/10.0; + + if (Factor <= EPS) + { + tmp_color.spec.CIELuv.L_star = tmp_L_star; + tmp_color.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, tmp_chroma); + tmp_color.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, tmp_chroma); + tmp_color.format = XcmsCIELuvFormat; + memcpy ((char *)pColor_return, (char *)&tmp_color, sizeof(XcmsColor)); + return(XcmsSuccess); + } + } + prev2_L_star = prev1_L_star; + prev1_L_star = tmp_L_star; + tmp_L_star = tmp_L_star + Factor; + if (tmp_L_star >= 100.0) {tmp_L_star = 100.0;} + } + +if (nCount >= nMaxCount) { + tmp_color.spec.CIELuv.L_star = prev1_L_star; + tmp_color.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, prev1_chroma); + tmp_color.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, prev1_chroma); + tmp_color.format = XcmsCIELuvFormat; + memcpy ((char *)pColor_return, (char *)&tmp_color, sizeof(XcmsColor)); } + +return(XcmsSuccess); +} +/* palette.c * * Compilation: * * cc -ansi -Wall -o palette -L /usr/X11R6/lib -lX11 palette.c * Usage: * * anytopnm image.jpg | pndepth 65535 | pnmtoplainpnm > image.ppm * ./palette -display <hostname:display_number.screen_number> * -delta 2.0 image.ppm > image_delta2.ppm * * * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xcms.h> int main (int argc, char *argv[]) { FILE *g; Display *display; int nuances, width, height, c, l, p, nombre; unsigned long n; XcmsColor *color, *color2, *white_point; char *q, *signature, *fichier, *display_name; Colormap colormap; XcmsCCC ccc; Bool *test; float delta_E; if (argc < 6) { printf ("Usage :\n\t./palette -display \ hostname:number.screen_number -delta <float> <fichier.ppm>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./palette -display \ hostname:number.screen_number -delta <float> <fichier.ppm>.\n"); exit (1); } if (strcmp(argv[3], "-delta") != 0) { printf ("Usage :\n\t./palette -display \ hostname:number.screen_number -delta <float> <fichier.ppm>.\n"); exit (1); } display_name = argv[2]; display = XOpenDisplay(display_name); if (! display) { printf("cannot open display.\n"); exit(1); } delta_E = atof(argv[4]); if (! delta_E) { printf("delta ?\n"); exit(1); } fichier = argv[5]; g = fopen(fichier, "r"); if (! g) { printf("%s ?\n", fichier); exit(1); } colormap = XDefaultColormap(display, XDefaultScreen(display)); ccc = XcmsCCCOfColormap(display, colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); signature = malloc(3*sizeof(char)); q = malloc(128*sizeof(char)); test = malloc(sizeof(Bool)); l = 0; n = 0; p = 0; c = 0; color = malloc(sizeof(XcmsColor)); color2 = malloc(sizeof(XcmsColor)); while (c != -1) { c = fgetc (g); q[l] = c; if (c == -1 || c == '\n' || c == '\t' || c == ' ') { if (l > 0) { n++; if (n == 1) { signature = q; signature[2]=0; if (strcmp(signature, "P3") != 0) { printf("Must be plain pnm.\n"); exit(1); } } if (n == 2) width = atoi(q); if (n == 3) height = atoi(q); if (n == 4) { nuances = atoi(q); if (nuances != 65535) { printf("Must be depth 65536.\n"); exit (1); } printf("P3\n%d %d\n65535\n", width, height); } if (n >= 5) { nombre = atoi(q); p ++; if (p == 1) color->spec.RGB.red = nombre; if (p == 2) color->spec.RGB.green = nombre; if (p == 3) { color->spec.RGB.blue = nombre; color->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color, 1, test); XcmsRGBiToCIEXYZ(ccc, color, 1, test); XcmsCIEXYZToCIELab(ccc, white_point, color, 1); color->spec.CIELab.L_star = delta_E * (int) (color->spec.CIELab.L_star/delta_E); color->spec.CIELab.a_star = delta_E * (int) (color->spec.CIELab.a_star/delta_E); color->spec.CIELab.b_star = delta_E * (int) (color->spec.CIELab.b_star/delta_E); color2->spec.CIELab.L_star = color->spec.CIELab.L_star; color2->spec.CIELab.b_star = color->spec.CIELab.b_star; color2->spec.CIELab.a_star = color->spec.CIELab.a_star; color2->format = XcmsCIELabFormat; XcmsCIELabToCIEXYZ(ccc, white_point, color, 1); XcmsCIEXYZToRGBi(ccc, color, 1, test); if ((color->spec.RGBi.red < 0) | (color->spec.RGBi.green < 0) | (color->spec.RGBi.blue < 0) | (color->spec.RGBi.red > 1) | (color->spec.RGBi.green > 1) | (color->spec.RGBi.blue > 1)) { XcmsCIELabToCIEXYZ(ccc, white_point, color2, 1); XcmsCIELabClipab(ccc, color2, 1, 0, test); XcmsCIEXYZToRGBi(ccc, color2, 1, test); color->spec.RGBi.red = color2->spec.RGBi.red; color->spec.RGBi.green = color2->spec.RGBi.green; color->spec.RGBi.blue = color2->spec.RGBi.blue; color->format = XcmsRGBiFormat; } XcmsRGBiToRGB(ccc, color, 1, test); printf("%d %d %d\n", color->spec.RGB.red, color->spec.RGB.green, color->spec.RGB.blue); p = 0; } } } l = 0; } else { l++; } } fclose(g); free(q); XFree(color); XFree(color2); XFree(white_point); free(test); return 0; }/* view_xpm.c * * Compilation: * cc -ansi -Wall -o view_xpm -L /usr/X11R6/lib -lX11 view_xpm.c * * Usage: * ./view_xpm -display <hostname:display_number.screen_number> -zoom <unsigned int> image.xpm * * * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xcms.h> #include <X11/cursorfont.h> #include <X11/Xutil.h> int main (int argc, char * argv[]) { FILE *g; Display *display; int *n_item; XVisualInfo *visual_info, *visual_tmp; unsigned long *pixels, *rmask_return, *gmask_return, *bmask_return; Colormap colormap; int width, height, nb_colors, chars_per_pixel; int red_min, red_max, green_max, green_min, blue_min, blue_max; XImage *image, *sub_image; XcmsColor *color, *color_return, *white_point; int l, a, count_height, count_width, zoom, x, y; unsigned long number, total_bytes, bytes; long *couleurs, pic; char *p, *q, *code, *rouge, *vert, *bleu; char *lecture, indice1, indice2, indice3; char *string, *string2, *font_name; Status status; Window parent, window, window_quitter, window_right, window_left; Window window_up, window_down, window_image, window_fin; Pixmap pixmap_quitter, pixmap_right, pixmap_left; Pixmap pixmap_up, pixmap_down, pixmap_image, pixmap_fin; Cursor cursor; Font font; XSetWindowAttributes attributes; XGCValues *values; GC gc; XEvent event; Window *root_return, *child_return; int *root_x_return, *root_y_return; int *win_x_return, *win_y_return; unsigned int *mask_return; XcmsCCC ccc; Bool *test; /* Open. */ if (argc < 6) { printf ("Usage :\n\t./view_xpm \ -display hostname:number.screen_number -zoom <unsigned int> <fichier.xpm>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./view_xpm \ -display hostname:number.screen_number -zoom <unsigned int> <fichier.xpm>.\n"); exit (1); } if (strcmp(argv[3], "-zoom") != 0) { printf ("Usage :\n\t./view_xpm \ -display hostname:number.screen_number -zoom <unsigned int> <fichier.xpm>.\n"); exit (1); } display = XOpenDisplay(argv[2]); if (! display) { printf("cannot open display.\n"); exit(1); } zoom = atoi(argv[4]); if (! zoom) { printf("zoom ?\n"); exit(1); } g = fopen(argv[5], "r"); if(! g) { printf("%s ?\n", argv[5]); exit(1); } /* Visual.*/ n_item = malloc(sizeof(unsigned int)*8); visual_info = malloc(sizeof(XVisualInfo)*32); visual_tmp = malloc(sizeof(XVisualInfo)); visual_tmp->class = DirectColor; visual_info = XGetVisualInfo(display, VisualClassMask, visual_tmp, n_item); if (! visual_info) printf("cannot open \"Visual DirectColor\"\n"); XFree(visual_tmp); XFree(n_item); /* Colormap */ parent = XDefaultRootWindow(display); rmask_return = malloc(sizeof(unsigned long)*8); gmask_return = malloc(sizeof(unsigned long)*8); bmask_return = malloc(sizeof(unsigned long)*8); pixels = malloc(sizeof(unsigned long)*65535); colormap = XCreateColormap(display, parent, visual_info->visual, AllocNone); if (visual_info->depth == 8) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 3, 3, 2, rmask_return, gmask_return, bmask_return); if ((visual_info->depth == 15) | (visual_info->depth == 24)) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, visual_info->depth/3, visual_info->depth/3, visual_info->depth/3, rmask_return, gmask_return, bmask_return); if (visual_info->depth == 16) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 5, 6, 5, rmask_return, gmask_return, bmask_return); if (status == 0) printf("XAllocColorPlanes status 0\n"); /* Head XPM file. */ q = malloc(128); fgets(q, 80, g); /* XPM */ q[strlen(q)-1] = 0; if (strcmp(q, "/* XPM */") != 0) { printf("XPM file ?\n"); exit(1); } fgets(q, 80, g); q[strlen(q) -5] = 0; fgets(q, 80, g); if (q[0] == '/')fgets(q, 80, g); /*hints_cmt ?*/ q[0] = ' '; q[strlen(q)-3] = 0; p = strchr(q, ' '); p++; width = atoi((const char *) p); p = strchr(p, ' '); p++; height = atoi((const char *) p); p = strchr(p, ' '); p++; nb_colors = atoi((const char *) p); p = strchr(p, ' '); p++; chars_per_pixel = atoi((const char *) p); printf("width : %d, height : %d, nb_colors : %d, chars_per_pixel : %d\n", width, height, nb_colors, chars_per_pixel); /* Open Image.*/ image = XCreateImage(display, visual_info->visual, visual_info->depth, ZPixmap, 0, 0, width/zoom, height/zoom, 32, 0); image->data = (char *) malloc(image->bytes_per_line * (image->height + 2)); couleurs = malloc(857376*sizeof(unsigned long)); /* First read for maxima and minima.*/ rouge = malloc(4*sizeof(char)); vert = malloc(4*sizeof(char)); bleu = malloc(4*sizeof(char)); color = malloc(sizeof(XcmsColor)); color_return = malloc(sizeof(XcmsColor)); red_max = green_max = blue_max = 0; red_min = green_min = blue_min = 65535; for (l = 0; l < nb_colors; l++) { fgets(q, 80, g); if ((l == 0) & (q[0] == '/')) fgets(q, 80, g); /* colors_cmt ? */ q[0] = ' '; q[strlen(q)-3] = 0; p = q + 1 + chars_per_pixel + 3; if (p[0] == '#') { p = p+1; p = strtok(p, " "); strncpy(rouge, p, strlen(p)/3); strncpy(vert, p+strlen(p)/3, strlen(p)/3); strncpy(bleu, p+strlen(p)*2/3, strlen(p)/3); color->spec.RGB.red = (unsigned long) strtol(rouge, NULL, 16); color->spec.RGB.green = (unsigned long) strtol(vert, NULL, 16); color->spec.RGB.blue = (unsigned long) strtol(bleu, NULL, 16); if (strlen(p) == 6) { color->spec.RGB.red = color->spec.RGB.red*257; color->spec.RGB.green = color->spec.RGB.green*257; color->spec.RGB.blue = color->spec.RGB.blue*257; } if (color->spec.RGB.red > red_max) red_max = color->spec.RGB.red; if (color->spec.RGB.red < red_min) red_min = color->spec.RGB.red; if (color->spec.RGB.green > green_max) green_max = color->spec.RGB.green; if (color->spec.RGB.green < green_min) green_min = color->spec.RGB.green; if (color->spec.RGB.blue > blue_max) blue_max = color->spec.RGB.blue; if (color->spec.RGB.blue < blue_min) blue_min = color->spec.RGB.blue; }else{ string = (char *) strtok(p, " "); status = XcmsLookupColor(display, colormap, string, color, color_return, XcmsRGBFormat); if (status != 0) { if (color->spec.RGB.red > red_max) red_max = color->spec.RGB.red; if (color->spec.RGB.red < red_min) red_min = color->spec.RGB.red; if (color->spec.RGB.green > green_max) green_max = color->spec.RGB.green; if (color->spec.RGB.green < green_min) green_min = color->spec.RGB.green; if (color->spec.RGB.blue > blue_max) blue_max = color->spec.RGB.blue; if (color->spec.RGB.blue < blue_min) blue_min = color->spec.RGB.blue; } } } fclose(g); /* Second read for colormap. * * */ g = fopen(argv[5], "r"); code = malloc(12*sizeof(char)); lecture = malloc(12*sizeof(char)); q = NULL; q = malloc(128); fgets(q, 80, g); /* XPM */ fgets(q, 80, g); fgets(q, 80, g); /* hints_cmt ? */ if (q[0] == '/')fgets(q, 80, g); for (l = 0; l < nb_colors; l++) { fgets(q, 80, g); /* color_cmt ? */ if ((l == 0) & (q[0] == '/'))fgets(q, 80, g); q[0] = ' '; q[strlen(q)-3] = 0; code[0] = 32; code[1] = 32; code[2] = 32; strncpy(code, q+1, chars_per_pixel); indice1 = code[0]-32; indice2 = code[1]-32; indice3 = code[2]-32; number = indice1 + indice2*95 + indice3*95*95; p = q + 1 + chars_per_pixel + 3; if (p[0] == '#') { p = p + 1; p = strtok(p, " "); strncpy(rouge, p, strlen(p)/3); strncpy(vert, p+strlen(p)/3, strlen(p)/3); strncpy(bleu, p+strlen(p)*2/3, strlen(p)/3); color->spec.RGB.red = (unsigned long) strtol(rouge, NULL, 16); color->spec.RGB.green = (unsigned long) strtol(vert, NULL, 16); color->spec.RGB.blue = (unsigned long) strtol(bleu, NULL, 16); if (strlen(p) == 6) { color->spec.RGB.red = color->spec.RGB.red*257; color->spec.RGB.green = color->spec.RGB.green*257; color->spec.RGB.blue = color->spec.RGB.blue*257; } color->format = XcmsRGBFormat; if ((visual_info->depth == 15) | (visual_info->depth == 24)) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/(65536/visual_info->colormap_size) + (color->spec.RGB.green - green_min)*(65535/green_max)/(65536/visual_info->colormap_size) *visual_info->colormap_size + (color->spec.RGB.red - red_min)*(65535/red_max)/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/2048 + (color->spec.RGB.green - green_min)*(65535/green_max)/1024*32 + (color->spec.RGB.red - red_min)*(65535/red_max)/2048*64*32; if (visual_info->depth == 8) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/16384*8*8 + (color->spec.RGB.green - green_min)*(65535/green_max)/8192*8 + (color->spec.RGB.red - red_min)*(65535/red_max)/8192; XcmsStoreColor(display, colormap, color); XcmsQueryColor(display, colormap, color, XcmsRGBFormat); couleurs[number] = color->pixel; }else{ string = (char *) strtok(p, " "); status = XcmsLookupColor(display, colormap, string, color, color_return, XcmsRGBFormat); if (status == 0) { printf("xpm : bad color: %s\n", string); }else{ if ((visual_info->depth == 15) | (visual_info->depth == 24)) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/(65536/visual_info->colormap_size) + (color->spec.RGB.green - green_min)*(65535/green_max)/(65536/visual_info->colormap_size) *visual_info->colormap_size + (color->spec.RGB.red - red_min)*(65535/red_max)/(65536/visual_info->colormap_size) *visual_info->colormap_size*visual_info->colormap_size; if (visual_info->depth == 16) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/2048 + (color->spec.RGB.green - green_min)*(65535/green_max)/1024*32 + (color->spec.RGB.red - red_min)*(65535/red_max)/2048*64*32; if (visual_info->depth == 8) color->pixel = (color->spec.RGB.blue - blue_min)*(65535/blue_max)/16384*8*8 + (color->spec.RGB.green - green_min)*(65535/green_max)/8192*8 + (color->spec.RGB.red - red_min)*(65535/red_max)/8192; XcmsStoreColor(display, colormap, color); XcmsQueryColor(display, colormap, color, XcmsRGBFormat); couleurs[number] = color->pixel; } } } count_height = zoom; total_bytes = 0; q = realloc(q, width*chars_per_pixel*sizeof(char)+256*chars_per_pixel*sizeof(char)); for (l = 0; l < height; l++) { fgets(q, width*chars_per_pixel+16, g); if ((l == 0) & (q[0] == '/'))fgets(q, width*chars_per_pixel+16, g); /* pixels_cmt ?*/ q[0] = ' '; q[strlen(q)-2] = 0; if (l < height-1) q[strlen(q) - 1] = 0; if (count_height == zoom) { count_height = 0; count_width = zoom; bytes = 0; for(a = 0; a < width +128; a++) { lecture[0] = 32; lecture[1] = 32; lecture[2] = 32; strncpy(lecture, q +1 +a*chars_per_pixel, chars_per_pixel); if (count_width == zoom) { count_width = 0; bytes = bytes + image->bits_per_pixel/8; if (bytes <= (image->width - 1)*(image->bits_per_pixel / 8)) { indice1 = lecture[0]-32; indice2 = lecture[1]-32; indice3 = lecture[2]-32; number = indice1 + indice2*95 + indice3*95*95; if(image->byte_order == LSBFirst) { if (image->bits_per_pixel == 8) { image->data[total_bytes] = (char) (couleurs[number] >> 0); } if (image->bits_per_pixel == 16) { image->data[total_bytes] = (char) (couleurs[number] >> 0); image->data[total_bytes+1] = (char) (couleurs[number] >> 8); } if(image->bits_per_pixel == 32) { image->data[total_bytes] = (char) (couleurs[number] >> 0); image->data[total_bytes+1] = (char) (couleurs[number] >> 8); image->data[total_bytes+2] = (char) (couleurs[number] >> 16); image->data[total_bytes+3] = (char) (couleurs[number] >> 24); } } if(image->byte_order == MSBFirst) { if (image->bits_per_pixel == 8) { image->data[total_bytes] = (char) (couleurs[number] >> 0); } if (image->bits_per_pixel == 16) { image->data[total_bytes] = (char) (couleurs[number] >> 8); image->data[total_bytes+1] = (char) (couleurs[number] >> 0); } if(image->bits_per_pixel == 32) { image->data[total_bytes] = (char) (couleurs[number] >> 24); image->data[total_bytes+1] = (char) (couleurs[number] >> 16); image->data[total_bytes+2] = (char) (couleurs[number] >> 8); image->data[total_bytes+3] = (char) (couleurs[number] >> 0); } } total_bytes = total_bytes + image->bits_per_pixel/8; if (bytes == (image->width - 1)*(image->bits_per_pixel / 8)) { total_bytes = total_bytes + image->bytes_per_line - bytes; } } } count_width++; } } count_height++; } /* Create Pixmap. */ pixmap_image = XCreatePixmap(display, parent, DisplayWidth(display, visual_info->screen)-50, DisplayHeight(display, visual_info->screen)-50-20, visual_info->depth); pixmap_up = XCreatePixmap(display, parent, 75, 19, visual_info->depth); pixmap_down = XCreatePixmap(display, parent, 75, 19, visual_info->depth); pixmap_left = XCreatePixmap(display, parent, 75, 19, visual_info->depth); pixmap_right = XCreatePixmap(display, parent, 75, 19, visual_info->depth); pixmap_quitter = XCreatePixmap(display, parent, 75, 19, visual_info->depth); pixmap_fin = XCreatePixmap(display, parent, DisplayWidth(display, visual_info->screen)-50-375, 19, visual_info->depth); /* Create GC.*/ font_name = "-adobe-times-medium-r-normal-*-12-120-75-75-p-64-iso8859-1"; font = XLoadFont(display, font_name); color->spec.RGB.red = red_max; color->spec.RGB.green = green_max; color->spec.RGB.blue = blue_max; color->format = XcmsRGBFormat; color->pixel = pixels[0] | rmask_return[0] | gmask_return[0] | bmask_return[0]; XcmsStoreColor(display, colormap, color); XcmsQueryColor(display, colormap, color, XcmsRGBFormat); values = malloc(sizeof(XGCValues)); values->font = font; values->foreground = color->pixel; gc = XCreateGC(display, pixmap_image, GCFont | GCForeground, values); /* Paint Pixmap.*/ XFillRectangle(display, pixmap_image, gc, 0, 0, DisplayWidth(display, visual_info->screen)-50, DisplayHeight(display, visual_info->screen)-50-20); XFillRectangle(display, pixmap_up, gc, 0, 0, 75, 19); XFillRectangle(display, pixmap_down, gc, 0, 0, 75, 19); XFillRectangle(display, pixmap_left, gc, 0, 0, 75, 19); XFillRectangle(display, pixmap_right, gc, 0, 0, 75, 19); XFillRectangle(display, pixmap_quitter, gc, 0, 0, 75, 19); XFillRectangle(display, pixmap_fin, gc, 0, 0, DisplayWidth(display, visual_info->screen)-50-375, 19); /* DrawString Pixmap */ color->spec.RGB.red = red_min; color->spec.RGB.green = green_min; color->spec.RGB.blue = blue_min; color->format = XcmsRGBFormat; color->pixel = pixels[0]; XcmsStoreColor(display, colormap, color); XcmsQueryColor(display, colormap, color, XcmsRGBFormat); XSetForeground(display, gc, color->pixel); XDrawString(display, pixmap_quitter, gc, 10, 12, "Quitter.", 8); XDrawString(display, pixmap_up, gc, 10, 12, "Haut.", 5); XDrawString(display, pixmap_down, gc, 10, 12, "Bas.", 4); XDrawString(display, pixmap_left, gc, 10, 12, "Gauche.", 7); XDrawString(display, pixmap_right, gc, 10, 12, "Droite.", 7); XDrawString(display, pixmap_fin, gc, 10, 12, "Coordonnées :", 12); /* PutImage Pixmap.*/ width = DisplayWidth(display, visual_info->screen)-50; if (image->width <= DisplayWidth(display, visual_info->screen)-50) width = image->width; height = DisplayHeight(display, visual_info->screen)-50-20; if (image->height <= DisplayHeight(display, visual_info->screen)-50-20) height = image->height; sub_image = XSubImage(image, 0, 0, width, height); XPutImage(display, pixmap_image, gc, sub_image, 0, 0, 0, 0, width, height); /* Create Windows.*/ cursor = XCreateFontCursor(display, 132); attributes.cursor = cursor; attributes.colormap = colormap; attributes.border_pixel = pixels[0]; attributes.event_mask = ButtonPressMask; window = XCreateWindow(display, parent, 0, 0, DisplayWidth(display, visual_info->screen)-50, DisplayHeight(display, visual_info->screen)-50, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixel | CWEventMask | CWCursor | CWColormap, &attributes); XStoreName(display, window, "view xpm"); attributes.background_pixmap = pixmap_image; attributes.event_mask = PointerMotionMask; window_image = XCreateWindow(display, window, 0, 20, DisplayWidth(display, visual_info->screen)-50, DisplayHeight(display, visual_info->screen)-50-20, 0, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap| CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_quitter; attributes.event_mask = ButtonPressMask; window_quitter = XCreateWindow(display, window, 0, 0, 75, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_up; window_up = XCreateWindow(display, window, 75, 0, 75, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_down; window_down = XCreateWindow(display, window, 150, 0, 75, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_left; window_left = XCreateWindow(display, window, 225, 0, 75, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_right; window_right = XCreateWindow(display, window, 300, 0, 75, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); attributes.background_pixmap = pixmap_fin; window_fin = XCreateWindow(display, window, 375, 0, DisplayWidth(display, visual_info->screen)-50-375, 19, 1, visual_info->depth, InputOutput, visual_info->visual, CWBorderPixel | CWBackPixmap | CWEventMask | CWCursor | CWColormap, &attributes); XInstallColormap(display, colormap); XMapWindow(display, window); XMapWindow(display, window_image); XMapWindow(display, window_quitter); XMapWindow(display, window_up); XMapWindow(display, window_down); XMapWindow(display, window_left); XMapWindow(display, window_right); XMapWindow(display, window_fin); /* Events. */ x = 0; y = 0; root_return = malloc(128); child_return = malloc(128); root_x_return = malloc(128); root_y_return = malloc(128); win_x_return = malloc(128); win_y_return = malloc(128); mask_return = malloc(128); string2 = malloc(256); ccc = XcmsCCCOfColormap(display, colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); test = malloc(sizeof(Bool)); while(1) { color->pixel = pixels[0] | rmask_return[0] | gmask_return[0] | bmask_return[0]; XSetForeground(display, gc, color->pixel); XFillRectangle(display, pixmap_fin, gc, 0, 0, DisplayWidth(display, visual_info->screen)-50-375, 19); color->pixel = pixels[0]; XSetForeground(display, gc, color->pixel); XQueryPointer(display, window_image, root_return, child_return, root_x_return, root_y_return, win_x_return, win_y_return, mask_return); if ((win_x_return[0] > 0) & (win_y_return[0] > 0) & (win_x_return[0] < sub_image->width) & (win_y_return[0] < sub_image->height)) { pic = XGetPixel(sub_image, win_x_return[0], win_y_return[0]); color->pixel = pic; XcmsQueryColor(display, colormap, color, XcmsRGBFormat); XcmsRGBToRGBi(ccc, color, 1, test); XcmsRGBiToCIEXYZ(ccc, color, 1, test); if (color->spec.CIEXYZ.Y > 1.0) color->spec.CIEXYZ.Y = 1.0; XcmsCIEXYZToCIELab(ccc, white_point, color, 1); sprintf(string2, "Coordonnées cartésiennes = (%04d, %04d) et colorimétriques (L*, a*, b*) = (%f, %f, %f)", win_x_return[0]+x, win_y_return[0]+y, color->spec.CIELab.L_star, color->spec.CIELab.a_star, color->spec.CIELab.b_star); XDrawString(display, pixmap_fin, gc, 10, 12, string2, strlen(string2)); } XClearArea(display, window_fin, 0, 0, DisplayWidth(display, visual_info->screen)-50-375, 19, 0); XNextEvent(display, &event); if(event.xkey.window == window_quitter) break; if(event.xkey.window == window_up) { y = y + 250; if (y >= image->height-height) y = image->height-height; XFillRectangle(display, pixmap_image, gc, 0, 0, width, height); sub_image = XSubImage(image, x, y, width, height); XPutImage(display, pixmap_image, gc, sub_image, 0, 0, 0, 0, width, height); XClearWindow(display, window_image); } if(event.xkey.window == window_down) { y = y - 250; if (y <= 0) y = 0; XFillRectangle(display, pixmap_image, gc, 0, 0, width, height); sub_image = XSubImage(image, x, y, width, height); XPutImage(display, pixmap_image, gc, sub_image, 0, 0, 0, 0, width, height); XClearWindow(display, window_image); } if(event.xkey.window == window_right) { x = x - 250; if (x <= 0) x = 0; XFillRectangle(display, pixmap_image, gc, 0, 0, width, height); sub_image = XSubImage(image, x, y, width, height); XPutImage(display, pixmap_image, gc, sub_image, 0, 0, 0, 0, width, height); XClearWindow(display, window_image); } if(event.xkey.window == window_left) { x = x + 250; if (x >= image->width-width) x = image->width-width; XFillRectangle(display, pixmap_image, gc, 0, 0, width, height); sub_image = XSubImage(image, x, y, width, height); XPutImage(display, pixmap_image, gc, sub_image, 0, 0, 0, 0, width, height); XClearWindow(display, window_image); } } /* Close. */ fclose(g); XFree(q); XUnmapWindow(display, window_image); XUnmapWindow(display, window_quitter); XUnmapWindow(display, window_up); XUnmapWindow(display, window_down); XUnmapWindow(display, window_left); XUnmapWindow(display, window_right); XUnmapWindow(display, window_fin); XUnmapWindow(display, window); XFreePixmap(display, pixmap_image); XFreePixmap(display, pixmap_quitter); XFreePixmap(display, pixmap_up); XFreePixmap(display, pixmap_down); XFreePixmap(display, pixmap_left); XFreePixmap(display, pixmap_right); XFreePixmap(display, pixmap_image); XFreePixmap(display, pixmap_fin); XDestroyWindow(display, window_image); XDestroyWindow(display, window_quitter); XDestroyWindow(display, window_up); XDestroyWindow(display, window_down); XDestroyWindow(display, window_left); XDestroyWindow(display, window_right); XDestroyWindow(display, window_fin); XDestroyWindow(display, window); XUninstallColormap(display, colormap); XFree(rmask_return); XFree(gmask_return); XFree(bmask_return); XFree(pixels); XFree(visual_info); XFree(values); XFreeGC(display, gc); XFree(color); XFree(color_return); XFree(image->data); XFree(code); XFree(lecture); XFree(rouge); XFree(vert); XFree(bleu); XFree(couleurs); return 22; }/* xpmcielab.c * * Compilation : * * cc -ansi -Wall -o xpmcielab -L /usr/X11R6/lib/ -lX11 -lm xpmcielab.c * * Usage : * * ./xpmcielab -display :0.0 image.xpm * * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xcms.h> #include <X11/Xutil.h> #include <math.h> int main (int argc, char * argv[]) { FILE *f, *g; Display *display; int *n_item; XVisualInfo *visual_info, *visual_tmp; unsigned long *pixels, *rmask_return, *gmask_return, *bmask_return; Colormap colormap; int width, height, nb_colors, chars_per_pixel; XcmsColor *color, *color_return, *color2, *white_point; int l; char *p, *q, *code, *rouge, *vert, *bleu, *lecture; char *string; Status status; Window parent; XcmsCCC ccc; Bool *test; /* Open. */ if (argc < 4) { printf ("Usage :\n\t./xpmcielab \ -display <hostname:number.screen_number> <fichier.xpm>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./xpmcielab \ -display <hostname:number.screen_number> <fichier.xpm>.\n"); exit (1); } display = XOpenDisplay(argv[2]); if (! display) { printf("cannot open display.\n"); exit(1); } g = fopen(argv[3], "r"); if(! g) { printf("%s ?\n", argv[3]); exit(1); } /* Visual.*/ n_item = malloc(sizeof(unsigned int)*8); visual_info = malloc(sizeof(XVisualInfo)*32); visual_tmp = malloc(sizeof(XVisualInfo)); visual_tmp->class = DirectColor; visual_info = XGetVisualInfo(display, VisualClassMask, visual_tmp, n_item); if (! visual_info) printf("cannot open \"Visual DirectColor\"\n"); XFree(visual_tmp); XFree(n_item); /* Colormap */ parent = XDefaultRootWindow(display); rmask_return = malloc(sizeof(unsigned long)*8); gmask_return = malloc(sizeof(unsigned long)*8); bmask_return = malloc(sizeof(unsigned long)*8); pixels = malloc(sizeof(unsigned long)*65535); colormap = XCreateColormap(display, parent, visual_info->visual, AllocNone); if (visual_info->depth == 8) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 3, 3, 2, rmask_return, gmask_return, bmask_return); if ((visual_info->depth == 15) | (visual_info->depth == 24)) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, visual_info->depth/3, visual_info->depth/3, visual_info->depth/3, rmask_return, gmask_return, bmask_return); if (visual_info->depth == 16) status = XAllocColorPlanes(display, colormap, 1, pixels, 1, 5, 6, 5, rmask_return, gmask_return, bmask_return); if (status == 0) printf("XAllocColorPlanes status 0\n"); /* XPM file. */ f = fopen("controle.xpm", "w"); q = malloc(128); rouge = malloc(4*sizeof(char)); vert = malloc(4*sizeof(char)); bleu = malloc(4*sizeof(char)); color = malloc(sizeof(XcmsColor)); color2 = malloc(sizeof(XcmsColor)); color_return = malloc(sizeof(XcmsColor)); ccc = XcmsCCCOfColormap(display, colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); test = malloc(sizeof(Bool)); code = malloc(12*sizeof(char)); lecture = malloc(12*sizeof(char)); q = NULL; q = malloc(128); fgets(q, 80, g);fprintf(f, "%s", q); /* XPM */ fgets(q, 80, g);fprintf(f, "%s", q); fgets(q, 80, g);fprintf(f, "%s", q); /* hints_cmt ? */ if (q[0] == '/') { fgets(q, 80, g); fprintf(f, "%s", q); } q[0] = ' '; q[strlen(q)-3] = 0; p = strchr(q, ' '); p++; width = atoi((const char *) p); p = strchr(p, ' '); p++; height = atoi((const char *) p); p = strchr(p, ' '); p++; nb_colors = atoi((const char *) p); p = strchr(p, ' '); p++; chars_per_pixel = atoi((const char *) p); for (l = 0; l < nb_colors; l++) { fgets(q, 80, g); /* color_cmt ? */ if ((l == 0) & (q[0] == '/')) { fprintf(f, "%s", q); fgets(q, 80, g); } q[0] = ' '; q[strlen(q)-3] = 0; code[0] = 0; code[1] = 0; code[2] = 0; strncpy(code, q+1, chars_per_pixel); if (chars_per_pixel == 1) fprintf(f, "\"%c s ", code[0]); if (chars_per_pixel == 2) fprintf(f, "\"%c%c s ", code[0], code[1] ); if (chars_per_pixel == 3) fprintf(f, "\"%c%c%c s ", code[0], code[1], code[2]); p = q + 1 + chars_per_pixel + 3; if (p[0] == '#') { p = p + 1; p = strtok(p, " "); strncpy(rouge, p, strlen(p)/3); strncpy(vert, p+strlen(p)/3, strlen(p)/3); strncpy(bleu, p+strlen(p)*2/3, strlen(p)/3); color->spec.RGB.red = (unsigned long) strtol(rouge, NULL, 16); color->spec.RGB.green = (unsigned long) strtol(vert, NULL, 16); color->spec.RGB.blue = (unsigned long) strtol(bleu, NULL, 16); if (strlen(p) == 6) { color->spec.RGB.red = color->spec.RGB.red*257; color->spec.RGB.green = color->spec.RGB.green*257; color->spec.RGB.blue = color->spec.RGB.blue*257; } color->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color, 1, test); XcmsRGBiToCIEXYZ(ccc, color, 1, test); if (color->spec.CIEXYZ.Y > 1.0) color->spec.CIEXYZ.Y = 1.0; XcmsCIEXYZToCIELab(ccc, white_point, color, 1); fprintf(f, "cielab:%.1f/%.1f/%.1f\",\n", color->spec.CIELab.L_star, color->spec.CIELab.a_star, color->spec.CIELab.b_star); }else{ string = (char *) strtok(p, " "); status = XcmsLookupColor(display, colormap, string, color, color_return, XcmsRGBFormat); if (status == 0) { printf("xpm : bad color: %s\n", string); fprintf(f, "%s\",\n", string); }else{ XcmsRGBToRGBi(ccc, color, 1, test); XcmsRGBiToCIEXYZ(ccc, color, 1, test); if (color->spec.CIEXYZ.Y > 1.0) color->spec.CIEXYZ.Y = 1.0; XcmsCIEXYZToCIELab(ccc, white_point, color, 1); fprintf(f, "cielab:%.1f/%.1f/%.1f\",\n", color->spec.CIELab.L_star, color->spec.CIELab.a_star, color->spec.CIELab.b_star); } } } q = realloc(q, width*chars_per_pixel*sizeof(char)+256*chars_per_pixel*sizeof(char)); for (l = 0; l < height; l++) { fgets(q, width*chars_per_pixel+16, g); if ((l == 0) & (q[0] == '/')) { fprintf(f, "%s", q); fgets(q, width*chars_per_pixel+16, g); } fprintf(f, "%s", q); } fgets(q, width*chars_per_pixel+16, g); fprintf(f, "%s", q); fclose(g); XFree(q); XFree(rmask_return); XFree(gmask_return); XFree(bmask_return); XFree(pixels); XFree(visual_info); XFree(color); XFree(color_return); XFree(code); XFree(lecture); XFree(rouge); XFree(vert); XFree(bleu); return 22; }/* nuancier_65536.c * * Compilation: * cc -ansi -Wall -o 65536 65536.c * Usage: * ./65536 > 65536.xpm * */ #include <stdlib.h> #include <stdio.h> #include <string.h> int main (int argc, char *argv[]) { unsigned int i, j, r, g, b, n1, n2, n3; static char *printable = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjklzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"; printf("/* XPM */\n"); printf("static char *nuancier_65535[] = {\n"); printf("/* width height ncolors char_per_pixel */\n"); printf("\"256 256 65536 3\",\n"); printf("/* colors */\n"); n1 = 0; n2 = 0; n3 = 0; r = 0; g = 0; b = 0; for (i = 0; i< 65536; i++) { printf("\"%c%c%c c #%04X%04X%04X\",\n", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1], r, g, b); b = b + 2048; if (b > 65535) { b = 0; g = g + 1024; if (g > 65535) { g = 0; r = r + 2048; } } n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } printf("/* pixels */\n"); n1 = 0; n2 = 0; n3 = 0; j = 0; for (i = 0; i< 65536; i++) { if (j == 0) printf("\""); printf("%c%c%c", printable[ (int) (n3/8464)], printable[ (int) (n2/92)], printable[n1]); j++; if ((j > 255) & (i != 65535)) { printf("\",\n"); j = 0; } if (i == 65535) printf("\"\n"); n1++; n2++; n3++; if (n1 == strlen(printable)) n1 = 0; if (n2 == 8464) n2 = 0; } printf("};\n"); return 0; }/* glx_cms.c * * Compilation : * * cc -ansi -Wall -o glx_cms -L /usr/X11R6/lib -lGL -lGLU -lm -lX11 glx_cms.c * * Usage : * * ./glx_cms -display $DISPLAY -type < RGB | RGBi | XYZ | xyY | uvY | TEK | CIELuv | CIElab > <fichier xpm> * * */ #include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/Xcms.h> #include <GL/gl.h> #include <GL/glx.h> static GLfloat monochromatic_light[401][4] = { /* monochromatics light, * Step 1 nanomètre * interpolation of Lagrange, * (XYZ color space).*/ { 380.0, 0.001368, 3.9e-05, 0.00645 }, { 381.0, 0.001421, 4.108e-05, 0.007026 }, { 382.0, 0.001539, 4.47e-05, 0.007663 }, { 383.0, 0.001718, 4.977e-05, 0.008422 }, { 384.0, 0.001952, 5.623e-05, 0.009364 }, { 385.0, 0.002236, 6.4e-05, 0.01055 }, { 386.0, 0.002537928, 7.24e-05, 0.01197768 }, { 387.0, 0.002887504, 8.212e-05, 0.01363144 }, { 388.0, 0.003286816, 9.324e-05, 0.01552136 }, { 389.0, 0.003737952, 0.00010584, 0.01765752 }, { 390.0, 0.004243, 0.00012, 0.02005 }, { 391.0, 0.004753104, 0.000134808, 0.02246696 }, { 392.0, 0.005334032, 0.000151584, 0.02522088 }, { 393.0, 0.006000608, 0.000170656, 0.02838232 }, { 394.0, 0.006767656, 0.000192352, 0.03202184 }, { 395.0, 0.00765, 0.000217, 0.03621 }, { 396.0, 0.008754816, 0.000246784, 0.04145224 }, { 397.0, 0.009981488, 0.000279712, 0.04727552 }, { 398.0, 0.011321752, 0.000315648, 0.05364168 }, { 399.0, 0.012767344, 0.000354456, 0.06051256 }, { 400.0, 0.01431, 0.000396, 0.06785 }, { 401.0, 0.01561336, 0.000431248, 0.07405072 }, { 402.0, 0.01707928, 0.000471184, 0.08103296 }, { 403.0, 0.01878152, 0.000517896, 0.08914984 }, { 404.0, 0.02079384, 0.000573472, 0.09875448 }, { 405.0, 0.02319, 0.00064, 0.1102 }, { 406.0, 0.02626328, 0.000725552, 0.1248728 }, { 407.0, 0.02981304, 0.000824736, 0.1418344 }, { 408.0, 0.03385816, 0.000938144, 0.1611796 }, { 409.0, 0.03841752, 0.001066368, 0.1830032 }, { 410.0, 0.04351, 0.00121, 0.2074 }, { 411.0, 0.0489468, 0.0013576, 0.2334456 }, { 412.0, 0.0550064, 0.0015248, 0.2625088 }, { 413.0, 0.0617596, 0.0017152, 0.2949392 }, { 414.0, 0.0692772, 0.0019324, 0.3310864 }, { 415.0, 0.07763, 0.00218, 0.3713 }, { 416.0, 0.08714064, 0.00245584, 0.4170496 }, { 417.0, 0.09756512, 0.00277072, 0.4672848 }, { 418.0, 0.10891128, 0.00312968, 0.5220752 }, { 419.0, 0.12118696, 0.00353776, 0.5814904 }, { 420.0, 0.1344, 0.004, 0.6456 }, { 421.0, 0.14970736, 0.00455696, 0.720048 }, { 422.0, 0.16568048, 0.00516928, 0.797936 }, { 423.0, 0.18203992, 0.00583312, 0.87794 }, { 424.0, 0.19850624, 0.00654464, 0.958736 }, { 425.0, 0.2148, 0.0073, 1.039 }, { 426.0, 0.2299464, 0.00808192, 1.1141472 }, { 427.0, 0.2445352, 0.00890336, 1.1869296 }, { 428.0, 0.2584608, 0.00976384, 1.2568384 }, { 429.0, 0.2716176, 0.01066288, 1.3233648 }, { 430.0, 0.2839, 0.0116, 1.386 }, { 431.0, 0.2947896, 0.01257344, 1.442296 }, { 432.0, 0.3046968, 0.01358432, 1.494168 }, { 433.0, 0.3136192, 0.01463248, 1.541592 }, { 434.0, 0.3215544, 0.01571776, 1.584544 }, { 435.0, 0.3285, 0.01684, 1.623 }, { 436.0, 0.3342904, 0.01800736, 1.65604 }, { 437.0, 0.3391272, 0.01920928, 1.68476 }, { 438.0, 0.3430488, 0.02044352, 1.70936 }, { 439.0, 0.3460936, 0.02170784, 1.73004 }, { 440.0, 0.3483, 0.023, 1.747 }, { 441.0, 0.3495944, 0.02428448, 1.759928 }, { 442.0, 0.3501552, 0.02560064, 1.769664 }, { 443.0, 0.3500488, 0.02695456, 1.776536 }, { 444.0, 0.3493416, 0.02835232, 1.780872 }, { 445.0, 0.3481, 0.0298, 1.783 }, { 446.0, 0.3464608, 0.0313152, 1.7836 }, { 447.0, 0.3444024, 0.0328896, 1.78256 }, { 448.0, 0.3419736, 0.0345264, 1.78012 }, { 449.0, 0.3392232, 0.0362288, 1.77652 }, { 450.0, 0.3362, 0.038, 1.772 }, { 451.0, 0.3333016, 0.0398496, 1.76872 }, { 452.0, 0.3301408, 0.0417728, 1.76452 }, { 453.0, 0.3266792, 0.0437712, 1.75916 }, { 454.0, 0.3228784, 0.0458464, 1.7524 }, { 455.0, 0.3187, 0.048, 1.744 }, { 456.0, 0.3139968, 0.0502432, 1.733368 }, { 457.0, 0.3088664, 0.0525656, 1.720704 }, { 458.0, 0.3032976, 0.0549664, 1.705856 }, { 459.0, 0.2972792, 0.0574448, 1.688672 }, { 460.0, 0.2908, 0.06, 1.669 }, { 461.0, 0.2839384, 0.06258704, 1.647136 }, { 462.0, 0.2765712, 0.06526032, 1.622368 }, { 463.0, 0.2686648, 0.06803008, 1.594432 }, { 464.0, 0.2601856, 0.07090656, 1.563064 }, { 465.0, 0.2511, 0.0739, 1.528 }, { 466.0, 0.2406512, 0.07701808, 1.484944 }, { 467.0, 0.2297096, 0.08027424, 1.438672 }, { 468.0, 0.2184224, 0.08367936, 1.389928 }, { 469.0, 0.2069368, 0.08724432, 1.339456 }, { 470.0, 0.1954, 0.09098, 1.288 }, { 471.0, 0.18440592, 0.09493312, 1.238544 }, { 472.0, 0.17354336, 0.09906976, 1.189032 }, { 473.0, 0.16284784, 0.10339184, 1.139648 }, { 474.0, 0.15235488, 0.10790128, 1.090576 }, { 475.0, 0.1421, 0.1126, 1.042 }, { 476.0, 0.13219904, 0.11752576, 0.9943536 }, { 477.0, 0.12258712, 0.12263568, 0.9475088 }, { 478.0, 0.11327968, 0.12792272, 0.9015872 }, { 479.0, 0.10429216, 0.13337984, 0.8567104 }, { 480.0, 0.09564, 0.139, 0.813 }, { 481.0, 0.08730504, 0.144604, 0.7706288 }, { 482.0, 0.07934472, 0.1504, 0.7296544 }, { 483.0, 0.07178288, 0.156424, 0.6901856 }, { 484.0, 0.06464336, 0.162712, 0.6523312 }, { 485.0, 0.05795, 0.1693, 0.6162 }, { 486.0, 0.05192184, 0.176256, 0.5825504 }, { 487.0, 0.04633872, 0.183576, 0.5506792 }, { 488.0, 0.04117568, 0.191288, 0.5205328 }, { 489.0, 0.03640776, 0.19942, 0.4920576 }, { 490.0, 0.03201, 0.208, 0.4652 }, { 491.0, 0.02789344, 0.2171072, 0.439964 }, { 492.0, 0.02411312, 0.2267056, 0.416224 }, { 493.0, 0.02066008, 0.2368104, 0.393912 }, { 494.0, 0.01752536, 0.2474368, 0.37296 }, { 495.0, 0.0147, 0.2586, 0.3533 }, { 496.0, 0.01214592, 0.2701808, 0.33488 }, { 497.0, 0.00989056, 0.2823624, 0.317612 }, { 498.0, 0.00793224, 0.2951936, 0.301424 }, { 499.0, 0.00626928, 0.3087232, 0.286244 }, { 500.0, 0.0049, 0.323, 0.272 }, { 501.0, 0.0037488, 0.33854, 0.258844 }, { 502.0, 0.0029064, 0.354808, 0.246424 }, { 503.0, 0.0023896, 0.371736, 0.234612 }, { 504.0, 0.0022152, 0.389256, 0.22328 }, { 505.0, 0.0024, 0.4073, 0.2123 }, { 506.0, 0.002916, 0.4255888, 0.200968 }, { 507.0, 0.003836, 0.4443184, 0.189876 }, { 508.0, 0.005188, 0.4634736, 0.17904 }, { 509.0, 0.007, 0.4830392, 0.168476 }, { 510.0, 0.0093, 0.503, 0.1582 }, { 511.0, 0.01218096, 0.5236928, 0.1481176 }, { 512.0, 0.01558968, 0.5446624, 0.1383828 }, { 513.0, 0.01953792, 0.5658056, 0.1290392 }, { 514.0, 0.02403744, 0.5870192, 0.1201304 }, { 515.0, 0.0291, 0.6082, 0.1117 }, { 516.0, 0.03485512, 0.6293184, 0.1039852 }, { 517.0, 0.04116736, 0.6501792, 0.0967876 }, { 518.0, 0.04801904, 0.6706608, 0.0901024 }, { 519.0, 0.05539248, 0.6906416, 0.0839248 }, { 520.0, 0.06327, 0.71, 0.07825 }, { 521.0, 0.07164608, 0.7279936, 0.07326328 }, { 522.0, 0.08048784, 0.7452768, 0.06872224 }, { 523.0, 0.08977456, 0.7618832, 0.06457456 }, { 524.0, 0.09948552, 0.7778464, 0.06076792 }, { 525.0, 0.1096, 0.7932, 0.05725 }, { 526.0, 0.12018304, 0.80816, 0.05385968 }, { 527.0, 0.13110672, 0.822532, 0.05068064 }, { 528.0, 0.14232888, 0.836304, 0.04768776 }, { 529.0, 0.15380736, 0.849464, 0.04485592 }, { 530.0, 0.1655, 0.862, 0.04216 }, { 531.0, 0.1771896, 0.8737848, 0.03947408 }, { 532.0, 0.1890528, 0.8849504, 0.03689904 }, { 533.0, 0.2010912, 0.8955136, 0.03443496 }, { 534.0, 0.2133064, 0.9054912, 0.03208192 }, { 535.0, 0.2257, 0.9149, 0.02984 }, { 536.0, 0.2382768, 0.923792, 0.02771408 }, { 537.0, 0.2510344, 0.93214, 0.02569824 }, { 538.0, 0.2639736, 0.939952, 0.02379136 }, { 539.0, 0.2770952, 0.947236, 0.02199232 }, { 540.0, 0.2904, 0.954, 0.0203 }, { 541.0, 0.3038984, 0.9602456, 0.01872128 }, { 542.0, 0.3175792, 0.9659888, 0.01724504 }, { 543.0, 0.3314408, 0.9712392, 0.01586816 }, { 544.0, 0.3454816, 0.9760064, 0.01458752 }, { 545.0, 0.3597, 0.9803, 0.0134 }, { 546.0, 0.3740688, 0.9841072, 0.0123092 }, { 547.0, 0.3886184, 0.9874656, 0.0113036 }, { 548.0, 0.4033536, 0.9903904, 0.0103784 }, { 549.0, 0.4182792, 0.9928968, 0.0095288 }, { 550.0, 0.4334, 0.995, 0.00875 }, { 551.0, 0.4487816, 0.9967856, 0.008034 }, { 552.0, 0.4643528, 0.9981808, 0.00738 }, { 553.0, 0.4801032, 0.9991832, 0.006784 }, { 554.0, 0.4960224, 0.9997904, 0.006242 }, { 555.0, 0.5121, 1, 0.00575 }, { 556.0, 0.5283544, 0.9998448, 0.0053024 }, { 557.0, 0.5447392, 0.9992784, 0.0048972 }, { 558.0, 0.5612368, 0.9982896, 0.0045308 }, { 559.0, 0.5778296, 0.9968672, 0.0041996 }, { 560.0, 0.5945, 0.995, 0.0039 }, { 561.0, 0.6112144, 0.9925936, 0.0036204 }, { 562.0, 0.6279752, 0.9897408, 0.0033672 }, { 563.0, 0.6447688, 0.9864512, 0.0031388 }, { 564.0, 0.6615816, 0.9827344, 0.0029336 }, { 565.0, 0.6784, 0.9786, 0.00275 }, { 566.0, 0.6952552, 0.9740896, 0.0025848 }, { 567.0, 0.7120776, 0.9691728, 0.0024384 }, { 568.0, 0.7288424, 0.9638512, 0.0023096 }, { 569.0, 0.7455248, 0.9581264, 0.0021972 }, { 570.0, 0.7621, 0.952, 0.0021 }, { 571.0, 0.7785496, 0.9454416, 0.0020184 }, { 572.0, 0.7948408, 0.9384928, 0.0019492 }, { 573.0, 0.8109472, 0.9311632, 0.0018908 }, { 574.0, 0.8268424, 0.9234624, 0.0018416 }, { 575.0, 0.8425, 0.9154, 0.0018 }, { 576.0, 0.8579448, 0.907008, 0.001766 }, { 577.0, 0.8730864, 0.898268, 0.001736 }, { 578.0, 0.8878856, 0.889184, 0.001708 }, { 579.0, 0.9023032, 0.87976, 0.00168 }, { 580.0, 0.9163, 0.87, 0.00165 }, { 581.0, 0.9297888, 0.8598376, 0.0016064 }, { 582.0, 0.9427904, 0.8493648, 0.0015592 }, { 583.0, 0.9552776, 0.8386032, 0.0015088 }, { 584.0, 0.9672232, 0.8275744, 0.0014556 }, { 585.0, 0.9786, 0.8163, 0.0014 }, { 586.0, 0.98932, 0.8047984, 0.001336 }, { 587.0, 0.999432, 0.7930952, 0.001272 }, { 588.0, 1.008924, 0.7812128, 0.00121 }, { 589.0, 1.017784, 0.7691736, 0.001152 }, { 590.0, 1.026, 0.757, 0.0011 }, { 591.0, 1.0338192, 0.744772, 0.0010736 }, { 592.0, 1.0409056, 0.73244, 0.0010528 }, { 593.0, 1.0471824, 0.720012, 0.0010352 }, { 594.0, 1.0525728, 0.707496, 0.0010184 }, { 595.0, 1.057, 0.6949, 0.001 }, { 596.0, 1.05992, 0.682216, 0.0009648 }, { 597.0, 1.06184, 0.669472, 0.0009264 }, { 598.0, 1.0628, 0.65668, 0.0008856 }, { 599.0, 1.06284, 0.643852, 0.0008432 }, { 600.0, 1.062, 0.631, 0.0008 }, { 601.0, 1.060672, 0.6181616, 0.00076192 }, { 602.0, 1.058456, 0.6053168, 0.00072336 }, { 603.0, 1.055304, 0.5924712, 0.00068384 }, { 604.0, 1.051168, 0.5796304, 0.00064288 }, { 605.0, 1.046, 0.5668, 0.0006 }, { 606.0, 1.0393872, 0.5539568, 0.00054576 }, { 607.0, 1.0317376, 0.5411424, 0.00049088 }, { 608.0, 1.0230944, 0.5283696, 0.00043712 }, { 609.0, 1.0135008, 0.5156512, 0.00038624 }, { 610.0, 1.003, 0.503, 0.00034 }, { 611.0, 0.9917376, 0.4904928, 0.00031072 }, { 612.0, 0.9796288, 0.4780624, 0.00028696 }, { 613.0, 0.9666912, 0.4657056, 0.00026784 }, { 614.0, 0.9529424, 0.4534192, 0.00025248 }, { 615.0, 0.9384, 0.4412, 0.00024 }, { 616.0, 0.9231392, 0.4290768, 0.00022888 }, { 617.0, 0.9071056, 0.4170064, 0.00021904 }, { 618.0, 0.8903024, 0.4049776, 0.00020976 }, { 619.0, 0.8727328, 0.3929792, 0.00020032 }, { 620.0, 0.8544, 0.381, 0.00019 }, { 621.0, 0.834904, 0.3688624, 0.00017264 }, { 622.0, 0.814752, 0.3567632, 0.00015432 }, { 623.0, 0.794048, 0.3447328, 0.00013568 }, { 624.0, 0.772896, 0.3328016, 0.00011736 }, { 625.0, 0.7514, 0.321, 0.0001 }, { 626.0, 0.729616, 0.309352, 8.712e-05 }, { 627.0, 0.707708, 0.297896, 7.576e-05 }, { 628.0, 0.685792, 0.286664, 6.584e-05 }, { 629.0, 0.663984, 0.275688, 5.728e-05 }, { 630.0, 0.6424, 0.265, 5e-05 }, { 631.0, 0.621684, 0.254824, 4.424e-05 }, { 632.0, 0.601292, 0.244952, 3.952e-05 }, { 633.0, 0.581208, 0.235368, 3.568e-05 }, { 634.0, 0.561416, 0.226056, 3.256e-05 }, { 635.0, 0.5419, 0.217, 3e-05 }, { 636.0, 0.5225672, 0.2081456, 2.752e-05 }, { 637.0, 0.5034976, 0.1995248, 2.536e-05 }, { 638.0, 0.4846944, 0.1911312, 2.344e-05 }, { 639.0, 0.4661608, 0.1829584, 2.168e-05 }, { 640.0, 0.4479, 0.175, 2e-05 }, { 641.0, 0.4298352, 0.1672112, 1.8e-05 }, { 642.0, 0.4120696, 0.1596336, 1.6e-05 }, { 643.0, 0.3946264, 0.1522704, 1.4e-05 }, { 644.0, 0.3775288, 0.1451248, 1.2e-05 }, { 645.0, 0.3608, 0.1382, 1e-05 }, { 646.0, 0.3444696, 0.1315056, 7.68e-06 }, { 647.0, 0.3285528, 0.1250368, 5.44e-06 }, { 648.0, 0.3130712, 0.1187952, 3.36e-06 }, { 649.0, 0.2980464, 0.1127824, 1.52e-06 }, { 650.0, 0.2835, 0.107, 0.0 }, { 651.0, 0.269588, 0.101488, -4.8e-07 }, { 652.0, 0.256164, 0.0962, -6.4e-07 }, { 653.0, 0.243216, 0.091128, -5.6e-07 }, { 654.0, 0.230732, 0.086264, -3.2e-07 }, { 655.0, 0.2187, 0.0816, 0.0 }, { 656.0, 0.2070888, 0.07711584, 0.0 }, { 657.0, 0.1959104, 0.07281872, 0.0 }, { 658.0, 0.1851576, 0.06870368, 0.0 }, { 659.0, 0.1748232, 0.06476576, 0.0 }, { 660.0, 0.1649, 0.061, 0.0 }, { 661.0, 0.1553584, 0.05739248, 0.0 }, { 662.0, 0.1462192, 0.05394944, 0.0 }, { 663.0, 0.1374808, 0.05066816, 0.0 }, { 664.0, 0.1291416, 0.04754592, 0.0 }, { 665.0, 0.1212, 0.04458, 0.0 }, { 666.0, 0.1136448, 0.04175872, 0.0 }, { 667.0, 0.1064864, 0.03909056, 0.0 }, { 668.0, 0.0997256, 0.03657504, 0.0 }, { 669.0, 0.0933632, 0.03421168, 0.0 }, { 670.0, 0.0874, 0.032, 0.0 }, { 671.0, 0.08193696, 0.02997536, 0.0 }, { 672.0, 0.07684968, 0.02809248, 0.0 }, { 673.0, 0.07211392, 0.02634192, 0.0 }, { 674.0, 0.06770544, 0.02471424, 0.0 }, { 675.0, 0.0636, 0.0232, 0.0 }, { 676.0, 0.05980472, 0.02179936, 0.0 }, { 677.0, 0.05625616, 0.02049088, 0.0 }, { 678.0, 0.05292224, 0.01926272, 0.0 }, { 679.0, 0.04977088, 0.01810304, 0.0 }, { 680.0, 0.04677, 0.017, 0.0 }, { 681.0, 0.04373648, 0.0158864, 0.0 }, { 682.0, 0.04082704, 0.0148196, 0.0 }, { 683.0, 0.03804736, 0.0138016, 0.0 }, { 684.0, 0.03540312, 0.0128344, 0.0 }, { 685.0, 0.0329, 0.01192, 0.0 }, { 686.0, 0.03057696, 0.011073104, 0.0 }, { 687.0, 0.02839808, 0.010279832, 0.0 }, { 688.0, 0.02636072, 0.009539008, 0.0 }, { 689.0, 0.02446224, 0.008849456, 0.0 }, { 690.0, 0.0227, 0.00821, 0.0 }, { 691.0, 0.02109152, 0.007626184, 0.0 }, { 692.0, 0.01960896, 0.007088432, 0.0 }, { 693.0, 0.01824464, 0.006593888, 0.0 }, { 694.0, 0.01699088, 0.006139696, 0.0 }, { 695.0, 0.01584, 0.005723, 0.0 }, { 696.0, 0.014790368, 0.005342896, 0.0 }, { 697.0, 0.013826744, 0.004994088, 0.0 }, { 698.0, 0.012939936, 0.004673232, 0.0 }, { 699.0, 0.012120752, 0.004376984, 0.0 }, { 700.0, 0.01136, 0.004102, 0.0 }, { 701.0, 0.010621416, 0.003835176, 0.0 }, { 702.0, 0.009929648, 0.003585368, 0.0 }, { 703.0, 0.009282272, 0.003351672, 0.0 }, { 704.0, 0.008676864, 0.003133184, 0.0 }, { 705.0, 0.008111, 0.002929, 0.0 }, { 706.0, 0.007581776, 0.002737928, 0.0 }, { 707.0, 0.007087368, 0.002559424, 0.0 }, { 708.0, 0.006625472, 0.002392656, 0.0 }, { 709.0, 0.006193784, 0.002236792, 0.0 }, { 710.0, 0.00579, 0.002091, 0.0 }, { 711.0, 0.005408008, 0.001953072, 0.0 }, { 712.0, 0.005050264, 0.001823896, 0.0 }, { 713.0, 0.004715416, 0.001702984, 0.0 }, { 714.0, 0.004402112, 0.001589848, 0.0 }, { 715.0, 0.004109, 0.001484, 0.0 }, { 716.0, 0.003832872, 0.00138428, 0.0 }, { 717.0, 0.003574696, 0.00129104, 0.0 }, { 718.0, 0.003333584, 0.00120396, 0.0 }, { 719.0, 0.003108648, 0.00112272, 0.0 }, { 720.0, 0.002899, 0.001047, 0.0 }, { 721.0, 0.002704008, 0.000976576, 0.0 }, { 722.0, 0.002522464, 0.000911008, 0.0 }, { 723.0, 0.002353416, 0.000849952, 0.0 }, { 724.0, 0.002195912, 0.000793064, 0.0 }, { 725.0, 0.002049, 0.00074, 0.0 }, { 726.0, 0.001910224, 0.000689872, 0.0 }, { 727.0, 0.001780512, 0.000643016, 0.0 }, { 728.0, 0.001659288, 0.000599224, 0.0 }, { 729.0, 0.001545976, 0.000558288, 0.0 }, { 730.0, 0.00144, 0.00052, 0.0 }, { 731.0, 0.001339728, 0.000483768, 0.0 }, { 732.0, 0.001245904, 0.000449864, 0.0 }, { 733.0, 0.001158216, 0.000418176, 0.0 }, { 734.0, 0.001076352, 0.000388592, 0.0 }, { 735.0, 0.001, 0.000361, 0.0 }, { 736.0, 0.000928688, 0.000335224, 0.0 }, { 737.0, 0.000862304, 0.000311232, 0.0 }, { 738.0, 0.000800576, 0.000288928, 0.0 }, { 739.0, 0.000743232, 0.000268216, 0.0 }, { 740.0, 0.00069, 0.000249, 0.0 }, { 741.0, 0.000640352, 0.00023112, 0.0 }, { 742.0, 0.000594336, 0.00021456, 0.0 }, { 743.0, 0.000551744, 0.00019924, 0.0 }, { 744.0, 0.000512368, 0.00018508, 0.0 }, { 745.0, 0.000476, 0.000172, 0.0 }, { 746.0, 0.000442336, 0.000159856, 0.0 }, { 747.0, 0.000411288, 0.000148648, 0.0 }, { 748.0, 0.000382672, 0.000138312, 0.0 }, { 749.0, 0.000356304, 0.000128784, 0.0 }, { 750.0, 0.000332, 0.00012, 0.0 }, { 751.0, 0.000309448, 0.000111864, 0.0 }, { 752.0, 0.000288624, 0.000104352, 0.0 }, { 753.0, 0.000269376, 9.7408e-05, 0.0 }, { 754.0, 0.000251552, 9.0976e-05, 0.0 }, { 755.0, 0.000235, 8.5e-05, 0.0 }, { 756.0, 0.000219216, 7.9296e-05, 0.0 }, { 757.0, 0.000204488, 7.3968e-05, 0.0 }, { 758.0, 0.000190752, 6.8992e-05, 0.0 }, { 759.0, 0.000177944, 6.4344e-05, 0.0 }, { 760.0, 0.000166, 6e-05, 0.0 }, { 761.0, 0.00015476, 5.5872e-05, 0.0 }, { 762.0, 0.00014428, 5.2016e-05, 0.0 }, { 763.0, 0.00013452, 4.8424e-05, 0.0 }, { 764.0, 0.00012544, 4.5088e-05, 0.0 }, { 765.0, 0.000117, 4.2e-05, 0.0 }, { 766.0, 0.00010916, 3.9216e-05, 0.0 }, { 767.0, 0.00010188, 3.6648e-05, 0.0 }, { 768.0, 9.512e-05, 3.4272e-05, 0.0 }, { 769.0, 8.884e-05, 3.2064e-05, 0.0 }, { 770.0, 8.3e-05, 3e-05, 0.0 }, { 771.0, 7.7496e-05, 2.796e-05, 0.0 }, { 772.0, 7.2368e-05, 2.604e-05, 0.0 }, { 773.0, 6.7592e-05, 2.424e-05, 0.0 }, { 774.0, 6.3144e-05, 2.256e-05, 0.0 }, { 775.0, 5.9e-05, 2.1e-05, 0.0 }, { 776.0, 5.512e-05, 1.953e-05, 0.0 }, { 777.0, 5.15e-05, 1.819e-05, 0.0 }, { 778.0, 4.812e-05, 1.698e-05, 0.0 }, { 779.0, 4.496e-05, 1.591e-05, 0.0 }, { 780.0, 4.2e-05, 1.5e-05, 0.0 } }; int main(int argc, char *argv[]) { FILE *g; Display *dpy; Window win; GLXContext ctx; int i, a; GLfloat h; int attrib[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 1, None }; int scrnum; XSetWindowAttributes attr; unsigned long mask; Window root; XVisualInfo *visinfo; XSizeHints sizehints; static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; static GLint graph_cms; XcmsColor *white_point, *color_return; XcmsColor **monochroma_color, **limites_color, **data_color; XcmsColor **color_pixel, **color_cms; XcmsCCC ccc; Bool *test; char *rouge, *vert, *bleu, *string; char *q, *d; int l, b, width, height, nb_colors, chars_per_pixel; Status status; GLfloat distance, largeur, hauteur, profondeur0, profondeur1, fond; /* Open. */ if (argc < 6) { printf ("Usage :\n\t./glx_cms -display <hostname:number.screen_number> -type < RGB | RGBi | XYZ | xyY | uvY | TEK | CIELuv | CIElab > <fichier.xpm>.\n"); exit (1); } if (strcmp(argv[1], "-display") != 0) { printf ("Usage :\n\t./glx_cms -display <hostname:number.screen_number> -type < RGB | RGBi | XYZ | xyY | uvY | TEK | CIELuv | CIElab > <fichier.xpm>.\n"); exit (1); } dpy = XOpenDisplay(argv[2]); if (!dpy) { printf("Error: couldn't open display %s\n", argv[2]); return -1; } if (strcmp(argv[3], "-type") != 0) { printf ("Usage :\n\t./glx_cms -display <hostname:number.screen_number> -type < RGB | RGBi | XYZ | xyY | uvY | TEK | CIELuv | CIElab > <fichier.xpm>.\n"); exit (1); } if ((strcmp(argv[4], "RGB") != 0) & (strcmp(argv[4], "RGBi") != 0) & (strcmp(argv[4], "XYZ") != 0) & (strcmp(argv[4], "xyY") != 0) & (strcmp(argv[4], "uvY") != 0) & (strcmp(argv[4], "TEK") != 0) & (strcmp(argv[4], "CIELuv") != 0) & (strcmp(argv[4], "CIELab") != 0)) { printf ("Usage :\n\t./glx_cms -display <hostname:number.screen_number> -type < RGB | RGBi | XYZ | xyY | uvY | TEK | CIELuv | CIElab > <fichier.xpm>.\n"); exit (1); } scrnum = DefaultScreen( dpy ); root = RootWindow(dpy, scrnum); visinfo = glXChooseVisual( dpy, scrnum, attrib ); if (!visinfo) { printf("Error: couldn't get an RGB, Double-buffered visual\n"); exit(1); } /* window attributes */ attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, 0, 0, 600, 600, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr ); /* set hints and properties */ sizehints.x = 0; sizehints.y = 0; sizehints.width = 600; sizehints.height = 600; sizehints.flags = USSize | USPosition; XSetNormalHints(dpy, win, &sizehints); XSetStandardProperties(dpy, win, "glx_cms", "glx_cms", None, (char **)NULL, 0, &sizehints); ctx = glXCreateContext( dpy, visinfo, NULL, True ); if (!ctx) { printf("Error: glXCreateContext failed\n"); exit(1); } XFree(visinfo); XMapWindow(dpy, win); glXMakeCurrent(dpy, win, ctx); glViewport(0, 0, 600, 600); glMatrixMode(GL_PROJECTION); glLoadIdentity(); distance = -40.0; profondeur0 = 30.0; profondeur1 = 60.0; largeur = 0.65; hauteur = 0.65; fond = 4.0; if ((strcmp(argv[4], "xyY") == 0) | (strcmp(argv[4], "uvY") == 0)) { largeur = 0.475; hauteur = 0.475; } if ((strcmp(argv[4], "TEK") == 0) | (strcmp(argv[4], "CIELuv") == 0) | (strcmp(argv[4], "CIELab") == 0)) { distance = -400.0; profondeur0 = 30.0; profondeur1 = 1000.0; largeur = 12.5; hauteur = 12.5; fond = 300.0; } glFrustum(-largeur, largeur, -hauteur, hauteur, profondeur0, profondeur1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, distance); /*monochroma_color from monochromatic_light * (XYZ color space).*/ monochroma_color = malloc(401*sizeof(XcmsColor)); for (a = 0; a < 402; a++) monochroma_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { monochroma_color[a]->spec.CIEXYZ.X = monochromatic_light[a][1]; monochroma_color[a]->spec.CIEXYZ.Y = monochromatic_light[a][2]; monochroma_color[a]->spec.CIEXYZ.Z =monochromatic_light[a][3]; monochroma_color[a]->format = XcmsCIEXYZFormat; } /* Limites of colors * * (RGB color space).*/ limites_color = malloc((256*12+1)*sizeof(XcmsColor)); for (a = 0; a < 3073; a++) limites_color[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 256; a++) { limites_color[a]->spec.RGB.red = a*257-1; limites_color[a]->spec.RGB.green = 0; limites_color[a]->spec.RGB.blue = 0; limites_color[a+256]->spec.RGB.red = 0; limites_color[a+256]->spec.RGB.green = a*257-1; limites_color[a+256]->spec.RGB.blue = 0; limites_color[a+256*2]->spec.RGB.red = 0; limites_color[a+256*2]->spec.RGB.green = 0; limites_color[a+256*2]->spec.RGB.blue = a*257-1; limites_color[a+256*3]->spec.RGB.red = 65535; limites_color[a+256*3]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*3]->spec.RGB.blue = 0; limites_color[a+256*4]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*4]->spec.RGB.green = 65535; limites_color[a+256*4]->spec.RGB.blue = 0; limites_color[a+256*5]->spec.RGB.red = 0; limites_color[a+256*5]->spec.RGB.green = 65535; limites_color[a+256*5]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.red = 0; limites_color[a+256*6]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*6]->spec.RGB.blue = 65535; limites_color[a+256*7]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*7]->spec.RGB.green = 0; limites_color[a+256*7]->spec.RGB.blue = 65535; limites_color[a+256*8]->spec.RGB.red = 65535; limites_color[a+256*8]->spec.RGB.green = 0; limites_color[a+256*8]->spec.RGB.blue = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.red = 65535-a*257-1; limites_color[a+256*9]->spec.RGB.green = 65535; limites_color[a+256*9]->spec.RGB.blue = 65535; limites_color[a+256*10]->spec.RGB.red = 65535; limites_color[a+256*10]->spec.RGB.green = 65535-a*257-1; limites_color[a+256*10]->spec.RGB.blue = 65535; limites_color[a+256*11]->spec.RGB.red = 65535; limites_color[a+256*11]->spec.RGB.green = 65535; limites_color[a+256*11]->spec.RGB.blue = 65535-a*257-1; } for (a = 0; a < 3073; a++) limites_color[a]->format = XcmsRGBFormat; /* Data_color from image_file * (RGB color Space). */ g = fopen(argv[5], "r"); if (! g) { printf("%s ?\n", argv[5]); exit(1); } q = malloc(128); fgets(q, 80, g); /* XPM */ q[strlen(q)-1] = 0; if (strcmp(q, "/* XPM */") != 0) { printf("XPM file ?\n"); exit(1); } fgets(q, 80, g); q[strlen(q) -5] = 0; fgets(q, 80, g); if (q[0] == '/') { /* hints_cmt */ fgets(q, 80, g); } q[0] = ' '; q[strlen(q)-3] = 0; d = strchr(q, ' '); d++; width = atoi((const char *) d); d = strchr(d, ' '); d++; height = atoi((const char *) d); d = strchr(d, ' '); d++; nb_colors = atoi((const char *) d); d = strchr(d, ' '); d++; chars_per_pixel = atoi((const char *) d); rouge = malloc(4*sizeof(char)); vert = malloc(4*sizeof(char)); bleu = malloc(4*sizeof(char)); ccc = XcmsCCCOfColormap(dpy, attr.colormap); white_point = malloc(sizeof(XcmsColor)); white_point = XcmsScreenWhitePointOfCCC(ccc); data_color = malloc((nb_colors+1)*sizeof(XcmsColor)); for(b = 0; b < nb_colors+1; b++) { data_color[b] = malloc(sizeof(XcmsColor)); } color_return = malloc(sizeof(XcmsColor)); for (l = 0; l < nb_colors; l++) { fgets(q, 80, g); if ((l==0) & (q[0] == '/')) { /* colors_cmt */ fgets(q, 80, g); } q[0] = ' '; q[strlen(q)-3] = 0; d = q + 1 + chars_per_pixel + 3; if (d[0] == '#') { d = d+1; d = strtok(d, " "); strncpy(rouge, d, strlen(d)/3); strncpy(vert, d+strlen(d)/3, strlen(d)/3); strncpy(bleu, d+strlen(d)*2/3, strlen(d)/3); data_color[l]->spec.RGB.red = (unsigned long) strtol(rouge, NULL, 16); data_color[l]->spec.RGB.green = (unsigned long) strtol(vert, NULL, 16); data_color[l]->spec.RGB.blue = (unsigned long) strtol(bleu, NULL, 16); data_color[l]->format = XcmsRGBFormat; if (strlen(d) == 6) { data_color[l]->spec.RGB.red = data_color[l]->spec.RGB.red*257; data_color[l]->spec.RGB.green = data_color[l]->spec.RGB.green*257; data_color[l]->spec.RGB.blue = data_color[l]->spec.RGB.blue*257; data_color[l]->format = XcmsRGBFormat; } }else{ string = (char *) strtok(d, " "); status = XcmsLookupColor(dpy, attr.colormap, string, data_color[l], color_return, XcmsRGBFormat); if (status == 0) { printf("xpm : bad color: %s\n", string); } } } fclose(g); test = malloc(sizeof(Bool)); color_pixel = malloc((3073+402+nb_colors+4)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+nb_colors+4; a++) color_pixel[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_pixel[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_pixel[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_pixel[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_pixel[a]->format = XcmsCIEXYZFormat; XcmsCIELabClipLab (ccc, color_pixel[a], 1, 0, test); XcmsCIEXYZToRGBi(ccc, color_pixel[a], 1, test); } for (a = 0; a < 3073; a++) { color_pixel[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_pixel[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_pixel[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_pixel[a+402]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_pixel[a+402], 1, test); } for (a = 0; a < nb_colors; a++) { color_pixel[a+402+3073]->spec.RGB.red = data_color[a]->spec.RGB.red; color_pixel[a+402+3073]->spec.RGB.green = data_color[a]->spec.RGB.green; color_pixel[a+402+3073]->spec.RGB.blue = data_color[a]->spec.RGB.blue; color_pixel[a+402+3073]->format = XcmsRGBFormat; XcmsRGBToRGBi(ccc, color_pixel[a+402+3073], 1, test); } color_cms = malloc((3073+402+nb_colors+1)*sizeof(XcmsColor)); for (a = 0; a < 3073+402+nb_colors+1; a++) color_cms[a] = malloc(sizeof(XcmsColor)); for (a = 0; a < 402; a++) { color_cms[a]->spec.CIEXYZ.X = monochroma_color[a]->spec.CIEXYZ.X; color_cms[a]->spec.CIEXYZ.Y = monochroma_color[a]->spec.CIEXYZ.Y; color_cms[a]->spec.CIEXYZ.Z = monochroma_color[a]->spec.CIEXYZ.Z; color_cms[a]->format = XcmsCIEXYZFormat; } if (strcmp(argv[4], "RGB") == 0) { for (a = 0; a < 402; a++) { XcmsCIEXYZToRGBi(ccc, color_cms[a], 1, test); XcmsRGBiToRGB(ccc, color_cms[a], 1, test); } } if (strcmp(argv[4], "RGBi") == 0) { for (a = 0; a < 402; a++) XcmsCIEXYZToRGBi(ccc, color_cms[a], 1, test); } if (strcmp(argv[4], "xyY") == 0) { for (a = 0; a < 402; a++) XcmsCIEXYZToCIExyY(ccc, white_point, color_cms[a], 1); } if (strcmp(argv[4], "uvY") == 0) { for (a = 0; a < 402; a++) XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a], 1); } if (strcmp(argv[4], "TEK") == 0) { for (a = 0; a < 402; a++) { XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_cms[a], 1); } } if (strcmp(argv[4], "CIELuv") == 0) { for (a = 0; a < 402; a++) { XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a], 1); XcmsCIEuvYToCIELuv(ccc, white_point, color_cms[a], 1); } } if (strcmp(argv[4], "CIELab") == 0) { for (a = 0; a < 402; a++) XcmsCIEXYZToCIELab(ccc, white_point, color_cms[a], 1); } for (a = 0; a < 3073; a++) { color_cms[a+402]->spec.RGB.red = limites_color[a]->spec.RGB.red; color_cms[a+402]->spec.RGB.green = limites_color[a]->spec.RGB.green; color_cms[a+402]->spec.RGB.blue = limites_color[a]->spec.RGB.blue; color_cms[a+402]->format = XcmsRGBFormat; } for (a = 0; a < nb_colors ; a++) { color_cms[a+402+3073]->spec.RGB.red = data_color[a]->spec.RGB.red; color_cms[a+402+3073]->spec.RGB.green = data_color[a]->spec.RGB.green; color_cms[a+402+3073]->spec.RGB.blue = data_color[a]->spec.RGB.blue; color_cms[a+402+3073]->format = XcmsRGBFormat; } if (strcmp(argv[4], "RGBi") == 0) { for (a = 0; a < 3073+nb_colors ; a++) XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); } if (strcmp(argv[4], "XYZ") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); } } if (strcmp(argv[4], "xyY") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); XcmsCIEXYZToCIExyY(ccc, white_point, color_cms[a+402], 1); } } if (strcmp(argv[4], "uvY") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a+402], 1); } } if (strcmp(argv[4], "TEK") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a+402], 1); XcmsCIEuvYToTekHVC(ccc, white_point, color_cms[a+402], 1); } } if (strcmp(argv[4], "CIELuv") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); XcmsCIEXYZToCIEuvY(ccc, white_point, color_cms[a+402], 1); XcmsCIEuvYToCIELuv(ccc, white_point, color_cms[a+402], 1); } } if (strcmp(argv[4], "CIELab") == 0) { for (a = 0; a < 3073+nb_colors ; a++) { XcmsRGBToRGBi(ccc, color_cms[a+402], 1, test); XcmsRGBiToCIEXYZ(ccc, color_cms[a+402], 1, test); XcmsCIEXYZToCIELab(ccc, white_point, color_cms[a+402], 1); } } graph_cms = glGenLists(1); glNewList(graph_cms, GL_COMPILE); glBegin(GL_QUADS); glColor3f(0.5, 0.5, 0.5); glVertex3f(-fond, fond, fond); glVertex3f(fond, fond, fond); glVertex3f(fond, -fond, fond); glVertex3f(-fond, -fond, fond); glVertex3f(-fond, fond, -fond); glVertex3f(fond, fond, -fond); glVertex3f(fond, -fond, -fond); glVertex3f(-fond, -fond, -fond); glVertex3f(-fond, fond, fond); glVertex3f(fond, fond, fond); glVertex3f(fond, fond, -fond); glVertex3f(-fond, fond, -fond); glVertex3f(-fond, -fond, fond); glVertex3f(fond, -fond, fond); glVertex3f(fond, -fond, -fond); glVertex3f(-fond, -fond, -fond); glVertex3f(-fond, -fond, fond); glVertex3f(-fond, fond, fond); glVertex3f(-fond, fond, -fond); glVertex3f(-fond, -fond, -fond); glVertex3f(fond, -fond, fond); glVertex3f(fond, fond, fond); glVertex3f(fond, fond, -fond); glVertex3f(fond, -fond, -fond); glEnd(); glBegin(GL_POINTS); if (strcmp(argv[4], "RGB") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f( (float) color_cms[i]->spec.RGB.red/65535.0 - 0.5, (float) color_cms[i]->spec.RGB.green/65535.0 - 0.5, (float) color_cms[i]->spec.RGB.blue/65535.0 - 0.5); } } if (strcmp(argv[4], "RGBi") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.RGBi.red - 0.5, color_cms[i]->spec.RGBi.green - 0.5, color_cms[i]->spec.RGBi.blue - 0.5); } } if (strcmp(argv[4], "XYZ") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.CIEXYZ.X - 0.5 , color_cms[i]->spec.CIEXYZ.Z - 0.5, color_cms[i]->spec.CIEXYZ.Y - 0.5); } } if (strcmp(argv[4], "xyY") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.CIExyY.x - 0.5 , color_cms[i]->spec.CIExyY.y - 0.5, color_cms[i]->spec.CIExyY.Y - 0.5); } } if (strcmp(argv[4], "uvY") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.CIEuvY.u_prime - 0.5 , color_cms[i]->spec.CIEuvY.v_prime - 0.5, color_cms[i]->spec.CIEuvY.Y - 0.5); } } if (strcmp(argv[4], "TEK") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.TekHVC.C*cos(color_cms[i]->spec.TekHVC.H*3.14159/180), color_cms[i]->spec.TekHVC.C*sin(color_cms[i]->spec.TekHVC.H*3.14159/180), color_cms[i]->spec.TekHVC.V - 50.0); } } if (strcmp(argv[4], "CIELuv") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.CIELuv.u_star, color_cms[i]->spec.CIELuv.v_star, color_cms[i]->spec.CIELuv.L_star - 50.0); } } if (strcmp(argv[4], "CIELab") == 0) { for (i = 0; i < nb_colors+402+3073 ; i++) { glColor3f(color_pixel[i]->spec.RGBi.red, color_pixel[i]->spec.RGBi.green, color_pixel[i]->spec.RGBi.blue); glVertex3f(color_cms[i]->spec.CIELab.a_star, color_cms[i]->spec.CIELab.b_star, color_cms[i]->spec.CIELab.L_star - 50.0); } } glEnd(); glEndList(); glEnable(GL_NORMALIZE); while (1) { while (XPending(dpy) > 0) { XEvent event; XNextEvent(dpy, &event); switch (event.type) { case Expose: /* we'll redraw below */ break; case ConfigureNotify: glViewport(0, 0, event.xconfigure.width, event.xconfigure.height); h = (GLfloat) event.xconfigure.height / (GLfloat) event.xconfigure.width; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-largeur, largeur, -hauteur*h, h*hauteur, profondeur0, profondeur1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, distance); break; case KeyPress: { char buffer[10]; int code; code = XLookupKeysym(&event.xkey, 0); if (code == XK_Left) { view_roty += 1.0; } else if (code == XK_Right) { view_roty -= 1.0; } else if (code == XK_Up) { view_rotx += 1.0; } else if (code == XK_Down) { view_rotx -= 1.0; } else { (void) XLookupString(&event.xkey, buffer, sizeof(buffer), NULL, NULL); if (buffer[0] == 27) { /* escape */ return 0; } } } } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(view_rotx, 1.0, 0.0, 0.0); glRotatef(view_roty, 0.0, 1.0, 0.0); glRotatef(view_rotz, 0.0, 0.0, 1.0); glCallList(graph_cms); glPopMatrix(); glXSwapBuffers(dpy, win); } glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); XCloseDisplay(dpy); return 0; }Attachment: smime.p7s
Description: S/MIME cryptographic signature
--- End Message ---
--- Begin Message ---
- To: pascal.dubois6@tiscali.fr, 351404-done@bugs.debian.org
- Subject: Re: Bug#351404: bugs in Debian libx11-dev
- From: Cyril Brulebois <kibi@debian.org>
- Date: Fri, 3 Dec 2010 17:28:26 +0100
- Message-id: <20101203162826.GA26337@debian.org>
- In-reply-to: <43e4dd20.slifk7sgllFDa288%postier@localhost.localdomain>
- References: <43e4dd20.slifk7sgllFDa288%postier@localhost.localdomain>
Hi, pascal.dubois6@tiscali.fr <pascal.dubois6@tiscali.fr> (04/02/2006): > PACKAGE: libx11-dev_6.8.2.dfsg.1-7_i386.deb > > SUMMARY: Bugs in libX11-dev (Xcms X ColoriMetrics Spaces). > This work fixes them with programs tests, patches > and examples. upstream called it an invalid bug, details are available there: https://bugs.freedesktop.org/show_bug.cgi?id=9949#c12 I'm closing it in the Debian BTS accordingly. Mraw, KiBi.Attachment: signature.asc
Description: Digital signature
--- End Message ---