home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 January / macpower199701.bin / AMUG / Programming_10 / Videotoolbox 96-08-22-c.sit / VideoToolbox / VideoToolboxSources / Luminance.c < prev    next >
MacBinary  |  1996-03-07  |  43.1 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: MacBinary (archive/macBinary).

You can browse this item here: Luminance.c

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Thu Mar 7 22:40:24 1996, modified Thu Mar 7 22:40:24 1996, creator 'CWIE', type ASCII, 40709 bytes "Luminance.c" , at 0x9f85 3132 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 4c 75 6d 69 6e 61 | 6e 63 65 2e 63 00 00 00 |..Lumina|nce.c...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 01 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 9f 05 00 | 00 0c 3c ad 65 5c a8 ad |........|..<.e\..|
|00000060| 65 5c a8 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |e\......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 48 cc 00 00 |........|....H...|
|00000080| 2f 2a 0d 4c 75 6d 69 6e | 61 6e 63 65 2e 63 0d 53 |/*.Lumin|ance.c.S|
|00000090| 65 65 20 4c 75 6d 69 6e | 61 6e 63 65 2e 68 20 66 |ee Lumin|ance.h f|
|000000a0| 6f 72 20 70 72 6f 74 6f | 74 79 70 65 73 2e 0d 53 |or proto|types..S|
|000000b0| 65 65 20 4c 75 6d 69 6e | 61 6e 63 65 2e 6e 6f 74 |ee Lumin|ance.not|
|000000c0| 65 20 66 6f 72 20 65 78 | 70 6c 61 6e 61 74 69 6f |e for ex|planatio|
|000000d0| 6e 2e 0d 41 6c 73 6f 20 | 73 65 65 3a 0d 44 2e 47 |n..Also |see:.D.G|
|000000e0| 2e 20 50 65 6c 6c 69 20 | 61 6e 64 20 4c 2e 20 5a |. Pelli |and L. Z|
|000000f0| 68 61 6e 67 20 28 31 39 | 39 31 29 20 41 63 63 75 |hang (19|91) Accu|
|00000100| 72 61 74 65 20 63 6f 6e | 74 72 6f 6c 20 6f 66 20 |rate con|trol of |
|00000110| 63 6f 6e 74 72 61 73 74 | 20 6f 6e 20 6d 69 63 72 |contrast| on micr|
|00000120| 6f 63 6f 6d 70 75 74 65 | 72 20 64 69 73 70 6c 61 |ocompute|r displa|
|00000130| 79 73 2e 20 0d 56 69 73 | 69 6f 6e 20 52 65 73 65 |ys. .Vis|ion Rese|
|00000140| 61 72 63 68 2c 20 33 31 | 3a 31 33 33 37 2d 31 33 |arch, 31|:1337-13|
|00000150| 36 30 2e 0d 0d 43 6f 70 | 79 72 69 67 68 74 20 28 |60...Cop|yright (|
|00000160| 63 29 20 31 39 38 39 2d | 31 39 39 35 20 44 65 6e |c) 1989-|1995 Den|
|00000170| 69 73 20 47 2e 20 50 65 | 6c 6c 69 2e 20 54 68 69 |is G. Pe|lli. Thi|
|00000180| 73 20 73 6f 66 74 77 61 | 72 65 20 69 73 20 66 72 |s softwa|re is fr|
|00000190| 65 65 3b 20 79 6f 75 20 | 6d 61 79 20 75 73 65 20 |ee; you |may use |
|000001a0| 69 74 20 69 6e 0d 79 6f | 75 72 20 72 65 73 65 61 |it in.yo|ur resea|
|000001b0| 72 63 68 20 61 6e 64 20 | 67 69 76 65 20 69 74 20 |rch and |give it |
|000001c0| 61 77 61 79 20 74 6f 20 | 6f 74 68 65 72 73 2c 20 |away to |others, |
|000001d0| 77 69 74 68 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |with the| followi|
|000001e0| 6e 67 20 72 65 73 74 72 | 69 63 74 69 6f 6e 73 2e |ng restr|ictions.|
|000001f0| 20 41 6e 79 0d 63 6f 70 | 79 20 79 6f 75 20 67 69 | Any.cop|y you gi|
|00000200| 76 65 20 61 77 61 79 20 | 6d 75 73 74 20 69 6e 63 |ve away |must inc|
|00000210| 6c 75 64 65 20 74 68 69 | 73 20 70 61 72 61 67 72 |lude thi|s paragr|
|00000220| 61 70 68 2c 20 75 6e 6d | 6f 64 69 66 69 65 64 2c |aph, unm|odified,|
|00000230| 20 61 6e 64 2c 20 69 66 | 20 79 6f 75 20 68 61 76 | and, if| you hav|
|00000240| 65 0d 6d 61 64 65 20 61 | 6e 79 20 63 68 61 6e 67 |e.made a|ny chang|
|00000250| 65 73 20 74 6f 20 74 68 | 65 20 72 65 73 74 20 6f |es to th|e rest o|
|00000260| 66 20 74 68 65 20 66 69 | 6c 65 2c 20 6d 75 73 74 |f the fi|le, must|
|00000270| 20 69 6e 63 6c 75 64 65 | 20 61 20 6e 6f 74 65 2c | include| a note,|
|00000280| 20 61 64 64 65 64 20 74 | 6f 20 48 49 53 54 4f 52 | added t|o HISTOR|
|00000290| 59 0d 62 65 6c 6f 77 2c | 20 67 69 76 69 6e 67 20 |Y.below,| giving |
|000002a0| 79 6f 75 72 20 6e 61 6d | 65 2c 20 74 68 65 20 64 |your nam|e, the d|
|000002b0| 61 74 65 2c 20 61 6e 64 | 20 61 20 64 65 73 63 72 |ate, and| a descr|
|000002c0| 69 70 74 69 6f 6e 20 6f | 66 20 74 68 65 20 63 68 |iption o|f the ch|
|000002d0| 61 6e 67 65 73 2e 20 54 | 68 69 73 0d 73 6f 66 74 |anges. T|his.soft|
|000002e0| 77 61 72 65 20 6d 61 79 | 20 6e 6f 74 20 62 65 20 |ware may| not be |
|000002f0| 73 6f 6c 64 2c 20 77 68 | 65 74 68 65 72 20 69 6e |sold, wh|ether in|
|00000300| 20 73 6f 75 72 63 65 20 | 6f 72 20 63 6f 6d 70 69 | source |or compi|
|00000310| 6c 65 64 20 66 6f 72 6d | 2c 20 77 69 74 68 6f 75 |led form|, withou|
|00000320| 74 20 6d 79 0d 70 65 72 | 6d 69 73 73 69 6f 6e 2e |t my.per|mission.|
|00000330| 20 49 20 68 6f 70 65 20 | 79 6f 75 20 77 69 6c 6c | I hope |you will|
|00000340| 20 66 69 6e 64 20 74 68 | 69 73 20 73 6f 66 74 77 | find th|is softw|
|00000350| 61 72 65 20 75 73 65 66 | 75 6c 2c 20 62 75 74 20 |are usef|ul, but |
|00000360| 49 20 63 61 6e 27 74 20 | 70 72 6f 6d 69 73 65 20 |I can't |promise |
|00000370| 74 68 61 74 0d 69 74 20 | 77 69 6c 6c 20 77 6f 72 |that.it |will wor|
|00000380| 6b 20 66 6f 72 20 79 6f | 75 2c 20 61 6e 64 20 61 |k for yo|u, and a|
|00000390| 6d 20 6e 6f 74 20 6f 66 | 66 65 72 69 6e 67 20 61 |m not of|fering a|
|000003a0| 6e 79 20 73 75 70 70 6f | 72 74 2e 20 54 68 61 74 |ny suppo|rt. That|
|000003b0| 27 73 20 77 68 79 20 69 | 74 27 73 20 66 72 65 65 |'s why i|t's free|
|000003c0| 2e 20 49 0d 77 6f 75 6c | 64 20 61 70 70 72 65 63 |. I.woul|d apprec|
|000003d0| 69 61 74 65 20 72 65 70 | 6f 72 74 73 20 6f 66 20 |iate rep|orts of |
|000003e0| 62 75 67 73 20 61 6e 64 | 20 69 6d 70 72 6f 76 65 |bugs and| improve|
|000003f0| 6d 65 6e 74 73 2e 0d 0d | 44 65 6e 69 73 20 47 2e |ments...|Denis G.|
|00000400| 20 50 65 6c 6c 69 0d 44 | 65 70 61 72 74 6d 65 6e | Pelli.D|epartmen|
|00000410| 74 20 6f 66 20 50 73 79 | 63 68 6f 6c 6f 67 79 0d |t of Psy|chology.|
|00000420| 4e 65 77 20 59 6f 72 6b | 20 55 6e 69 76 65 72 73 |New York| Univers|
|00000430| 69 74 79 0d 36 20 57 61 | 73 68 69 6e 67 74 6f 6e |ity.6 Wa|shington|
|00000440| 20 50 6c 61 63 65 0d 4e | 65 77 20 59 6f 72 6b 2c | Place.N|ew York,|
|00000450| 20 4e 59 20 31 30 30 30 | 33 0d 64 65 6e 69 73 40 | NY 1000|3.denis@|
|00000460| 63 6e 73 2e 6e 79 75 2e | 65 64 75 0d 0d 48 49 53 |cns.nyu.|edu..HIS|
|00000470| 54 4f 52 59 3a 0d 0d 34 | 2f 32 34 2f 38 39 20 64 |TORY:..4|/24/89 d|
|00000480| 67 70 20 66 69 72 73 74 | 20 77 6f 72 6b 69 6e 67 |gp first| working|
|00000490| 20 76 65 72 73 69 6f 6e | 2e 0d 34 2f 32 38 2f 38 | version|..4/28/8|
|000004a0| 39 20 64 67 70 20 61 64 | 64 65 64 20 64 65 76 69 |9 dgp ad|ded devi|
|000004b0| 63 65 20 61 72 67 75 6d | 65 6e 74 2e 0d 36 2f 32 |ce argum|ent..6/2|
|000004c0| 33 2f 38 39 20 64 67 70 | 20 61 64 64 65 64 20 73 |3/89 dgp| added s|
|000004d0| 75 70 70 6f 72 74 20 66 | 6f 72 20 61 20 76 69 64 |upport f|or a vid|
|000004e0| 65 6f 20 61 74 74 65 6e | 75 61 74 6f 72 20 74 68 |eo atten|uator th|
|000004f0| 61 74 20 68 61 73 20 75 | 6e 65 71 75 61 6c 20 67 |at has u|nequal g|
|00000500| 61 69 6e 20 69 6e 20 74 | 68 65 20 74 68 72 65 65 |ain in t|he three|
|00000510| 0d 09 09 09 63 68 61 6e | 6e 65 6c 73 2e 20 41 64 |....chan|nels. Ad|
|00000520| 64 65 64 20 4c 6f 61 64 | 43 6c 75 74 28 29 20 61 |ded Load|Clut() a|
|00000530| 6e 64 20 4c 75 6d 69 6e | 61 6e 63 65 43 6c 75 74 |nd Lumin|anceClut|
|00000540| 28 29 20 72 6f 75 74 69 | 6e 65 73 2e 0d 37 2f 33 |() routi|nes..7/3|
|00000550| 30 2f 38 39 20 64 67 70 | 20 72 65 70 6c 61 63 65 |0/89 dgp| replace|
|00000560| 64 20 63 61 6c 6c 20 74 | 6f 20 53 65 74 45 6e 74 |d call t|o SetEnt|
|00000570| 72 69 65 73 20 28 77 68 | 69 63 68 20 63 61 6c 6c |ries (wh|ich call|
|00000580| 73 20 74 68 65 20 43 6f | 6c 6f 72 20 4d 61 6e 61 |s the Co|lor Mana|
|00000590| 67 65 72 29 20 62 79 20 | 61 20 63 61 6c 6c 0d 09 |ger) by |a call..|
|000005a0| 09 09 74 6f 20 47 44 53 | 65 74 45 6e 74 72 69 65 |..to GDS|etEntrie|
|000005b0| 73 20 28 77 68 69 63 68 | 20 63 61 6c 6c 73 20 74 |s (which| calls t|
|000005c0| 68 65 20 64 65 76 69 63 | 65 20 64 72 69 76 65 72 |he devic|e driver|
|000005d0| 29 2e 0d 38 2f 31 30 2f | 38 39 20 64 67 70 20 66 |)..8/10/|89 dgp f|
|000005e0| 69 78 65 64 20 62 75 67 | 73 2e 0d 38 2f 31 33 2f |ixed bug|s..8/13/|
|000005f0| 38 39 20 64 67 70 20 72 | 65 77 72 6f 74 65 20 4c |89 dgp r|ewrote L|
|00000600| 54 6f 56 28 29 20 74 6f | 20 75 73 65 20 6e 74 68 |ToV() to| use nth|
|00000610| 20 6f 72 64 65 72 20 70 | 6f 6c 79 6e 6f 6d 69 61 | order p|olynomia|
|00000620| 6c 2e 20 42 72 6f 6b 65 | 20 75 70 20 4c 69 6e 65 |l. Broke| up Line|
|00000630| 61 72 69 7a 65 43 6c 75 | 74 20 69 6e 74 6f 0d 09 |arizeClu|t into..|
|00000640| 09 09 74 68 72 65 65 20 | 72 6f 75 74 69 6e 65 73 |..three |routines|
|00000650| 2d 2d 53 65 74 4c 75 6d | 69 6e 61 6e 63 65 52 61 |--SetLum|inanceRa|
|00000660| 6e 67 65 2c 20 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |nge, Set|Luminanc|
|00000670| 65 2c 20 61 6e 64 20 53 | 65 74 4c 75 6d 69 6e 61 |e, and S|etLumina|
|00000680| 6e 63 65 73 2d 2d 74 68 | 65 0d 09 09 09 6c 61 73 |nces--th|e....las|
|00000690| 74 20 6f 66 20 77 68 69 | 63 68 20 69 73 20 65 71 |t of whi|ch is eq|
|000006a0| 75 69 76 61 6c 65 6e 74 | 20 74 6f 20 74 68 65 20 |uivalent| to the |
|000006b0| 6f 6c 64 20 4c 69 6e 65 | 61 72 69 7a 65 43 6c 75 |old Line|arizeClu|
|000006c0| 74 2e 0d 38 2f 31 36 2f | 38 39 09 64 67 70 09 41 |t..8/16/|89.dgp.A|
|000006d0| 66 74 65 72 20 72 65 61 | 64 69 6e 67 20 74 68 65 |fter rea|ding the|
|000006e0| 20 42 72 6f 6f 6b 74 72 | 65 65 20 44 41 43 20 6d | Brooktr|ee DAC m|
|000006f0| 61 6e 75 61 6c 20 49 20 | 63 68 61 6e 67 65 64 20 |anual I |changed |
|00000700| 74 68 65 20 64 6f 63 75 | 6d 65 6e 74 61 74 69 6f |the docu|mentatio|
|00000710| 6e 20 61 6e 64 0d 09 09 | 09 69 6e 63 72 65 61 73 |n and...|.increas|
|00000720| 65 64 20 74 6f 6c 65 72 | 61 6e 63 65 20 66 72 6f |ed toler|ance fro|
|00000730| 6d 20 30 2e 35 20 74 6f | 20 31 20 4c 53 42 2c 20 |m 0.5 to| 1 LSB, |
|00000740| 61 6e 64 20 6e 6f 77 20 | 75 73 65 20 74 68 65 20 |and now |use the |
|00000750| 68 69 67 68 65 73 74 0d | 09 09 09 6c 75 6d 69 6e |highest.|...lumin|
|00000760| 61 6e 63 65 20 67 61 69 | 6e 20 28 77 6f 72 73 74 |ance gai|n (worst|
|00000770| 20 63 61 73 65 29 20 6f | 76 65 72 20 74 68 65 20 | case) o|ver the |
|00000780| 72 65 71 75 65 73 74 65 | 64 20 72 61 6e 67 65 20 |requeste|d range |
|00000790| 74 6f 20 74 72 61 6e 73 | 66 6f 72 6d 20 69 74 0d |to trans|form it.|
|000007a0| 09 09 09 69 6e 74 6f 20 | 61 20 6c 75 6d 69 6e 61 |...into |a lumina|
|000007b0| 6e 63 65 20 64 69 66 66 | 65 72 65 6e 63 65 20 74 |nce diff|erence t|
|000007c0| 6f 6c 65 72 61 6e 63 65 | 2e 0d 38 2f 32 31 2f 38 |olerance|..8/21/8|
|000007d0| 39 09 64 67 70 09 4d 61 | 64 65 20 6d 69 6e 6f 72 |9.dgp.Ma|de minor|
|000007e0| 20 69 6d 70 72 6f 76 65 | 6d 65 6e 74 73 20 69 6e | improve|ments in|
|000007f0| 20 4c 54 6f 56 28 29 20 | 74 6f 20 64 65 61 6c 20 | LToV() |to deal |
|00000800| 77 69 74 68 20 66 61 69 | 6c 75 72 65 20 74 6f 20 |with fai|lure to |
|00000810| 63 6f 6e 76 65 72 67 65 | 20 64 75 65 20 74 6f 20 |converge| due to |
|00000820| 0d 09 09 09 67 65 74 74 | 69 6e 67 20 73 74 75 63 |....gett|ing stuc|
|00000830| 6b 20 69 6e 20 61 20 6c | 6f 63 61 6c 20 6d 69 6e |k in a l|ocal min|
|00000840| 69 6d 75 6d 20 6f 66 20 | 74 68 65 20 71 75 61 72 |imum of |the quar|
|00000850| 74 69 63 2e 20 4d 79 20 | 73 6f 6c 75 74 69 6f 6e |tic. My |solution|
|00000860| 20 69 73 20 74 6f 20 6e | 6f 77 0d 09 09 09 72 65 | is to n|ow....re|
|00000870| 71 75 69 72 65 20 74 68 | 61 74 20 4c 6d 69 6e 20 |quire th|at Lmin |
|00000880| 61 6e 64 20 4c 6d 61 78 | 20 62 65 20 66 69 6c 6c |and Lmax| be fill|
|00000890| 65 64 20 69 6e 20 62 79 | 20 74 68 65 20 75 73 65 |ed in by| the use|
|000008a0| 72 20 69 6e 20 74 68 65 | 20 63 61 6c 69 62 72 61 |r in the| calibra|
|000008b0| 74 69 6f 6e 0d 09 09 09 | 73 74 72 75 63 74 75 72 |tion....|structur|
|000008c0| 65 2e 20 49 6e 20 70 72 | 61 63 74 69 63 65 20 74 |e. In pr|actice t|
|000008d0| 68 69 73 20 77 69 6c 6c | 20 67 75 61 72 61 6e 74 |his will| guarant|
|000008e0| 65 65 20 74 68 61 74 20 | 74 68 65 20 6d 69 6e 69 |ee that |the mini|
|000008f0| 6d 75 6d 20 6c 75 6d 69 | 6e 61 6e 63 65 0d 09 09 |mum lumi|nance...|
|00000900| 09 77 69 6c 6c 20 6e 6f | 74 20 62 65 20 62 65 6c |.will no|t be bel|
|00000910| 6f 77 20 74 68 65 20 6c | 6f 63 61 6c 20 6d 69 6e |ow the l|ocal min|
|00000920| 69 6d 75 6d 20 66 6f 75 | 6e 64 20 61 74 20 74 68 |imum fou|nd at th|
|00000930| 65 20 62 61 73 65 20 6f | 66 20 74 68 65 20 72 69 |e base o|f the ri|
|00000940| 73 69 6e 67 20 63 75 72 | 76 65 2e 0d 09 09 09 4c |sing cur|ve.....L|
|00000950| 61 73 74 20 77 65 65 6b | 20 49 20 61 6c 73 6f 20 |ast week| I also |
|00000960| 63 68 61 6e 67 65 64 20 | 74 68 65 20 4c 54 6f 56 |changed |the LToV|
|00000970| 20 61 6c 67 6f 72 69 74 | 68 6d 20 73 6c 69 67 68 | algorit|hm sligh|
|00000980| 74 6c 79 2c 20 74 6f 20 | 64 6f 20 61 20 62 69 73 |tly, to |do a bis|
|00000990| 65 63 74 69 6f 6e 20 69 | 66 0d 09 09 09 4e 65 77 |ection i|f....New|
|000009a0| 74 6f 6e 27 73 20 6d 65 | 74 68 6f 64 20 77 6f 75 |ton's me|thod wou|
|000009b0| 6c 64 20 74 61 6b 65 20 | 75 73 20 6f 75 74 20 6f |ld take |us out o|
|000009c0| 66 20 72 61 6e 67 65 2e | 0d 39 2f 37 2f 38 39 20 |f range.|.9/7/89 |
|000009d0| 64 67 70 09 46 69 78 65 | 64 20 62 75 67 20 69 6e |dgp.Fixe|d bug in|
|000009e0| 20 73 6f 72 74 69 6e 67 | 20 72 6f 75 74 69 6e 65 | sorting| routine|
|000009f0| 2c 20 53 6f 72 74 28 29 | 2e 0d 39 2f 31 30 2f 38 |, Sort()|..9/10/8|
|00000a00| 39 20 64 67 70 09 43 6f | 6d 6d 65 6e 74 65 64 20 |9 dgp.Co|mmented |
|00000a10| 6f 75 74 20 74 68 65 20 | 70 6f 6c 79 6e 6f 6d 69 |out the |polynomi|
|00000a20| 61 6c 20 76 65 72 73 69 | 6f 6e 73 20 6f 66 20 56 |al versi|ons of V|
|00000a30| 54 6f 4c 20 61 6e 64 20 | 4c 54 6f 56 20 61 6e 64 |ToL and |LToV and|
|00000a40| 20 72 65 70 6c 61 63 65 | 20 74 68 65 6d 20 62 79 | replace| them by|
|00000a50| 0d 09 09 09 6e 65 77 20 | 76 65 72 73 69 6f 6e 73 |....new |versions|
|00000a60| 20 74 68 61 74 20 75 73 | 65 20 61 20 70 6f 77 65 | that us|e a powe|
|00000a70| 72 20 6c 61 77 2e 20 54 | 68 65 20 70 6f 77 65 72 |r law. T|he power|
|00000a80| 20 6c 61 77 20 69 73 20 | 61 20 6d 61 72 67 69 6e | law is |a margin|
|00000a90| 61 6c 6c 79 20 62 65 74 | 74 65 72 20 66 69 74 0d |ally bet|ter fit.|
|00000aa0| 09 09 09 74 68 61 6e 20 | 61 20 36 74 68 20 6f 72 |...than |a 6th or|
|00000ab0| 64 65 72 20 70 6f 6c 79 | 6e 6f 6d 69 61 6c 20 28 |der poly|nomial (|
|00000ac0| 75 73 69 6e 67 20 6f 6e | 6c 79 20 34 20 69 6e 73 |using on|ly 4 ins|
|00000ad0| 74 65 61 64 20 6f 66 20 | 37 20 70 61 72 61 6d 65 |tead of |7 parame|
|00000ae0| 74 65 72 73 29 20 61 6e | 64 20 69 74 73 0d 09 09 |ters) an|d its...|
|00000af0| 09 69 6e 76 65 72 73 65 | 20 63 61 6e 20 62 65 20 |.inverse| can be |
|00000b00| 63 6f 6d 70 75 74 65 64 | 20 6d 75 63 68 20 6d 6f |computed| much mo|
|00000b10| 72 65 20 71 75 69 63 6b | 6c 79 2c 20 61 62 6f 75 |re quick|ly, abou|
|00000b20| 74 20 30 2e 33 20 6d 73 | 20 69 6e 73 74 65 61 64 |t 0.3 ms| instead|
|00000b30| 20 6f 66 20 32 20 6d 73 | 2e 0d 39 2f 31 31 2f 38 | of 2 ms|..9/11/8|
|00000b40| 39 20 64 67 70 09 44 65 | 63 69 64 69 6e 67 20 74 |9 dgp.De|ciding t|
|00000b50| 6f 20 62 65 20 69 6e 64 | 65 63 69 73 69 76 65 2c |o be ind|ecisive,|
|00000b60| 20 49 20 69 6e 74 72 6f | 64 75 63 65 64 20 61 20 | I intro|duced a |
|00000b70| 63 6f 6e 64 69 74 69 6f | 6e 61 6c 20 50 4f 57 45 |conditio|nal POWE|
|00000b80| 52 5f 4c 41 57 5f 46 49 | 54 0d 09 09 09 74 6f 20 |R_LAW_FI|T....to |
|00000b90| 63 6f 6e 74 72 6f 6c 20 | 74 68 65 20 63 68 6f 69 |control |the choi|
|00000ba0| 63 65 20 6f 66 20 70 6f | 77 65 72 20 6c 61 77 20 |ce of po|wer law |
|00000bb0| 6f 72 20 70 6f 6c 79 6e | 6f 6d 69 61 6c 20 66 69 |or polyn|omial fi|
|00000bc0| 74 20 66 6f 72 20 4c 54 | 6f 56 20 61 6e 64 20 56 |t for LT|oV and V|
|00000bd0| 54 6f 4c 2e 0d 39 2f 31 | 36 2f 38 39 09 64 67 70 |ToL..9/1|6/89.dgp|
|00000be0| 09 48 61 76 69 6e 67 20 | 66 69 6e 69 73 68 65 64 |.Having |finished|
|00000bf0| 20 77 72 69 74 69 6e 67 | 20 74 68 65 20 70 61 70 | writing| the pap|
|00000c00| 65 72 20 28 50 65 6c 6c | 69 20 26 20 5a 68 61 6e |er (Pell|i & Zhan|
|00000c10| 67 2c 20 31 39 39 31 29 | 20 49 20 63 61 6d 65 20 |g, 1991)| I came |
|00000c20| 62 61 63 6b 20 74 6f 0d | 09 09 09 63 68 61 6e 67 |back to.|...chang|
|00000c30| 65 20 74 68 65 20 70 72 | 6f 67 72 61 6d 20 74 6f |e the pr|ogram to|
|00000c40| 20 61 67 72 65 65 20 77 | 69 74 68 20 77 68 61 74 | agree w|ith what|
|00000c50| 20 49 20 77 72 6f 74 65 | 2e 20 49 20 63 68 61 6e | I wrote|. I chan|
|00000c60| 67 65 64 20 74 68 65 20 | 65 71 75 69 76 61 6c 65 |ged the |equivale|
|00000c70| 6e 74 0d 09 09 09 6e 75 | 6d 62 65 72 20 74 6f 6c |nt....nu|mber tol|
|00000c80| 65 72 61 6e 63 65 20 74 | 6f 20 62 65 20 74 68 65 |erance t|o be the|
|00000c90| 20 73 75 6d 20 69 6e 73 | 74 65 61 64 20 6f 66 20 | sum ins|tead of |
|00000ca0| 74 68 65 20 6d 61 78 69 | 6d 75 6d 20 6f 66 20 74 |the maxi|mum of t|
|00000cb0| 68 65 20 0d 09 09 09 76 | 61 72 69 61 62 6c 65 2d |he ....v|ariable-|
|00000cc0| 64 61 63 20 67 61 69 6e | 73 2e 0d 39 2f 32 35 2f |dac gain|s..9/25/|
|00000cd0| 38 39 20 64 67 70 20 46 | 69 78 65 64 20 6d 69 6e |89 dgp F|ixed min|
|00000ce0| 6f 72 20 62 75 67 20 69 | 6e 20 63 6f 6d 70 75 74 |or bug i|n comput|
|00000cf0| 61 74 69 6f 6e 20 6f 66 | 20 74 6f 6c 65 72 61 6e |ation of| toleran|
|00000d00| 63 65 2e 20 4e 6f 77 20 | 67 69 76 65 73 20 63 6f |ce. Now |gives co|
|00000d10| 72 72 65 63 74 20 61 6e | 73 77 65 72 20 65 76 65 |rrect an|swer eve|
|00000d20| 6e 0d 09 09 09 77 68 65 | 6e 20 74 68 65 20 6c 6f |n....whe|n the lo|
|00000d30| 77 4c 75 6d 69 6e 61 6e | 63 65 20 6f 72 20 68 69 |wLuminan|ce or hi|
|00000d40| 67 68 4c 75 6d 69 6e 61 | 6e 63 65 20 69 73 20 6f |ghLumina|nce is o|
|00000d50| 75 74 20 6f 66 20 72 61 | 6e 67 65 2e 0d 31 30 2f |ut of ra|nge..10/|
|00000d60| 39 2f 38 39 20 64 67 70 | 09 4d 61 64 65 20 6d 69 |9/89 dgp|.Made mi|
|00000d70| 6e 6f 72 20 63 68 61 6e | 67 65 20 73 6f 20 74 68 |nor chan|ge so th|
|00000d80| 61 74 20 77 68 65 6e 20 | 73 6f 6d 65 20 6f 66 20 |at when |some of |
|00000d90| 74 68 65 20 67 61 69 6e | 5b 5d 20 61 72 65 20 7a |the gain|[] are z|
|00000da0| 65 72 6f 20 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 |ero SetL|uminance|
|00000db0| 20 77 69 6c 6c 0d 09 09 | 09 6c 6f 61 64 20 7a 65 | will...|.load ze|
|00000dc0| 72 6f 20 69 6e 74 6f 20 | 74 68 65 20 75 6e 75 73 |ro into |the unus|
|00000dd0| 65 64 20 63 6f 6c 6f 72 | 53 70 65 63 20 61 72 72 |ed color|Spec arr|
|00000de0| 61 79 20 65 6c 65 6d 65 | 6e 74 73 2e 20 54 68 69 |ay eleme|nts. Thi|
|00000df0| 73 20 69 73 20 6f 6e 6c | 79 20 61 20 63 6f 73 6d |s is onl|y a cosm|
|00000e00| 65 74 69 63 0d 09 09 09 | 63 68 61 6e 67 65 2e 0d |etic....|change..|
|00000e10| 31 30 2f 32 38 2f 38 39 | 20 64 67 70 20 4d 61 64 |10/28/89| dgp Mad|
|00000e20| 65 20 6d 69 6e 6f 72 20 | 63 68 61 6e 67 65 73 2e |e minor |changes.|
|00000e30| 20 49 20 64 65 63 6c 61 | 72 65 64 20 4c 54 6f 56 | I decla|red LToV|
|00000e40| 50 6f 6c 79 6e 6f 6d 69 | 61 6c 20 61 6e 64 20 4c |Polynomi|al and L|
|00000e50| 54 6f 56 50 6f 77 65 72 | 20 61 6e 64 0d 09 09 09 |ToVPower| and....|
|00000e60| 56 54 6f 4c 50 6f 6c 79 | 6e 6f 6d 69 61 6c 20 61 |VToLPoly|nomial a|
|00000e70| 6e 64 20 56 54 6f 4c 50 | 6f 77 65 72 20 69 6e 73 |nd VToLP|ower ins|
|00000e80| 74 65 61 64 20 6f 66 20 | 68 61 76 69 6e 67 20 61 |tead of |having a|
|00000e90| 20 63 6f 6e 64 69 74 69 | 6f 6e 61 6c 20 63 6f 6d | conditi|onal com|
|00000ea0| 70 69 6c 61 74 69 6f 6e | 2e 20 0d 09 09 09 54 68 |pilation|. ....Th|
|00000eb0| 69 73 20 6d 61 6b 65 73 | 20 62 6f 74 68 20 66 6c |is makes| both fl|
|00000ec0| 61 76 6f 72 73 20 6f 66 | 20 72 6f 75 74 69 6e 65 |avors of| routine|
|00000ed0| 20 61 6c 77 61 79 73 20 | 61 76 61 69 6c 61 62 6c | always |availabl|
|00000ee0| 65 2e 20 49 20 61 6c 73 | 6f 20 63 68 61 6e 67 65 |e. I als|o change|
|00000ef0| 64 20 0d 09 09 09 4c 54 | 6f 56 50 6f 6c 79 6e 6f |d ....LT|oVPolyno|
|00000f00| 6d 69 61 6c 20 74 6f 20 | 75 73 65 20 4c 54 6f 56 |mial to |use LToV|
|00000f10| 50 6f 77 65 72 20 69 6e | 73 74 65 61 64 20 6f 66 |Power in|stead of|
|00000f20| 20 4c 54 6f 56 51 75 61 | 64 72 61 74 69 63 20 66 | LToVQua|dratic f|
|00000f30| 6f 72 20 69 74 73 20 69 | 6e 69 74 69 61 6c 20 0d |or its i|nitial .|
|00000f40| 09 09 09 67 75 65 73 73 | 2e 20 54 68 65 20 71 75 |...guess|. The qu|
|00000f50| 61 64 72 61 74 69 63 20 | 67 75 65 73 73 20 77 61 |adratic |guess wa|
|00000f60| 73 20 6f 66 74 65 6e 20 | 70 6f 6f 72 20 61 6e 64 |s often |poor and|
|00000f70| 20 6f 63 63 61 73 69 6f | 6e 61 6c 6c 79 20 6c 65 | occasio|nally le|
|00000f80| 64 20 74 6f 20 0d 09 09 | 09 63 6f 6e 76 65 72 67 |d to ...|.converg|
|00000f90| 65 6e 63 65 20 70 72 6f | 62 6c 65 6d 73 2e 20 49 |ence pro|blems. I|
|00000fa0| 66 20 74 68 65 20 70 6f | 77 65 72 20 6c 61 77 20 |f the po|wer law |
|00000fb0| 66 69 74 20 69 73 20 6e | 6f 74 20 61 76 61 69 6c |fit is n|ot avail|
|00000fc0| 61 62 6c 65 20 74 68 65 | 6e 20 69 74 20 72 65 76 |able the|n it rev|
|00000fd0| 65 72 74 73 0d 09 09 09 | 74 6f 20 75 73 69 6e 67 |erts....|to using|
|00000fe0| 20 74 68 65 20 71 75 61 | 64 72 61 74 69 63 20 66 | the qua|dratic f|
|00000ff0| 69 74 2e 20 49 66 20 74 | 68 61 74 27 73 20 6e 6f |it. If t|hat's no|
|00001000| 74 20 61 76 61 69 6c 61 | 62 6c 65 20 74 68 65 6e |t availa|ble then|
|00001010| 20 69 74 20 72 65 76 65 | 72 74 73 20 74 6f 20 75 | it reve|rts to u|
|00001020| 73 69 6e 67 0d 09 09 09 | 61 20 6d 69 64 64 6c 65 |sing....|a middle|
|00001030| 2d 6f 66 2d 72 61 6e 67 | 65 20 67 75 65 73 73 2e |-of-rang|e guess.|
|00001040| 0d 31 30 2f 32 38 2f 38 | 39 20 64 67 70 20 49 20 |.10/28/8|9 dgp I |
|00001050| 65 6c 69 6d 69 6e 61 74 | 65 64 20 74 68 65 20 63 |eliminat|ed the c|
|00001060| 6f 6d 70 69 6c 65 2d 74 | 69 6d 65 20 66 6c 61 67 |ompile-t|ime flag|
|00001070| 20 50 4f 57 45 52 5f 4c | 41 57 5f 46 49 54 20 61 | POWER_L|AW_FIT a|
|00001080| 6e 64 20 69 6e 73 74 65 | 61 64 20 75 73 65 20 77 |nd inste|ad use w|
|00001090| 68 69 63 68 65 76 65 72 | 2c 20 0d 09 09 09 70 6f |hichever|, ....po|
|000010a0| 6c 79 6e 6f 6d 69 61 6c | 20 6f 72 20 70 6f 77 65 |lynomial| or powe|
|000010b0| 72 2c 20 70 72 6f 76 69 | 64 65 73 20 61 20 62 65 |r, provi|des a be|
|000010c0| 74 74 65 72 20 66 69 74 | 2c 20 61 73 20 64 65 74 |tter fit|, as det|
|000010d0| 65 72 6d 69 6e 65 64 20 | 61 74 20 72 75 6e 20 74 |ermined |at run t|
|000010e0| 69 6d 65 2e 20 49 20 0d | 09 09 09 62 69 61 73 65 |ime. I .|...biase|
|000010f0| 64 20 74 68 65 20 63 6f | 6d 70 61 72 69 73 6f 6e |d the co|mparison|
|00001100| 20 6f 66 20 72 6d 73 20 | 65 72 72 6f 72 20 74 6f | of rms |error to|
|00001110| 20 66 61 76 6f 72 20 74 | 68 65 20 70 6f 77 65 72 | favor t|he power|
|00001120| 20 6c 61 77 20 66 69 74 | 20 73 69 6e 63 65 20 69 | law fit| since i|
|00001130| 74 20 68 61 73 20 0d 09 | 09 09 66 65 77 20 70 61 |t has ..|..few pa|
|00001140| 72 61 6d 65 74 65 72 73 | 20 61 6e 64 20 63 61 6e |rameters| and can|
|00001150| 20 62 65 20 69 6e 76 65 | 72 74 65 64 20 6d 75 63 | be inve|rted muc|
|00001160| 68 20 6d 6f 72 65 20 71 | 75 69 63 6b 6c 79 2e 20 |h more q|uickly. |
|00001170| 4e 6f 74 65 3a 20 69 66 | 20 74 68 65 20 0d 09 09 |Note: if| the ...|
|00001180| 09 70 6f 77 65 72 2c 20 | 70 6f 6c 79 6e 6f 6d 69 |.power, |polynomi|
|00001190| 61 6c 2c 20 6f 72 20 71 | 75 61 64 72 61 74 69 63 |al, or q|uadratic|
|000011a0| 20 66 69 74 20 70 61 72 | 61 6d 65 74 65 72 73 20 | fit par|ameters |
|000011b0| 61 72 65 20 6e 6f 74 20 | 73 75 70 70 6c 69 65 64 |are not |supplied|
|000011c0| 20 74 68 65 6e 20 74 68 | 65 20 0d 09 09 09 61 70 | then th|e ....ap|
|000011d0| 70 72 6f 70 72 69 61 74 | 65 20 4c 52 2e 70 6f 77 |propriat|e LR.pow|
|000011e0| 65 72 45 72 72 6f 72 2c | 20 4c 52 2e 70 6f 6c 79 |erError,| LR.poly|
|000011f0| 6e 6f 6d 69 61 6c 45 72 | 72 6f 72 2c 20 6f 72 20 |nomialEr|ror, or |
|00001200| 4c 52 2e 71 75 61 64 72 | 61 74 69 63 45 72 72 6f |LR.quadr|aticErro|
|00001210| 72 20 66 69 65 6c 64 20 | 0d 09 09 09 73 68 6f 75 |r field |....shou|
|00001220| 6c 64 20 62 65 20 73 65 | 74 20 74 6f 20 69 6e 66 |ld be se|t to inf|
|00001230| 69 6e 69 74 79 3a 20 49 | 4e 46 20 6f 72 20 31 2e |inity: I|NF or 1.|
|00001240| 30 2f 30 2e 30 2e 0d 31 | 32 2f 35 2f 38 39 09 64 |0/0.0..1|2/5/89.d|
|00001250| 67 70 09 41 64 64 65 64 | 20 74 68 65 20 74 72 69 |gp.Added| the tri|
|00001260| 76 69 61 6c 20 72 6f 75 | 74 69 6e 65 20 4c 54 6f |vial rou|tine LTo|
|00001270| 4c 28 29 20 77 68 69 63 | 68 20 65 6e 66 6f 72 63 |L() whic|h enforc|
|00001280| 65 73 20 74 68 65 20 62 | 6f 75 6e 64 73 20 4c 50 |es the b|ounds LP|
|00001290| 2d 3e 4c 4d 69 6e 20 61 | 6e 64 20 0d 09 09 09 4c |->LMin a|nd ....L|
|000012a0| 50 2d 3e 4c 4d 61 78 2e | 0d 34 2f 32 2f 39 30 09 |P->LMax.|.4/2/90.|
|000012b0| 64 67 70 09 43 61 70 69 | 74 61 6c 69 7a 65 64 20 |dgp.Capi|talized |
|000012c0| 74 68 65 20 77 6f 72 64 | 20 22 54 6f 22 20 69 6e |the word| "To" in|
|000012d0| 20 61 6c 6c 20 66 75 6e | 63 74 69 6f 6e 20 6e 61 | all fun|ction na|
|000012e0| 6d 65 73 2c 20 65 2e 67 | 2e 20 4c 54 6f 4c 28 29 |mes, e.g|. LToL()|
|000012f0| 2e 0d 34 2f 32 32 2f 39 | 30 09 64 67 70 09 56 65 |..4/22/9|0.dgp.Ve|
|00001300| 72 73 69 6f 6e 20 31 2e | 34 2e 20 4d 61 64 65 20 |rsion 1.|4. Made |
|00001310| 6d 69 6e 6f 72 20 63 68 | 61 6e 67 65 73 20 74 6f |minor ch|anges to|
|00001320| 20 74 68 65 20 64 6f 63 | 75 6d 65 6e 74 61 74 69 | the doc|umentati|
|00001330| 6f 6e 2e 20 52 65 6e 61 | 6d 65 64 20 4c 54 6f 56 |on. Rena|med LToV|
|00001340| 28 29 20 74 6f 0d 09 09 | 09 4c 54 6f 56 46 6f 72 |() to...|.LToVFor|
|00001350| 6d 75 6c 61 69 63 28 29 | 2c 20 61 6e 64 20 69 6e |mulaic()|, and in|
|00001360| 74 72 6f 64 75 63 65 64 | 20 61 20 6e 65 77 20 4c |troduced| a new L|
|00001370| 54 6f 56 28 29 20 74 68 | 61 74 20 75 73 65 73 20 |ToV() th|at uses |
|00001380| 61 20 74 61 62 6c 65 20 | 74 6f 20 72 75 6e 20 66 |a table |to run f|
|00001390| 61 73 74 65 72 2e 0d 09 | 09 09 4c 54 6f 56 28 29 |aster...|..LToV()|
|000013a0| 20 74 61 6b 65 73 20 61 | 6e 20 61 76 65 72 61 67 | takes a|n averag|
|000013b0| 65 20 6f 66 20 31 37 30 | 20 b5 73 2c 20 77 68 65 |e of 170| .s, whe|
|000013c0| 72 65 61 73 20 4c 54 6f | 56 46 6f 72 6d 75 6c 61 |reas LTo|VFormula|
|000013d0| 69 63 28 29 20 74 61 6b | 65 73 0d 09 09 09 31 37 |ic() tak|es....17|
|000013e0| 30 30 20 b5 73 2e 20 49 | 20 61 6c 73 6f 20 6e 6f |00 .s. I| also no|
|000013f0| 77 20 75 73 65 20 74 68 | 65 20 4c 75 6d 69 6e 61 |w use th|e Lumina|
|00001400| 6e 63 65 54 61 62 6c 65 | 2c 20 69 66 20 61 76 61 |nceTable|, if ava|
|00001410| 69 6c 61 62 6c 65 2c 20 | 74 6f 20 73 70 65 65 64 |ilable, |to speed|
|00001420| 20 75 70 0d 09 09 09 56 | 54 6f 4c 28 29 20 73 6c | up....V|ToL() sl|
|00001430| 69 67 68 74 6c 79 2c 20 | 66 72 6f 6d 20 33 31 30 |ightly, |from 310|
|00001440| 20 b5 73 20 74 6f 20 31 | 38 30 20 b5 73 2e 20 45 | .s to 1|80 .s. E|
|00001450| 61 63 68 20 63 61 6c 6c | 20 74 6f 20 53 65 74 4c |ach call| to SetL|
|00001460| 75 6d 69 6e 61 6e 63 65 | 28 29 20 6e 6f 77 0d 09 |uminance|() now..|
|00001470| 09 09 74 61 6b 65 73 20 | 30 2e 39 20 6d 73 20 77 |..takes |0.9 ms w|
|00001480| 68 65 72 65 61 73 20 69 | 74 20 75 73 65 64 20 74 |hereas i|t used t|
|00001490| 6f 20 74 61 6b 65 20 32 | 2e 35 20 6d 73 2e 20 54 |o take 2|.5 ms. T|
|000014a0| 68 65 20 6c 6f 73 73 20 | 69 6e 20 61 63 63 75 72 |he loss |in accur|
|000014b0| 61 63 79 20 69 73 0d 09 | 09 09 6e 65 67 6c 69 67 |acy is..|..neglig|
|000014c0| 69 62 6c 65 2e 20 54 68 | 65 20 69 6e 74 65 72 70 |ible. Th|e interp|
|000014d0| 6f 6c 61 74 69 6f 6e 20 | 65 72 72 6f 72 20 63 61 |olation |error ca|
|000014e0| 6e 20 62 65 20 72 65 64 | 75 63 65 64 20 73 74 69 |n be red|uced sti|
|000014f0| 6c 6c 20 66 75 72 74 68 | 65 72 20 62 79 0d 09 09 |ll furth|er by...|
|00001500| 09 69 6e 63 72 65 61 73 | 69 6e 67 20 4c 55 4d 49 |.increas|ing LUMI|
|00001510| 4e 41 4e 43 45 53 5f 49 | 4e 5f 54 41 42 4c 45 2e |NANCES_I|N_TABLE.|
|00001520| 20 45 61 63 68 20 64 6f | 75 62 6c 69 6e 67 20 6f | Each do|ubling o|
|00001530| 66 20 74 68 65 20 74 61 | 62 6c 65 20 73 69 7a 65 |f the ta|ble size|
|00001540| 20 71 75 61 72 74 65 72 | 73 20 74 68 65 0d 09 09 | quarter|s the...|
|00001550| 09 6d 61 78 69 6d 75 6d | 20 70 6f 73 73 69 62 6c |.maximum| possibl|
|00001560| 65 20 65 72 72 6f 72 20 | 6f 66 20 74 68 65 20 69 |e error |of the i|
|00001570| 6e 74 65 72 70 6f 6c 61 | 74 69 6f 6e 2e 0d 34 2f |nterpola|tion..4/|
|00001580| 32 33 2f 39 30 09 64 67 | 70 09 41 64 64 65 64 20 |23/90.dg|p.Added |
|00001590| 61 20 66 65 77 20 6c 69 | 6e 65 73 20 6f 66 20 63 |a few li|nes of c|
|000015a0| 6f 64 65 20 74 6f 20 4c | 54 6f 56 28 29 20 74 6f |ode to L|ToV() to|
|000015b0| 20 63 68 65 63 6b 20 6e | 65 61 72 20 74 68 65 20 | check n|ear the |
|000015c0| 6c 61 73 74 20 69 6e 64 | 65 78 2c 20 69 6e 20 74 |last ind|ex, in t|
|000015d0| 68 65 0d 09 09 09 73 70 | 69 72 69 74 20 6f 66 20 |he....sp|irit of |
|000015e0| 4e 75 6d 65 72 69 63 61 | 6c 20 52 65 63 69 70 65 |Numerica|l Recipe|
|000015f0| 73 20 69 6e 20 43 2c 20 | 68 75 6e 74 2e 63 2c 20 |s in C, |hunt.c, |
|00001600| 62 65 66 6f 72 65 20 73 | 74 61 72 74 69 6e 67 20 |before s|tarting |
|00001610| 74 68 65 20 62 69 73 65 | 63 74 69 6f 6e 0d 09 09 |the bise|ction...|
|00001620| 09 73 65 61 72 63 68 2e | 20 49 20 75 70 64 61 74 |.search.| I updat|
|00001630| 65 64 20 74 68 65 20 74 | 69 6d 65 73 20 69 6e 20 |ed the t|imes in |
|00001640| 74 68 65 20 34 2f 32 32 | 2f 39 30 20 6e 6f 74 65 |the 4/22|/90 note|
|00001650| 20 74 6f 20 72 65 66 6c | 65 63 74 20 74 68 65 20 | to refl|ect the |
|00001660| 6c 61 74 65 73 74 20 74 | 69 6d 69 6e 67 0d 09 09 |latest t|iming...|
|00001670| 09 62 79 20 54 65 73 74 | 4c 75 6d 69 6e 61 6e 63 |.by Test|Luminanc|
|00001680| 65 2e 0d 37 2f 32 37 2f | 39 30 09 64 67 70 09 54 |e..7/27/|90.dgp.T|
|00001690| 69 67 68 74 65 6e 65 64 | 20 75 70 20 74 68 65 20 |ightened| up the |
|000016a0| 65 72 72 6f 72 20 63 68 | 65 63 6b 69 6e 67 20 66 |error ch|ecking f|
|000016b0| 6f 72 20 69 6c 6c 65 67 | 61 6c 20 65 6e 74 72 69 |or illeg|al entri|
|000016c0| 65 73 20 69 6e 74 6f 20 | 74 68 65 20 63 6c 75 74 |es into |the clut|
|000016d0| 2e 20 49 20 68 61 76 65 | 0d 09 09 09 74 68 65 20 |. I have|....the |
|000016e0| 69 6d 70 72 65 73 73 69 | 6f 6e 20 74 68 61 74 2c |impressi|on that,|
|000016f0| 20 63 6f 6e 74 72 61 72 | 79 20 74 6f 20 73 70 65 | contrar|y to spe|
|00001700| 63 69 66 69 63 61 74 69 | 6f 6e 2c 20 74 68 65 20 |cificati|on, the |
|00001710| 41 70 70 6c 65 20 76 69 | 64 65 6f 20 64 72 69 76 |Apple vi|deo driv|
|00001720| 65 72 0d 09 09 09 63 72 | 61 73 68 65 73 20 61 6e |er....cr|ashes an|
|00001730| 64 20 63 6f 72 72 75 70 | 74 73 20 69 74 73 65 6c |d corrup|ts itsel|
|00001740| 66 20 69 66 20 67 69 76 | 65 6e 20 61 6e 20 6f 75 |f if giv|en an ou|
|00001750| 74 2d 6f 66 2d 72 61 6e | 67 65 20 65 6e 74 72 79 |t-of-ran|ge entry|
|00001760| 20 76 61 6c 75 65 20 69 | 6e 20 61 0d 09 09 09 73 | value i|n a....s|
|00001770| 65 74 45 6e 74 72 79 20 | 43 6f 6e 74 72 6f 6c 20 |etEntry |Control |
|00001780| 63 61 6c 6c 2e 0d 39 2f | 31 38 2f 39 30 09 64 67 |call..9/|18/90.dg|
|00001790| 70 09 43 68 61 6e 67 65 | 64 20 61 6c 6c 20 69 6e |p.Change|d all in|
|000017a0| 73 74 61 6e 63 65 73 20 | 6f 66 20 22 76 22 20 74 |stances |of "v" t|
|000017b0| 6f 20 22 56 22 2e 20 54 | 68 65 20 66 69 6e 61 6c |o "V". T|he final|
|000017c0| 20 76 65 72 73 69 6f 6e | 20 6f 66 20 74 68 65 20 | version| of the |
|000017d0| 50 65 6c 6c 69 0d 09 09 | 09 26 20 5a 68 61 6e 67 |Pelli...|.& Zhang|
|000017e0| 20 28 31 39 39 31 29 20 | 70 61 70 65 72 20 72 65 | (1991) |paper re|
|000017f0| 66 65 72 73 20 74 6f 20 | 74 68 65 20 6e 6f 6d 69 |fers to |the nomi|
|00001800| 6e 61 6c 20 76 6f 6c 74 | 61 67 65 20 76 3b 20 74 |nal volt|age v; t|
|00001810| 68 69 73 20 66 69 6c 65 | 0d 09 09 09 6e 6f 77 20 |his file|....now |
|00001820| 72 65 66 65 72 73 20 74 | 6f 20 74 68 65 20 22 65 |refers t|o the "e|
|00001830| 71 75 69 76 61 6c 65 6e | 74 20 6e 75 6d 62 65 72 |quivalen|t number|
|00001840| 22 20 56 3b 20 74 68 65 | 79 20 61 72 65 20 72 65 |" V; the|y are re|
|00001850| 6c 61 74 65 64 20 62 79 | 20 56 3d 32 35 35 2a 76 |lated by| V=255*v|
|00001860| 2e 0d 39 2f 32 34 2f 39 | 30 09 64 67 70 09 55 70 |..9/24/9|0.dgp.Up|
|00001870| 64 61 74 65 64 20 74 68 | 65 20 64 6f 63 75 6d 65 |dated th|e docume|
|00001880| 6e 74 61 74 69 6f 6e 20 | 74 6f 20 63 6f 72 72 65 |ntation |to corre|
|00001890| 73 70 6f 6e 64 20 6d 6f | 72 65 20 63 6c 6f 73 65 |spond mo|re close|
|000018a0| 6c 79 20 74 6f 20 74 68 | 65 20 28 68 6f 70 65 66 |ly to th|e (hopef|
|000018b0| 75 6c 6c 79 29 0d 09 09 | 09 66 69 6e 61 6c 20 76 |ully)...|.final v|
|000018c0| 65 72 73 69 6f 6e 20 6f | 66 20 74 68 65 20 50 65 |ersion o|f the Pe|
|000018d0| 6c 6c 69 20 26 20 5a 68 | 61 6e 67 20 28 31 39 39 |lli & Zh|ang (199|
|000018e0| 31 29 20 70 61 70 65 72 | 2e 0d 31 30 2f 32 39 2f |1) paper|..10/29/|
|000018f0| 39 30 20 64 67 70 20 44 | 6f 75 62 6c 65 64 20 73 |90 dgp D|oubled s|
|00001900| 70 65 65 64 20 6f 66 20 | 53 65 74 4c 75 6d 69 6e |peed of |SetLumin|
|00001910| 61 6e 63 65 28 29 2e 20 | 4e 6f 77 20 53 65 74 4c |ance(). |Now SetL|
|00001920| 75 6d 69 6e 61 6e 63 65 | 28 29 20 74 61 6b 65 73 |uminance|() takes|
|00001930| 20 31 33 33 20 6d 73 20 | 74 6f 0d 09 09 09 64 6f | 133 ms |to....do|
|00001940| 20 61 20 63 6f 6d 70 6c | 65 74 65 20 63 6c 75 74 | a compl|ete clut|
|00001950| 20 66 6f 72 20 61 20 73 | 6d 61 6c 6c 20 6e 65 77 | for a s|mall new|
|00001960| 20 6c 75 6d 69 6e 61 6e | 63 65 20 72 61 6e 67 65 | luminan|ce range|
|00001970| 2c 20 61 6e 64 20 74 61 | 6b 65 73 20 31 38 38 20 |, and ta|kes 188 |
|00001980| 6d 73 20 66 6f 72 20 61 | 0d 09 09 09 6c 61 72 67 |ms for a|....larg|
|00001990| 65 20 6e 65 77 20 72 61 | 6e 67 65 2e 20 54 68 69 |e new ra|nge. Thi|
|000019a0| 73 20 72 65 71 75 69 72 | 65 64 20 6d 69 6e 6f 72 |s requir|ed minor|
|000019b0| 20 63 68 61 6e 67 65 73 | 20 74 6f 20 53 65 74 4c | changes| to SetL|
|000019c0| 75 6d 69 6e 61 6e 63 65 | 52 61 6e 67 65 28 29 20 |uminance|Range() |
|000019d0| 26 20 4c 54 6f 56 28 29 | 2e 0d 09 09 09 43 68 61 |& LToV()|.....Cha|
|000019e0| 6e 67 65 64 20 61 6c 6c | 20 66 75 6e 63 74 69 6f |nged all| functio|
|000019f0| 6e 20 68 65 61 64 65 72 | 73 20 74 6f 20 53 74 61 |n header|s to Sta|
|00001a00| 6e 64 61 72 64 20 43 20 | 70 72 6f 74 6f 74 79 70 |ndard C |prototyp|
|00001a10| 65 20 73 74 79 6c 65 2e | 0d 31 30 2f 33 30 2f 39 |e style.|.10/30/9|
|00001a20| 30 20 64 67 70 20 52 65 | 70 6c 61 63 65 64 20 70 |0 dgp Re|placed p|
|00001a30| 68 72 61 73 65 20 22 63 | 6c 75 74 20 76 61 6c 75 |hrase "c|lut valu|
|00001a40| 65 22 20 62 79 20 22 6e | 6f 6d 69 6e 61 6c 20 76 |e" by "n|ominal v|
|00001a50| 6f 6c 74 61 67 65 22 2c | 20 66 6f 72 20 63 6f 6e |oltage",| for con|
|00001a60| 73 69 73 74 65 6e 63 79 | 20 77 69 74 68 0d 09 09 |sistency| with...|
|00001a70| 09 50 65 6c 6c 69 20 26 | 20 5a 68 61 6e 67 20 28 |.Pelli &| Zhang (|
|00001a80| 31 39 39 31 29 2e 0d 09 | 09 09 49 6e 74 72 6f 64 |1991)...|..Introd|
|00001a90| 75 63 65 64 20 6e 65 77 | 20 66 69 78 65 64 20 66 |uced new| fixed f|
|00001aa0| 72 61 63 74 69 6f 6e 20 | 64 61 74 61 20 74 79 70 |raction |data typ|
|00001ab0| 65 20 63 61 6c 6c 65 64 | 20 22 4d 69 6c 6c 69 22 |e called| "Milli"|
|00001ac0| 2c 20 64 65 66 69 6e 65 | 64 20 69 6e 20 4d 69 6c |, define|d in Mil|
|00001ad0| 6c 69 2e 68 2e 0d 09 09 | 09 42 79 20 6a 75 64 69 |li.h....|.By judi|
|00001ae0| 63 69 6f 75 73 20 72 65 | 70 6c 61 63 65 6d 65 6e |cious re|placemen|
|00001af0| 74 20 6f 66 20 64 6f 75 | 62 6c 65 20 62 79 20 4d |t of dou|ble by M|
|00001b00| 69 6c 6c 69 2c 20 70 61 | 72 74 69 63 75 6c 61 72 |illi, pa|rticular|
|00001b10| 6c 79 20 69 6e 20 74 68 | 65 20 6c 75 6d 69 6e 61 |ly in th|e lumina|
|00001b20| 6e 63 65 0d 09 09 09 74 | 61 62 6c 65 2c 20 49 20 |nce....t|able, I |
|00001b30| 68 61 76 65 20 69 6e 63 | 72 65 61 73 65 64 20 74 |have inc|reased t|
|00001b40| 68 65 20 73 70 65 65 64 | 20 6f 66 20 53 65 74 4c |he speed| of SetL|
|00001b50| 75 6d 69 6e 61 6e 63 65 | 20 62 79 20 61 20 66 61 |uminance| by a fa|
|00001b60| 63 74 6f 72 20 6f 66 20 | 74 68 72 65 65 2e 0d 09 |ctor of |three...|
|00001b70| 09 09 41 20 4d 61 63 20 | 49 49 20 6e 6f 77 20 74 |..A Mac |II now t|
|00001b80| 61 6b 65 73 20 6f 6e 6c | 79 20 34 32 20 74 6f 20 |akes onl|y 42 to |
|00001b90| 35 30 20 6d 73 20 74 6f | 20 62 75 69 6c 64 20 61 |50 ms to| build a|
|00001ba0| 20 77 68 6f 6c 65 20 63 | 6c 75 74 2e 20 54 68 69 | whole c|lut. Thi|
|00001bb0| 73 20 6e 65 77 20 66 65 | 61 74 75 72 65 0d 09 09 |s new fe|ature...|
|00001bc0| 09 69 73 20 65 6e 61 62 | 6c 65 64 20 62 79 20 73 |.is enab|led by s|
|00001bd0| 65 74 74 69 6e 67 20 46 | 41 53 54 5f 4c 55 4d 49 |etting F|AST_LUMI|
|00001be0| 4e 41 4e 43 45 20 74 6f | 20 31 20 69 6e 20 4c 75 |NANCE to| 1 in Lu|
|00001bf0| 6d 69 6e 61 6e 63 65 2e | 68 2e 20 54 68 65 72 65 |minance.|h. There|
|00001c00| 20 69 73 20 61 20 73 6c | 69 67 68 74 0d 09 09 09 | is a sl|ight....|
|00001c10| 69 6e 63 72 65 61 73 65 | 20 69 6e 20 74 68 65 20 |increase| in the |
|00001c20| 6c 75 6d 69 6e 61 6e 63 | 65 20 74 6f 6c 65 72 61 |luminanc|e tolera|
|00001c30| 6e 63 65 2e 0d 31 30 2f | 33 31 2f 39 30 20 64 67 |nce..10/|31/90 dg|
|00001c40| 70 20 4d 6f 72 65 20 66 | 69 6e 65 20 74 75 6e 69 |p More f|ine tuni|
|00001c50| 6e 67 2e 20 4e 6f 77 20 | 74 61 6b 65 73 20 33 31 |ng. Now |takes 31|
|00001c60| 20 74 6f 20 34 34 20 6d | 73 20 74 6f 20 62 75 69 | to 44 m|s to bui|
|00001c70| 6c 64 20 61 20 77 68 6f | 6c 65 20 63 6c 75 74 2e |ld a who|le clut.|
|00001c80| 20 49 6e 74 72 6f 64 75 | 63 65 64 0d 09 09 09 63 | Introdu|ced....c|
|00001c90| 6f 6e 64 69 74 69 6f 6e | 61 6c 20 46 41 53 54 5f |ondition|al FAST_|
|00001ca0| 4c 55 4d 49 4e 41 4e 43 | 45 20 69 6e 20 4c 75 6d |LUMINANC|E in Lum|
|00001cb0| 69 6e 61 6e 63 65 2e 68 | 20 74 68 61 74 20 63 61 |inance.h| that ca|
|00001cc0| 75 73 65 73 20 74 68 65 | 20 73 61 6d 65 20 63 6f |uses the| same co|
|00001cd0| 64 65 20 74 6f 0d 09 09 | 09 62 65 20 63 6f 6d 70 |de to...|.be comp|
|00001ce0| 69 6c 65 64 20 77 69 74 | 68 20 65 69 74 68 65 72 |iled wit|h either|
|00001cf0| 20 4d 69 6c 6c 69 20 6f | 72 20 64 6f 75 62 6c 65 | Milli o|r double|
|00001d00| 20 76 61 72 69 61 62 6c | 65 73 2e 20 54 68 65 20 | variabl|es. The |
|00001d10| 5f 53 65 74 4c 75 6d 69 | 6e 61 6e 63 65 28 29 0d |_SetLumi|nance().|
|00001d20| 09 09 09 72 6f 75 74 69 | 6e 65 20 69 73 20 6e 6f |...routi|ne is no|
|00001d30| 77 20 71 75 69 74 65 20 | 70 6f 6c 69 73 68 65 64 |w quite |polished|
|00001d40| 2c 20 61 6e 64 20 72 75 | 6e 73 20 66 61 73 74 2e |, and ru|ns fast.|
|00001d50| 20 41 6c 6c 20 76 61 72 | 69 61 62 6c 65 73 20 61 | All var|iables a|
|00001d60| 6e 64 20 72 6f 75 74 69 | 6e 65 73 0d 09 09 09 77 |nd routi|nes....w|
|00001d70| 68 6f 73 65 20 6e 61 6d | 65 73 20 62 65 67 69 6e |hose nam|es begin|
|00001d80| 20 77 69 74 68 20 75 6e | 64 65 72 73 63 6f 72 65 | with un|derscore|
|00001d90| 20 5f 20 61 72 65 20 77 | 72 69 74 74 65 6e 20 68 | _ are w|ritten h|
|00001da0| 65 72 65 20 77 69 74 68 | 20 74 79 70 65 20 4d 69 |ere with| type Mi|
|00001db0| 6c 6c 69 2c 20 62 75 74 | 0d 09 09 09 69 66 20 46 |lli, but|....if F|
|00001dc0| 41 53 54 5f 4c 55 4d 49 | 4e 41 4e 43 45 20 69 73 |AST_LUMI|NANCE is|
|00001dd0| 20 66 61 6c 73 65 20 74 | 68 65 6e 20 74 68 69 73 | false t|hen this|
|00001de0| 20 74 79 70 65 20 69 73 | 20 72 65 64 65 66 69 6e | type is| redefin|
|00001df0| 65 64 20 28 69 6e 20 74 | 68 69 73 20 66 69 6c 65 |ed (in t|his file|
|00001e00| 20 6f 6e 6c 79 29 0d 09 | 09 09 61 73 20 64 6f 75 | only)..|..as dou|
|00001e10| 62 6c 65 2c 20 61 6e 64 | 20 61 6c 6c 20 74 68 65 |ble, and| all the|
|00001e20| 20 4d 69 6c 6c 69 20 6d | 61 63 72 6f 73 20 61 72 | Milli m|acros ar|
|00001e30| 65 20 72 65 64 65 66 69 | 6e 65 64 20 74 6f 20 62 |e redefi|ned to b|
|00001e40| 65 20 61 70 70 72 6f 70 | 72 69 61 74 65 20 66 6f |e approp|riate fo|
|00001e50| 72 0d 09 09 09 61 20 64 | 6f 75 62 6c 65 2e 20 53 |r....a d|ouble. S|
|00001e60| 6f 20 62 65 61 72 20 69 | 6e 20 6d 69 6e 64 20 74 |o bear i|n mind t|
|00001e70| 68 61 74 20 74 68 69 6e | 67 73 20 62 65 67 69 6e |hat thin|gs begin|
|00001e80| 6e 69 6e 67 20 77 69 74 | 68 20 75 6e 64 65 72 73 |ning wit|h unders|
|00001e90| 63 6f 72 65 20 61 72 65 | 20 6f 66 0d 09 09 09 75 |core are| of....u|
|00001ea0| 6e 6b 6e 6f 77 6e 20 74 | 79 70 65 2e 20 54 68 65 |nknown t|ype. The|
|00001eb0| 20 76 69 72 74 75 65 20 | 6f 66 20 62 65 69 6e 67 | virtue |of being|
|00001ec0| 20 61 62 6c 65 20 74 6f | 20 72 75 6e 20 74 68 65 | able to| run the|
|00001ed0| 20 73 61 6d 65 20 63 6f | 64 65 20 77 69 74 68 20 | same co|de with |
|00001ee0| 4d 69 6c 6c 69 20 6f 72 | 0d 09 09 09 64 6f 75 62 |Milli or|....doub|
|00001ef0| 6c 65 20 63 6f 6d 70 75 | 74 61 74 69 6f 6e 73 20 |le compu|tations |
|00001f00| 69 73 20 74 68 61 74 20 | 69 66 20 79 6f 75 20 73 |is that |if you s|
|00001f10| 75 73 70 65 63 74 20 61 | 6e 20 65 72 72 6f 72 20 |uspect a|n error |
|00001f20| 69 6e 20 74 68 65 20 28 | 68 6f 6d 65 6d 61 64 65 |in the (|homemade|
|00001f30| 29 0d 09 09 09 4d 69 6c | 6c 69 20 61 72 69 74 68 |)....Mil|li arith|
|00001f40| 6d 65 74 69 63 2c 20 79 | 6f 75 20 63 61 6e 20 74 |metic, y|ou can t|
|00001f50| 72 79 20 6f 75 74 20 64 | 6f 75 62 6c 65 20 61 72 |ry out d|ouble ar|
|00001f60| 69 74 68 6d 65 74 69 63 | 20 73 69 6d 70 6c 79 20 |ithmetic| simply |
|00001f70| 62 79 20 73 65 74 74 69 | 6e 67 0d 09 09 09 46 41 |by setti|ng....FA|
|00001f80| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 20 74 6f 20 |ST_LUMIN|ANCE to |
|00001f90| 30 20 61 6e 64 20 72 65 | 63 6f 6d 70 69 6c 69 6e |0 and re|compilin|
|00001fa0| 67 2e 0d 09 09 09 49 6e | 20 74 68 65 20 69 6e 74 |g.....In| the int|
|00001fb0| 65 72 65 73 74 20 6f 66 | 20 73 70 65 65 64 20 49 |erest of| speed I|
|00001fc0| 20 68 61 76 65 20 73 74 | 72 65 61 6d 6c 69 6e 65 | have st|reamline|
|00001fd0| 64 20 74 68 65 20 74 6f | 6c 65 72 61 6e 63 65 0d |d the to|lerance.|
|00001fe0| 09 09 09 63 6f 6d 70 75 | 74 61 74 69 6f 6e 2e 20 |...compu|tation. |
|00001ff0| 54 68 65 20 6e 65 77 20 | 74 6f 6c 65 72 61 6e 63 |The new |toleranc|
|00002000| 65 73 20 61 72 65 20 70 | 72 6f 62 61 62 6c 79 20 |es are p|robably |
|00002010| 61 73 20 67 6f 6f 64 20 | 61 73 20 74 68 65 20 6f |as good |as the o|
|00002020| 6c 64 20 6f 6e 65 73 2e | 0d 31 31 2f 32 2f 39 30 |ld ones.|.11/2/90|
|00002030| 20 64 67 70 20 41 64 64 | 65 64 20 5f 53 65 74 4c | dgp Add|ed _SetL|
|00002040| 75 6d 69 6e 61 6e 63 65 | 73 28 29 20 73 75 62 72 |uminance|s() subr|
|00002050| 6f 75 74 69 6e 65 20 74 | 68 61 74 20 73 75 62 73 |outine t|hat subs|
|00002060| 74 69 74 75 74 65 73 20 | 6c 69 6e 65 61 72 20 69 |titutes |linear i|
|00002070| 6e 74 65 72 70 6f 6c 61 | 74 69 6f 6e 0d 09 09 09 |nterpola|tion....|
|00002080| 66 6f 72 20 6d 6f 73 74 | 20 6f 66 20 74 68 65 20 |for most| of the |
|00002090| 63 61 6c 6c 73 20 74 6f | 20 5f 4c 54 6f 56 28 29 |calls to| _LToV()|
|000020a0| 2e 20 54 68 69 73 20 68 | 61 73 20 67 72 65 61 74 |. This h|as great|
|000020b0| 6c 79 20 73 70 65 65 64 | 65 64 20 75 70 0d 09 09 |ly speed|ed up...|
|000020c0| 09 53 65 74 4c 75 6d 69 | 6e 61 6e 63 65 73 41 6e |.SetLumi|nancesAn|
|000020d0| 64 52 61 6e 67 65 28 29 | 2c 20 77 69 74 68 20 6d |dRange()|, with m|
|000020e0| 69 6e 6f 72 20 6c 6f 73 | 73 20 6f 66 20 61 63 63 |inor los|s of acc|
|000020f0| 75 72 61 63 79 2e 20 41 | 20 63 6f 6d 70 6c 65 74 |uracy. A| complet|
|00002100| 65 20 63 6c 75 74 20 6e | 6f 77 0d 09 09 09 74 61 |e clut n|ow....ta|
|00002110| 6b 65 73 20 39 20 74 6f | 20 33 31 20 6d 73 2e 20 |kes 9 to| 31 ms. |
|00002120| 45 76 65 6e 20 61 20 4d | 61 63 20 49 49 20 63 61 |Even a M|ac II ca|
|00002130| 6e 20 6e 6f 77 20 63 6f | 6d 70 75 74 65 20 6c 6f |n now co|mpute lo|
|00002140| 77 2d 63 6f 6e 74 72 61 | 73 74 20 63 6c 75 74 73 |w-contra|st cluts|
|00002150| 0d 09 09 09 6f 6e 20 74 | 68 65 20 66 6c 79 2c 20 |....on t|he fly, |
|00002160| 62 65 74 77 65 65 6e 20 | 66 72 61 6d 65 73 2e 20 |between |frames. |
|00002170| 28 54 68 65 20 75 73 65 | 72 20 6d 61 79 20 77 69 |(The use|r may wi|
|00002180| 73 68 20 74 6f 20 6f 70 | 74 69 6d 69 7a 65 20 74 |sh to op|timize t|
|00002190| 68 65 20 73 70 65 65 64 | 2d 0d 09 09 09 61 63 63 |he speed|-....acc|
|000021a0| 75 72 61 63 79 20 74 72 | 61 64 65 2d 6f 66 66 20 |uracy tr|ade-off |
|000021b0| 63 6f 6e 74 72 6f 6c 6c | 65 64 20 62 79 20 74 68 |controll|ed by th|
|000021c0| 65 20 4c 49 4e 45 41 52 | 5f 56 5f 44 4f 4d 41 49 |e LINEAR|_V_DOMAI|
|000021d0| 4e 20 70 61 72 61 6d 65 | 74 65 72 2c 20 77 68 69 |N parame|ter, whi|
|000021e0| 63 68 0d 09 09 09 64 65 | 74 65 72 6d 69 6e 65 73 |ch....de|termines|
|000021f0| 20 74 68 65 20 6d 61 78 | 69 6d 75 6d 20 77 69 64 | the max|imum wid|
|00002200| 74 68 20 6f 66 20 74 68 | 65 20 69 6e 74 65 72 70 |th of th|e interp|
|00002210| 6f 6c 61 74 69 6f 6e 20 | 69 6e 74 65 72 76 61 6c |olation |interval|
|00002220| 2e 29 0d 31 31 2f 36 2f | 39 30 20 64 67 70 20 52 |.).11/6/|90 dgp R|
|00002230| 65 70 6c 61 63 65 64 20 | 4d 69 6c 6c 69 20 62 79 |eplaced |Milli by|
|00002240| 20 46 49 58 45 44 2c 20 | 77 68 69 63 68 20 63 61 | FIXED, |which ca|
|00002250| 6e 20 62 65 20 63 6f 6d | 70 69 6c 65 64 20 61 73 |n be com|piled as|
|00002260| 20 65 69 74 68 65 72 20 | 64 6f 75 62 6c 65 20 6f | either |double o|
|00002270| 72 20 46 69 78 65 64 2e | 0d 09 09 09 54 68 65 20 |r Fixed.|....The |
|00002280| 46 69 78 65 64 20 6d 61 | 74 68 20 69 73 20 73 75 |Fixed ma|th is su|
|00002290| 66 66 69 63 69 65 6e 74 | 6c 79 20 70 72 65 63 69 |fficient|ly preci|
|000022a0| 73 65 20 61 73 20 74 6f | 20 67 69 76 65 20 74 68 |se as to| give th|
|000022b0| 65 20 73 61 6d 65 20 44 | 41 43 20 76 61 6c 75 65 |e same D|AC value|
|000022c0| 73 20 61 73 0d 09 09 09 | 64 6f 75 62 6c 65 20 6d |s as....|double m|
|000022d0| 61 74 68 2e 0d 09 09 09 | 4e 6f 77 20 66 69 67 75 |ath.....|Now figu|
|000022e0| 72 65 20 6f 75 74 20 6f | 70 74 69 6d 61 6c 20 62 |re out o|ptimal b|
|000022f0| 69 74 20 73 68 69 66 74 | 20 4c 54 2d 3e 4c 2e 4c |it shift| LT->L.L|
|00002300| 53 68 69 66 74 20 74 6f | 20 70 72 65 73 65 72 76 |Shift to| preserv|
|00002310| 65 20 61 73 20 6d 75 63 | 68 20 72 65 73 6f 6c 75 |e as muc|h resolu|
|00002320| 74 69 6f 6e 0d 09 09 09 | 61 73 20 70 6f 73 73 69 |tion....|as possi|
|00002330| 62 6c 65 20 77 68 65 6e | 20 69 6e 74 65 72 70 6f |ble when| interpo|
|00002340| 6c 61 74 69 6e 67 20 69 | 6e 20 5f 4c 54 6f 56 28 |lating i|n _LToV(|
|00002350| 29 2e 20 0d 09 09 09 41 | 20 63 6f 6d 70 6c 65 74 |). ....A| complet|
|00002360| 65 20 63 6c 75 74 20 6e | 6f 77 20 74 61 6b 65 73 |e clut n|ow takes|
|00002370| 20 38 20 74 6f 20 33 30 | 20 6d 73 2e 20 46 6f 72 | 8 to 30| ms. For|
|00002380| 20 74 68 72 65 73 68 6f | 6c 64 20 73 74 69 6d 75 | thresho|ld stimu|
|00002390| 6c 69 20 74 68 65 20 61 | 76 65 72 61 67 65 0d 09 |li the a|verage..|
|000023a0| 09 09 74 69 6d 65 20 77 | 69 6c 6c 20 75 73 75 61 |..time w|ill usua|
|000023b0| 6c 6c 79 20 62 65 20 6c | 65 73 73 20 74 68 61 6e |lly be l|ess than|
|000023c0| 20 31 35 20 6d 73 2e 0d | 31 31 2f 38 2f 39 30 20 | 15 ms..|11/8/90 |
|000023d0| 64 67 70 09 45 6c 69 6d | 69 6e 61 74 65 64 20 67 |dgp.Elim|inated g|
|000023e0| 61 6d 6d 61 20 73 6c 6f | 70 65 20 74 61 62 6c 65 |amma slo|pe table|
|000023f0| 20 73 69 6e 63 65 20 74 | 68 65 20 73 70 65 65 64 | since t|he speed|
|00002400| 2d 75 70 20 69 74 20 6f | 66 66 65 72 65 64 20 77 |-up it o|ffered w|
|00002410| 61 73 20 74 6f 6f 20 73 | 6d 61 6c 6c 0d 09 09 09 |as too s|mall....|
|00002420| 74 6f 20 6d 65 61 73 75 | 72 65 2e 20 54 69 64 69 |to measu|re. Tidi|
|00002430| 65 64 20 75 70 20 74 68 | 65 20 63 6f 6d 70 75 74 |ed up th|e comput|
|00002440| 61 74 69 6f 6e 20 6f 66 | 20 4c 53 68 69 66 74 2e |ation of| LShift.|
|00002450| 0d 38 2f 32 34 2f 39 31 | 09 64 67 70 09 4d 61 64 |.8/24/91|.dgp.Mad|
|00002460| 65 20 63 6f 6d 70 61 74 | 69 62 6c 65 20 77 69 74 |e compat|ible wit|
|00002470| 68 20 54 48 49 4e 4b 20 | 43 20 35 2e 30 2e 0d 31 |h THINK |C 5.0..1|
|00002480| 32 2f 31 37 2f 39 31 20 | 64 67 70 20 41 64 64 65 |2/17/91 |dgp Adde|
|00002490| 64 20 6e 65 77 20 72 6f | 75 74 69 6e 65 73 3a 20 |d new ro|utines: |
|000024a0| 49 6e 63 72 65 6d 65 6e | 74 4c 75 6d 69 6e 61 6e |Incremen|tLuminan|
|000024b0| 63 65 28 29 20 61 6e 64 | 20 47 65 74 56 28 29 2e |ce() and| GetV().|
|000024c0| 0d 09 09 09 54 68 65 20 | 66 6f 72 6d 65 72 20 69 |....The |former i|
|000024d0| 73 20 75 73 65 64 20 74 | 6f 20 6f 62 74 61 69 6e |s used t|o obtain|
|000024e0| 20 74 68 65 20 6c 6f 77 | 65 73 74 20 70 6f 73 73 | the low|est poss|
|000024f0| 69 62 6c 65 20 63 6f 6e | 74 72 61 73 74 2e 20 4f |ible con|trast. O|
|00002500| 6e 20 61 20 6c 6f 67 20 | 63 6f 6e 74 72 61 73 74 |n a log |contrast|
|00002510| 0d 09 09 09 73 63 61 6c | 65 2c 20 6d 69 6e 75 73 |....scal|e, minus|
|00002520| 20 69 6e 66 69 6e 69 74 | 79 20 28 7a 65 72 6f 20 | infinit|y (zero |
|00002530| 63 6f 6e 74 72 61 73 74 | 29 20 69 73 20 61 20 70 |contrast|) is a p|
|00002540| 6f 6f 72 20 61 70 70 72 | 6f 78 69 6d 61 74 69 6f |oor appr|oximatio|
|00002550| 6e 20 74 6f 20 65 76 65 | 6e 0d 09 09 09 61 20 73 |n to eve|n....a s|
|00002560| 6d 61 6c 6c 20 6c 6f 67 | 20 63 6f 6e 74 72 61 73 |mall log| contras|
|00002570| 74 2e 0d 33 2f 31 31 2f | 39 32 09 64 67 70 09 4d |t..3/11/|92.dgp.M|
|00002580| 69 6e 6f 72 20 65 64 69 | 74 69 6e 67 20 6f 66 20 |inor edi|ting of |
|00002590| 63 6f 6d 6d 65 6e 74 73 | 2e 0d 31 32 2f 32 2f 39 |comments|..12/2/9|
|000025a0| 32 20 64 67 70 20 46 69 | 78 65 64 20 6d 69 6e 6f |2 dgp Fi|xed mino|
|000025b0| 72 20 62 75 67 20 69 6e | 20 53 65 74 4c 75 6d 69 |r bug in| SetLumi|
|000025c0| 6e 61 6e 63 65 52 61 6e | 67 65 28 29 20 72 65 70 |nanceRan|ge() rep|
|000025d0| 6f 72 74 65 64 20 62 79 | 20 57 65 69 20 58 69 65 |orted by| Wei Xie|
|000025e0| 20 61 6e 64 20 4b 65 6e | 20 41 6c 65 78 61 6e 64 | and Ken| Alexand|
|000025f0| 65 72 0d 09 09 09 74 68 | 61 74 20 63 6f 75 6c 64 |er....th|at could|
|00002600| 20 63 61 75 73 65 20 74 | 68 65 20 54 48 49 4e 4b | cause t|he THINK|
|00002610| 20 43 20 44 65 62 75 67 | 67 65 72 20 74 6f 20 72 | C Debug|ger to r|
|00002620| 65 70 6f 72 74 20 61 6e | 20 65 72 72 6f 72 20 77 |eport an| error w|
|00002630| 68 65 6e 20 61 6e 20 0d | 09 09 09 75 6e 69 6e 69 |hen an .|...unini|
|00002640| 74 69 61 6c 69 7a 65 64 | 20 64 6f 75 62 6c 65 20 |tialized| double |
|00002650| 56 5b 5d 20 77 61 73 20 | 63 6f 6e 76 65 72 74 65 |V[] was |converte|
|00002660| 64 20 74 6f 20 61 6e 20 | 69 6e 74 2e 20 54 68 65 |d to an |int. The|
|00002670| 20 76 61 6c 75 65 20 77 | 61 73 20 6e 6f 74 20 75 | value w|as not u|
|00002680| 73 65 64 20 0d 09 09 09 | 66 6f 72 20 61 6e 79 74 |sed ....|for anyt|
|00002690| 68 69 6e 67 2c 20 73 6f | 20 74 68 69 73 20 77 61 |hing, so| this wa|
|000026a0| 73 20 69 6e 6e 6f 63 75 | 6f 75 73 2e 0d 31 32 2f |s innocu|ous..12/|
|000026b0| 31 37 2f 39 32 20 64 67 | 70 20 31 2e 39 34 20 42 |17/92 dg|p 1.94 B|
|000026c0| 65 67 61 6e 20 65 6e 68 | 61 6e 63 65 6d 65 6e 74 |egan enh|ancement|
|000026d0| 20 74 6f 20 61 6c 6c 6f | 77 20 61 6e 79 20 64 61 | to allo|w any da|
|000026e0| 63 53 69 7a 65 2c 20 6e | 6f 74 20 6a 75 73 74 20 |cSize, n|ot just |
|000026f0| 38 2d 62 69 74 20 64 61 | 63 73 2e 20 49 20 68 61 |8-bit da|cs. I ha|
|00002700| 76 65 0d 09 09 09 63 6f | 6e 66 69 72 6d 65 64 20 |ve....co|nfirmed |
|00002710| 74 68 61 74 20 65 76 65 | 72 79 74 68 69 6e 67 20 |that eve|rything |
|00002720| 73 74 69 6c 6c 20 77 6f | 72 6b 73 20 66 69 6e 65 |still wo|rks fine|
|00002730| 20 77 69 74 68 20 38 2d | 62 69 74 20 64 61 63 73 | with 8-|bit dacs|
|00002740| 2c 20 62 75 74 20 49 20 | 64 6f 6e 27 74 0d 09 09 |, but I |don't...|
|00002750| 09 68 61 76 65 20 61 20 | 39 2d 62 69 74 20 64 61 |.have a |9-bit da|
|00002760| 63 20 76 69 64 65 6f 20 | 63 61 72 64 20 74 6f 20 |c video |card to |
|00002770| 74 65 73 74 20 69 74 20 | 61 6e 79 20 66 75 72 74 |test it |any furt|
|00002780| 68 65 72 2e 20 a5 43 41 | 55 54 49 4f 4e 3a 20 74 |her. .CA|UTION: t|
|00002790| 68 69 73 20 70 72 6f 62 | 61 62 6c 79 0d 09 09 09 |his prob|ably....|
|000027a0| 64 6f 65 73 20 6e 6f 74 | 20 79 65 74 20 77 6f 72 |does not| yet wor|
|000027b0| 6b 20 63 6f 72 72 65 63 | 74 6c 79 20 66 6f 72 20 |k correc|tly for |
|000027c0| 39 2d 62 69 74 20 64 61 | 63 73 2e 20 45 2e 67 2e |9-bit da|cs. E.g.|
|000027d0| 20 69 74 20 73 65 65 6d | 73 20 6c 69 6b 65 6c 79 | it seem|s likely|
|000027e0| 20 74 68 61 74 20 74 68 | 65 20 0d 09 09 09 66 69 | that th|e ....fi|
|000027f0| 78 65 64 20 70 6f 69 6e | 74 20 6d 61 74 68 20 77 |xed poin|t math w|
|00002800| 69 6c 6c 20 62 72 65 61 | 6b 20 69 66 20 56 4d 61 |ill brea|k if VMa|
|00002810| 78 20 69 73 20 69 6e 63 | 72 65 61 73 65 64 20 74 |x is inc|reased t|
|00002820| 6f 20 35 31 31 3b 20 61 | 20 6c 6f 74 20 6f 66 20 |o 511; a| lot of |
|00002830| 63 61 72 65 66 75 6c 20 | 0d 09 09 09 65 72 72 6f |careful |....erro|
|00002840| 72 20 61 6e 61 6c 79 73 | 69 73 20 77 65 6e 74 20 |r analys|is went |
|00002850| 69 6e 74 6f 20 74 68 65 | 20 6f 72 69 67 69 6e 61 |into the| origina|
|00002860| 6c 20 63 6f 64 69 6e 67 | 2c 20 61 74 20 77 68 69 |l coding|, at whi|
|00002870| 63 68 20 74 69 6d 65 20 | 49 20 74 68 6f 75 67 68 |ch time |I though|
|00002880| 74 20 74 68 61 74 20 0d | 09 09 09 69 74 20 77 61 |t that .|...it wa|
|00002890| 73 20 73 61 66 65 20 74 | 6f 20 61 73 73 75 6d 65 |s safe t|o assume|
|000028a0| 20 61 6e 20 38 2d 62 69 | 74 20 64 61 63 20 28 69 | an 8-bi|t dac (i|
|000028b0| 2e 65 2e 20 56 4d 61 78 | 3d 3d 32 35 35 29 2e 20 |.e. VMax|==255). |
|000028c0| a5 52 65 6d 6f 76 65 64 | 20 6f 62 73 6f 6c 65 74 |.Removed| obsolet|
|000028d0| 65 20 0d 09 09 09 73 75 | 70 70 6f 72 74 20 66 6f |e ....su|pport fo|
|000028e0| 72 20 54 48 49 4e 4b 20 | 43 20 34 2e 20 0d 31 32 |r THINK |C 4. .12|
|000028f0| 2f 32 31 2f 39 32 20 64 | 67 70 20 4e 6f 20 6c 6f |/21/92 d|gp No lo|
|00002900| 6e 67 65 72 20 6c 6f 61 | 64 20 75 6e 75 73 65 64 |nger loa|d unused|
|00002910| 20 64 61 63 20 62 69 74 | 73 2e 0d 31 2f 34 2f 39 | dac bit|s..1/4/9|
|00002920| 33 09 64 67 70 09 4c 6f | 61 64 4c 75 6d 69 6e 61 |3.dgp.Lo|adLumina|
|00002930| 6e 63 65 73 20 6e 6f 77 | 20 63 68 65 63 6b 73 20 |nces now| checks |
|00002940| 74 68 65 20 67 64 54 79 | 70 65 2e 0d 35 2f 31 30 |the gdTy|pe..5/10|
|00002950| 2f 39 33 09 64 67 70 09 | 49 66 20 64 72 69 76 65 |/93.dgp.|If drive|
|00002960| 72 20 69 73 20 69 6e 20 | 67 72 61 79 20 6d 6f 64 |r is in |gray mod|
|00002970| 65 20 28 69 2e 65 2e 20 | 6e 6f 74 20 63 6f 6c 6f |e (i.e. |not colo|
|00002980| 72 29 20 74 68 65 6e 20 | 4c 6f 61 64 4c 75 6d 69 |r) then |LoadLumi|
|00002990| 6e 61 6e 63 65 73 20 6d | 61 70 73 20 72 67 62 20 |nances m|aps rgb |
|000029a0| 74 6f 20 0d 09 09 09 67 | 72 61 79 20 62 79 20 73 |to ....g|ray by s|
|000029b0| 69 6d 70 6c 79 20 63 6f | 70 79 69 6e 67 20 74 68 |imply co|pying th|
|000029c0| 65 20 67 72 65 65 6e 20 | 63 6f 6d 70 6f 6e 65 6e |e green |componen|
|000029d0| 74 20 74 6f 20 74 68 65 | 20 72 65 64 20 61 6e 64 |t to the| red and|
|000029e0| 20 62 6c 75 65 20 63 6f | 6d 70 6f 6e 65 6e 74 73 | blue co|mponents|
|000029f0| 2e 0d 35 2f 31 32 2f 39 | 33 09 64 67 70 20 72 65 |..5/12/9|3.dgp re|
|00002a00| 6d 6f 76 65 64 20 64 65 | 62 75 67 67 69 6e 67 20 |moved de|bugging |
|00002a10| 63 6f 64 65 20 74 68 61 | 74 20 66 6f 72 63 65 64 |code tha|t forced|
|00002a20| 20 69 73 47 72 61 79 20 | 74 6f 20 61 6c 77 61 79 | isGray |to alway|
|00002a30| 73 20 62 65 20 74 72 75 | 65 2e 0d 33 2f 32 34 2f |s be tru|e..3/24/|
|00002a40| 39 34 09 64 67 70 09 61 | 64 64 65 64 20 4c 54 6f |94.dgp.a|dded LTo|
|00002a50| 45 2c 20 4c 54 6f 45 4f | 72 64 65 72 65 64 2c 20 |E, LToEO|rdered, |
|00002a60| 61 6e 64 20 45 54 6f 4c | 2e 0d 36 2f 32 39 2f 39 |and EToL|..6/29/9|
|00002a70| 34 20 64 67 70 20 72 65 | 6e 61 6d 65 64 20 22 4c |4 dgp re|named "L|
|00002a80| 74 6f 45 4f 72 64 65 72 | 65 64 22 20 74 6f 20 22 |toEOrder|ed" to "|
|00002a90| 4c 54 6f 45 4f 72 64 65 | 72 65 64 22 2c 20 66 69 |LToEOrde|red", fi|
|00002aa0| 78 69 6e 67 20 65 72 72 | 6f 6e 65 6f 75 73 20 63 |xing err|oneous c|
|00002ab0| 61 70 69 74 61 6c 69 7a | 61 74 69 6f 6e 2e 0d 39 |apitaliz|ation..9|
|00002ac0| 2f 32 38 2f 39 34 09 64 | 67 70 09 49 66 20 6e 65 |/28/94.d|gp.If ne|
|00002ad0| 63 65 73 73 61 72 79 2c | 20 49 6e 63 72 65 6d 65 |cessary,| Increme|
|00002ae0| 6e 74 4c 75 6d 69 6e 61 | 6e 63 65 20 6e 6f 77 20 |ntLumina|nce now |
|00002af0| 62 75 6d 70 73 20 75 70 | 20 74 68 65 20 75 70 70 |bumps up| the upp|
|00002b00| 65 72 20 6c 75 6d 69 6e | 61 6e 63 65 20 62 6f 75 |er lumin|ance bou|
|00002b10| 6e 64 20 74 6f 20 0d 09 | 09 09 69 6e 63 6c 75 64 |nd to ..|..includ|
|00002b20| 65 20 74 68 65 20 69 6e | 63 72 65 6d 65 6e 74 65 |e the in|cremente|
|00002b30| 64 20 6c 75 6d 69 6e 61 | 6e 63 65 2e 0d 31 30 2f |d lumina|nce..10/|
|00002b40| 32 35 2f 39 34 20 64 67 | 70 20 4c 6f 61 64 4c 75 |25/94 dg|p LoadLu|
|00002b50| 6d 69 6e 61 6e 63 65 20 | 61 6e 64 20 47 65 74 56 |minance |and GetV|
|00002b60| 20 6e 6f 77 20 69 67 6e | 6f 72 65 20 61 20 64 65 | now ign|ore a de|
|00002b70| 76 69 63 65 20 77 69 74 | 68 20 6e 6f 20 64 72 69 |vice wit|h no dri|
|00002b80| 76 65 72 2e 20 28 45 2e | 67 2e 20 61 20 64 65 76 |ver. (E.|g. a dev|
|00002b90| 69 63 65 0d 09 09 09 63 | 72 65 61 74 65 64 20 62 |ice....c|reated b|
|00002ba0| 79 20 4e 65 77 47 57 6f | 72 6c 64 2e 29 0d 31 32 |y NewGWo|rld.).12|
|00002bb0| 2f 32 39 2f 39 34 20 64 | 67 70 20 46 69 78 65 64 |/29/94 d|gp Fixed|
|00002bc0| 20 7a 65 72 6f 2d 64 69 | 76 69 64 65 20 68 61 6c | zero-di|vide hal|
|00002bd0| 74 20 69 6e 20 63 6f 6d | 70 75 74 69 6e 67 20 46 |t in com|puting F|
|00002be0| 41 53 54 5f 4c 55 4d 49 | 4e 41 4e 43 45 20 5f 4c |AST_LUMI|NANCE _L|
|00002bf0| 54 6f 56 20 72 65 74 75 | 72 6e 65 64 20 76 61 6c |ToV retu|rned val|
|00002c00| 75 65 2c 0d 09 09 09 72 | 65 70 6f 72 74 65 64 20 |ue,....r|eported |
|00002c10| 62 79 20 4a 6f 73 68 20 | 53 6f 6c 6f 6d 6f 6e 2e |by Josh |Solomon.|
|00002c20| 20 49 6e 63 72 65 61 73 | 65 64 20 4a 4d 41 58 20 | Increas|ed JMAX |
|00002c30| 66 72 6f 6d 20 32 30 20 | 74 6f 20 33 30 20 74 6f |from 20 |to 30 to|
|00002c40| 20 65 6c 69 6d 69 6e 61 | 74 65 20 73 70 75 72 69 | elimina|te spuri|
|00002c50| 6f 75 73 0d 09 09 09 77 | 61 72 6e 69 6e 67 20 69 |ous....w|arning i|
|00002c60| 6e 20 4c 54 6f 56 50 6f | 6c 79 6e 6f 6d 69 61 6c |n LToVPo|lynomial|
|00002c70| 2e 0d 33 2f 35 2f 39 36 | 20 64 67 70 20 46 69 78 |..3/5/96| dgp Fix|
|00002c80| 65 64 20 65 72 72 6f 72 | 20 69 6e 20 47 65 74 56 |ed error| in GetV|
|00002c90| 28 29 2c 20 77 68 69 63 | 68 20 63 61 6c 6c 65 64 |(), whic|h called|
|00002ca0| 20 47 44 47 65 74 45 6e | 74 72 69 65 73 28 29 20 | GDGetEn|tries() |
|00002cb0| 69 6e 63 6f 72 72 65 63 | 74 6c 79 2e 0d 2a 2f 0d |incorrec|tly..*/.|
|00002cc0| 23 69 6e 63 6c 75 64 65 | 20 22 56 69 64 65 6f 54 |#include| "VideoT|
|00002cd0| 6f 6f 6c 62 6f 78 2e 68 | 22 09 09 2f 2a 20 70 72 |oolbox.h|"../* pr|
|00002ce0| 6f 74 6f 74 79 70 65 20 | 66 6f 72 20 47 44 53 65 |ototype |for GDSe|
|00002cf0| 74 45 6e 74 72 69 65 73 | 28 29 20 2a 2f 0d 23 69 |tEntries|() */.#i|
|00002d00| 6e 63 6c 75 64 65 20 22 | 4c 75 6d 69 6e 61 6e 63 |nclude "|Luminanc|
|00002d10| 65 2e 68 22 0d 73 74 61 | 74 69 63 20 76 6f 69 64 |e.h".sta|tic void|
|00002d20| 20 53 6f 72 74 28 69 6e | 74 20 6e 2c 64 6f 75 62 | Sort(in|t n,doub|
|00002d30| 6c 65 20 61 72 72 5b 5d | 2c 69 6e 74 20 6b 72 72 |le arr[]|,int krr|
|00002d40| 5b 5d 29 3b 09 2f 2a 20 | 66 6f 72 20 69 6e 74 65 |[]);./* |for inte|
|00002d50| 72 6e 61 6c 20 75 73 65 | 20 6f 6e 6c 79 20 2a 2f |rnal use| only */|
|00002d60| 0d 0d 23 75 6e 64 65 66 | 20 4c 6f 6e 67 54 6f 46 |..#undef| LongToF|
|00002d70| 69 78 0d 23 75 6e 64 65 | 66 20 46 69 78 54 6f 4c |ix.#unde|f FixToL|
|00002d80| 6f 6e 67 0d 23 75 6e 64 | 65 66 20 44 6f 75 62 6c |ong.#und|ef Doubl|
|00002d90| 65 54 6f 46 69 78 0d 23 | 75 6e 64 65 66 20 46 69 |eToFix.#|undef Fi|
|00002da0| 78 54 6f 44 6f 75 62 6c | 65 0d 23 69 66 20 46 41 |xToDoubl|e.#if FA|
|00002db0| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 0d 09 23 64 |ST_LUMIN|ANCE..#d|
|00002dc0| 65 66 69 6e 65 20 46 49 | 58 45 44 20 46 69 78 65 |efine FI|XED Fixe|
|00002dd0| 64 0d 09 23 69 66 20 21 | 4d 41 43 49 4e 54 4f 53 |d..#if !|MACINTOS|
|00002de0| 48 0d 09 09 74 79 70 65 | 64 65 66 20 6c 6f 6e 67 |H...type|def long|
|00002df0| 20 46 69 78 65 64 3b 0d | 09 09 23 64 65 66 69 6e | Fixed;.|..#defin|
|00002e00| 65 20 46 69 78 4d 75 6c | 28 78 2c 79 29 20 44 6f |e FixMul|(x,y) Do|
|00002e10| 75 62 6c 65 54 6f 46 69 | 78 28 46 69 78 54 6f 44 |ubleToFi|x(FixToD|
|00002e20| 6f 75 62 6c 65 28 78 29 | 2a 46 69 78 54 6f 44 6f |ouble(x)|*FixToDo|
|00002e30| 75 62 6c 65 28 79 29 29 | 0d 09 09 23 64 65 66 69 |uble(y))|...#defi|
|00002e40| 6e 65 20 46 69 78 44 69 | 76 28 78 2c 79 29 20 44 |ne FixDi|v(x,y) D|
|00002e50| 6f 75 62 6c 65 54 6f 46 | 69 78 28 46 69 78 54 6f |oubleToF|ix(FixTo|
|00002e60| 44 6f 75 62 6c 65 28 78 | 29 2f 46 69 78 54 6f 44 |Double(x|)/FixToD|
|00002e70| 6f 75 62 6c 65 28 79 29 | 29 0d 09 23 65 6e 64 69 |ouble(y)|)..#endi|
|00002e80| 66 0d 09 23 64 65 66 69 | 6e 65 20 4c 6f 6e 67 54 |f..#defi|ne LongT|
|00002e90| 6f 46 69 78 28 78 29 20 | 28 28 6c 6f 6e 67 29 28 |oFix(x) |((long)(|
|00002ea0| 78 29 3c 3c 31 36 29 0d | 09 23 64 65 66 69 6e 65 |x)<<16).|.#define|
|00002eb0| 20 46 69 78 54 6f 4c 6f | 6e 67 28 78 29 20 28 28 | FixToLo|ng(x) ((|
|00002ec0| 78 29 3e 3e 31 36 29 0d | 09 23 64 65 66 69 6e 65 |x)>>16).|.#define|
|00002ed0| 20 44 6f 75 62 6c 65 54 | 6f 46 69 78 28 78 29 20 | DoubleT|oFix(x) |
|00002ee0| 28 28 46 69 78 65 64 29 | 28 28 78 29 2a 36 35 35 |((Fixed)|((x)*655|
|00002ef0| 33 36 2e 2b 30 2e 35 29 | 29 0d 09 23 64 65 66 69 |36.+0.5)|)..#defi|
|00002f00| 6e 65 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 78 |ne FixTo|Double(x|
|00002f10| 29 20 28 28 64 6f 75 62 | 6c 65 29 28 78 29 2a 28 |) ((doub|le)(x)*(|
|00002f20| 31 2e 2f 36 35 35 33 36 | 2e 29 29 0d 09 23 64 65 |1./65536|.))..#de|
|00002f30| 66 69 6e 65 20 44 28 78 | 29 20 46 69 78 54 6f 44 |fine D(x|) FixToD|
|00002f40| 6f 75 62 6c 65 28 78 29 | 09 09 09 09 09 09 09 2f |ouble(x)|......./|
|00002f50| 2a 20 68 61 6e 64 79 20 | 66 6f 72 20 64 65 62 75 |* handy |for debu|
|00002f60| 67 67 69 6e 67 20 2a 2f | 0d 23 65 6c 73 65 0d 09 |gging */|.#else..|
|00002f70| 23 64 65 66 69 6e 65 20 | 46 49 58 45 44 20 64 6f |#define |FIXED do|
|00002f80| 75 62 6c 65 0d 09 23 64 | 65 66 69 6e 65 20 46 69 |uble..#d|efine Fi|
|00002f90| 78 4d 75 6c 28 78 2c 79 | 29 20 28 28 64 6f 75 62 |xMul(x,y|) ((doub|
|00002fa0| 6c 65 29 28 78 29 2a 28 | 79 29 29 0d 09 23 64 65 |le)(x)*(|y))..#de|
|00002fb0| 66 69 6e 65 20 46 69 78 | 44 69 76 28 78 2c 79 29 |fine Fix|Div(x,y)|
|00002fc0| 20 28 28 64 6f 75 62 6c | 65 29 28 78 29 2f 28 79 | ((doubl|e)(x)/(y|
|00002fd0| 29 29 0d 09 23 64 65 66 | 69 6e 65 20 4c 6f 6e 67 |))..#def|ine Long|
|00002fe0| 54 6f 46 69 78 28 78 29 | 20 28 28 64 6f 75 62 6c |ToFix(x)| ((doubl|
|00002ff0| 65 29 28 78 29 29 0d 09 | 23 64 65 66 69 6e 65 20 |e)(x))..|#define |
|00003000| 46 69 78 54 6f 4c 6f 6e | 67 28 78 29 20 28 28 6c |FixToLon|g(x) ((l|
|00003010| 6f 6e 67 29 28 78 29 29 | 0d 09 23 64 65 66 69 6e |ong)(x))|..#defin|
|00003020| 65 20 44 6f 75 62 6c 65 | 54 6f 46 69 78 28 78 29 |e Double|ToFix(x)|
|00003030| 20 28 28 64 6f 75 62 6c | 65 29 28 78 29 29 0d 09 | ((doubl|e)(x))..|
|00003040| 23 64 65 66 69 6e 65 20 | 46 69 78 54 6f 44 6f 75 |#define |FixToDou|
|00003050| 62 6c 65 28 78 29 20 28 | 28 64 6f 75 62 6c 65 29 |ble(x) (|(double)|
|00003060| 28 78 29 29 0d 23 65 6e | 64 69 66 0d 0d 23 75 6e |(x)).#en|dif..#un|
|00003070| 64 65 66 20 4d 41 58 0d | 23 75 6e 64 65 66 20 4d |def MAX.|#undef M|
|00003080| 49 4e 0d 23 64 65 66 69 | 6e 65 20 4d 41 58 28 61 |IN.#defi|ne MAX(a|
|00003090| 2c 62 29 20 28 28 61 29 | 20 3e 20 28 62 29 20 3f |,b) ((a)| > (b) ?|
|000030a0| 20 28 61 29 20 3a 20 28 | 62 29 29 0d 23 64 65 66 | (a) : (|b)).#def|
|000030b0| 69 6e 65 20 4d 49 4e 28 | 61 2c 62 29 20 28 28 61 |ine MIN(|a,b) ((a|
|000030c0| 29 20 3c 20 28 62 29 20 | 3f 20 28 61 29 20 3a 20 |) < (b) |? (a) : |
|000030d0| 28 62 29 29 0d 0d 64 6f | 75 62 6c 65 20 45 54 6f |(b))..do|uble ETo|
|000030e0| 4c 28 4c 75 6d 69 6e 61 | 6e 63 65 52 65 63 6f 72 |L(Lumina|nceRecor|
|000030f0| 64 20 2a 4c 50 2c 69 6e | 74 20 65 6e 74 72 79 29 |d *LP,in|t entry)|
|00003100| 0d 7b 0d 09 72 65 74 75 | 72 6e 20 47 65 74 4c 75 |.{..retu|rn GetLu|
|00003110| 6d 69 6e 61 6e 63 65 28 | 4e 55 4c 4c 2c 4c 50 2c |minance(|NULL,LP,|
|00003120| 65 6e 74 72 79 29 3b 0d | 7d 0d 0d 69 6e 74 20 4c |entry);.|}..int L|
|00003130| 54 6f 45 28 4c 75 6d 69 | 6e 61 6e 63 65 52 65 63 |ToE(Lumi|nanceRec|
|00003140| 6f 72 64 20 2a 4c 50 2c | 64 6f 75 62 6c 65 20 4c |ord *LP,|double L|
|00003150| 2c 69 6e 74 20 66 69 72 | 73 74 45 6e 74 72 79 2c |,int fir|stEntry,|
|00003160| 69 6e 74 20 6c 61 73 74 | 45 6e 74 72 79 29 0d 2f |int last|Entry)./|
|00003170| 2f 52 65 74 75 72 6e 73 | 20 74 68 65 20 69 6e 64 |/Returns| the ind|
|00003180| 65 78 20 6f 66 20 74 68 | 65 20 74 61 62 6c 65 20 |ex of th|e table |
|00003190| 65 6e 74 72 79 20 69 6e | 20 73 70 65 63 69 66 69 |entry in| specifi|
|000031a0| 65 64 20 72 61 6e 67 65 | 20 77 69 74 68 20 6c 75 |ed range| with lu|
|000031b0| 6d 69 6e 61 6e 63 65 20 | 63 6c 6f 73 65 73 74 20 |minance |closest |
|000031c0| 74 6f 20 4c 2e 0d 7b 0d | 09 69 6e 74 20 69 2c 65 |to L..{.|.int i,e|
|000031d0| 6e 74 72 79 3b 0d 09 64 | 6f 75 62 6c 65 20 64 4c |ntry;..d|ouble dL|
|000031e0| 2c 6c 61 74 65 73 74 44 | 4c 3b 0d 09 0d 09 6c 61 |,latestD|L;....la|
|000031f0| 74 65 73 74 44 4c 3d 49 | 4e 46 3b 0d 09 65 6e 74 |testDL=I|NF;..ent|
|00003200| 72 79 3d 30 3b 0d 09 66 | 6f 72 28 69 3d 66 69 72 |ry=0;..f|or(i=fir|
|00003210| 73 74 45 6e 74 72 79 3b | 69 3c 3d 6c 61 73 74 45 |stEntry;|i<=lastE|
|00003220| 6e 74 72 79 3b 69 2b 2b | 29 7b 0d 09 09 64 4c 3d |ntry;i++|){...dL=|
|00003230| 66 61 62 73 28 4c 2d 47 | 65 74 4c 75 6d 69 6e 61 |fabs(L-G|etLumina|
|00003240| 6e 63 65 28 4e 55 4c 4c | 2c 4c 50 2c 69 29 29 3b |nce(NULL|,LP,i));|
|00003250| 0d 09 09 69 66 28 64 4c | 3c 6c 61 74 65 73 74 44 |...if(dL|<latestD|
|00003260| 4c 29 7b 0d 09 09 09 65 | 6e 74 72 79 3d 69 3b 0d |L){....e|ntry=i;.|
|00003270| 09 09 09 6c 61 74 65 73 | 74 44 4c 3d 64 4c 3b 0d |...lates|tDL=dL;.|
|00003280| 09 09 7d 0d 09 7d 0d 09 | 72 65 74 75 72 6e 20 65 |..}..}..|return e|
|00003290| 6e 74 72 79 3b 0d 7d 0d | 0d 69 6e 74 20 4c 54 6f |ntry;.}.|.int LTo|
|000032a0| 45 4f 72 64 65 72 65 64 | 28 4c 75 6d 69 6e 61 6e |EOrdered|(Luminan|
|000032b0| 63 65 52 65 63 6f 72 64 | 20 2a 4c 50 2c 64 6f 75 |ceRecord| *LP,dou|
|000032c0| 62 6c 65 20 4c 2c 69 6e | 74 20 66 69 72 73 74 45 |ble L,in|t firstE|
|000032d0| 6e 74 72 79 2c 69 6e 74 | 20 6c 61 73 74 45 6e 74 |ntry,int| lastEnt|
|000032e0| 72 79 29 0d 2f 2a 0d 52 | 65 74 75 72 6e 73 20 74 |ry)./*.R|eturns t|
|000032f0| 68 65 20 69 6e 64 65 78 | 20 6f 66 20 74 68 65 20 |he index| of the |
|00003300| 74 61 62 6c 65 20 65 6e | 74 72 79 20 69 6e 20 73 |table en|try in s|
|00003310| 70 65 63 69 66 69 65 64 | 20 72 61 6e 67 65 20 77 |pecified| range w|
|00003320| 69 74 68 20 6c 75 6d 69 | 6e 61 6e 63 65 20 63 6c |ith lumi|nance cl|
|00003330| 6f 73 65 73 74 20 74 6f | 20 4c 2e 0d 41 73 73 75 |osest to| L..Assu|
|00003340| 6d 65 73 20 6f 72 64 65 | 72 65 64 20 74 61 62 6c |mes orde|red tabl|
|00003350| 65 20 66 72 6f 6d 20 66 | 69 72 73 74 45 6e 74 72 |e from f|irstEntr|
|00003360| 79 20 74 6f 20 6c 61 73 | 74 45 6e 74 72 79 2c 20 |y to las|tEntry, |
|00003370| 65 69 74 68 65 72 20 69 | 6e 63 72 65 61 73 69 6e |either i|ncreasin|
|00003380| 67 20 6f 72 20 64 65 63 | 72 65 61 73 69 6e 67 2e |g or dec|reasing.|
|00003390| 0d 52 65 74 75 72 6e 65 | 64 20 65 6e 74 72 79 20 |.Returne|d entry |
|000033a0| 69 73 20 67 75 61 72 61 | 6e 74 65 65 64 20 74 6f |is guara|nteed to|
|000033b0| 20 62 65 20 69 6e 20 74 | 68 65 20 72 61 6e 67 65 | be in t|he range|
|000033c0| 20 66 69 72 73 74 45 6e | 74 72 79 2e 2e 2e 6c 61 | firstEn|try...la|
|000033d0| 73 74 45 6e 74 72 79 2e | 0d 42 61 73 65 64 20 6f |stEntry.|.Based o|
|000033e0| 6e 20 4e 75 6d 65 72 69 | 63 61 6c 20 52 65 63 69 |n Numeri|cal Reci|
|000033f0| 70 65 73 20 22 6c 6f 63 | 61 74 65 2e 63 22 2c 20 |pes "loc|ate.c", |
|00003400| 70 61 67 65 20 31 31 37 | 0d 2a 2f 0d 7b 0d 09 72 |page 117|.*/.{..r|
|00003410| 65 67 69 73 74 65 72 20 | 69 6e 74 20 6c 6f 77 65 |egister |int lowe|
|00003420| 72 2c 6d 69 64 64 6c 65 | 2c 75 70 70 65 72 3b 0d |r,middle|,upper;.|
|00003430| 09 72 65 67 69 73 74 65 | 72 20 64 6f 75 62 6c 65 |.registe|r double|
|00003440| 20 4c 4c 6f 77 65 72 2c | 4c 4d 69 64 64 6c 65 2c | LLower,|LMiddle,|
|00003450| 4c 55 70 70 65 72 3b 0d | 09 69 6e 74 20 61 73 63 |LUpper;.|.int asc|
|00003460| 65 6e 64 3b 0d 09 0d 09 | 6c 6f 77 65 72 3d 66 69 |end;....|lower=fi|
|00003470| 72 73 74 45 6e 74 72 79 | 3b 0d 09 75 70 70 65 72 |rstEntry|;..upper|
|00003480| 3d 6c 61 73 74 45 6e 74 | 72 79 3b 0d 09 4c 4c 6f |=lastEnt|ry;..LLo|
|00003490| 77 65 72 3d 47 65 74 4c | 75 6d 69 6e 61 6e 63 65 |wer=GetL|uminance|
|000034a0| 28 4e 55 4c 4c 2c 4c 50 | 2c 6c 6f 77 65 72 29 3b |(NULL,LP|,lower);|
|000034b0| 0d 09 4c 55 70 70 65 72 | 3d 47 65 74 4c 75 6d 69 |..LUpper|=GetLumi|
|000034c0| 6e 61 6e 63 65 28 4e 55 | 4c 4c 2c 4c 50 2c 75 70 |nance(NU|LL,LP,up|
|000034d0| 70 65 72 29 3b 0d 09 61 | 73 63 65 6e 64 3d 28 4c |per);..a|scend=(L|
|000034e0| 55 70 70 65 72 3e 4c 4c | 6f 77 65 72 29 3b 0d 09 |Upper>LL|ower);..|
|000034f0| 77 68 69 6c 65 28 75 70 | 70 65 72 2d 6c 6f 77 65 |while(up|per-lowe|
|00003500| 72 3e 31 29 7b 0d 09 09 | 6d 69 64 64 6c 65 3d 28 |r>1){...|middle=(|
|00003510| 75 70 70 65 72 2b 6c 6f | 77 65 72 29 2f 32 3b 0d |upper+lo|wer)/2;.|
|00003520| 09 09 4c 4d 69 64 64 6c | 65 3d 47 65 74 4c 75 6d |..LMiddl|e=GetLum|
|00003530| 69 6e 61 6e 63 65 28 4e | 55 4c 4c 2c 4c 50 2c 6d |inance(N|ULL,LP,m|
|00003540| 69 64 64 6c 65 29 3b 0d | 09 09 69 66 28 4c 3e 4c |iddle);.|..if(L>L|
|00003550| 4d 69 64 64 6c 65 20 3d | 3d 20 61 73 63 65 6e 64 |Middle =|= ascend|
|00003560| 29 7b 0d 09 09 09 6c 6f | 77 65 72 3d 6d 69 64 64 |){....lo|wer=midd|
|00003570| 6c 65 3b 0d 09 09 09 4c | 4c 6f 77 65 72 3d 4c 4d |le;....L|Lower=LM|
|00003580| 69 64 64 6c 65 3b 0d 09 | 09 7d 0d 09 09 65 6c 73 |iddle;..|.}...els|
|00003590| 65 7b 0d 09 09 09 75 70 | 70 65 72 3d 6d 69 64 64 |e{....up|per=midd|
|000035a0| 6c 65 3b 0d 09 09 09 4c | 55 70 70 65 72 3d 4c 4d |le;....L|Upper=LM|
|000035b0| 69 64 64 6c 65 3b 0d 09 | 09 7d 0d 09 7d 0d 09 69 |iddle;..|.}..}..i|
|000035c0| 66 28 4c 2d 4c 4c 6f 77 | 65 72 3c 4c 55 70 70 65 |f(L-LLow|er<LUppe|
|000035d0| 72 2d 4c 20 3d 3d 20 61 | 73 63 65 6e 64 29 72 65 |r-L == a|scend)re|
|000035e0| 74 75 72 6e 20 6c 6f 77 | 65 72 3b 0d 09 65 6c 73 |turn low|er;..els|
|000035f0| 65 20 72 65 74 75 72 6e | 20 75 70 70 65 72 3b 0d |e return| upper;.|
|00003600| 7d 0d 64 6f 75 62 6c 65 | 20 53 65 74 4c 75 6d 69 |}.double| SetLumi|
|00003610| 6e 61 6e 63 65 28 47 44 | 48 61 6e 64 6c 65 20 64 |nance(GD|Handle d|
|00003620| 65 76 69 63 65 2c 4c 75 | 6d 69 6e 61 6e 63 65 52 |evice,Lu|minanceR|
|00003630| 65 63 6f 72 64 20 2a 4c | 50 0d 09 2c 69 6e 74 20 |ecord *L|P..,int |
|00003640| 74 68 65 45 6e 74 72 79 | 2c 64 6f 75 62 6c 65 20 |theEntry|,double |
|00003650| 6c 75 6d 69 6e 61 6e 63 | 65 0d 09 2c 64 6f 75 62 |luminanc|e..,doub|
|00003660| 6c 65 20 6c 6f 77 4c 75 | 6d 69 6e 61 6e 63 65 2c |le lowLu|minance,|
|00003670| 64 6f 75 62 6c 65 20 68 | 69 67 68 4c 75 6d 69 6e |double h|ighLumin|
|00003680| 61 6e 63 65 29 0d 2f 2a | 0d 53 65 74 20 6f 6e 65 |ance)./*|.Set one|
|00003690| 20 65 6e 74 72 79 20 69 | 6e 20 74 68 65 20 43 6f | entry i|n the Co|
|000036a0| 6c 6f 72 53 70 65 63 20 | 74 61 62 6c 65 20 28 61 |lorSpec |table (a|
|000036b0| 6e 64 20 74 68 65 20 63 | 6c 75 74 20 69 66 20 64 |nd the c|lut if d|
|000036c0| 65 76 69 63 65 20 69 73 | 20 6e 6f 74 20 4e 55 4c |evice is| not NUL|
|000036d0| 4c 29 20 74 6f 0d 61 20 | 73 70 65 63 69 66 69 65 |L) to.a |specifie|
|000036e0| 64 20 6c 75 6d 69 6e 61 | 6e 63 65 2e 20 49 74 27 |d lumina|nce. It'|
|000036f0| 73 20 6f 6b 20 66 6f 72 | 20 6c 6f 77 4c 75 6d 69 |s ok for| lowLumi|
|00003700| 6e 61 6e 63 65 20 74 6f | 20 62 65 20 67 72 65 61 |nance to| be grea|
|00003710| 74 65 72 20 74 68 61 6e | 20 68 69 67 68 4c 75 6d |ter than| highLum|
|00003720| 69 6e 61 6e 63 65 3b 20 | 0d 74 68 65 79 20 73 74 |inance; |.they st|
|00003730| 69 6c 6c 20 64 65 73 69 | 67 6e 61 74 65 20 61 20 |ill desi|gnate a |
|00003740| 72 61 6e 67 65 2e 0d 2a | 2f 0d 7b 0d 09 46 49 58 |range..*|/.{..FIX|
|00003750| 45 44 20 5f 6c 75 6d 69 | 6e 61 6e 63 65 3b 0d 09 |ED _lumi|nance;..|
|00003760| 0d 09 69 66 28 74 68 65 | 45 6e 74 72 79 3c 30 20 |..if(the|Entry<0 |
|00003770| 7c 7c 20 74 68 65 45 6e | 74 72 79 3e 3d 43 4f 4c ||| theEn|try>=COL|
|00003780| 4f 52 53 20 0d 09 09 7c | 7c 20 64 65 76 69 63 65 |ORS ...||| device|
|00003790| 21 3d 4e 55 4c 4c 20 26 | 26 20 74 68 65 45 6e 74 |!=NULL &|& theEnt|
|000037a0| 72 79 3e 3d 47 44 43 4c | 55 54 53 49 5a 45 28 64 |ry>=GDCL|UTSIZE(d|
|000037b0| 65 76 69 63 65 29 29 0d | 09 09 09 50 72 69 6e 74 |evice)).|...Print|
|000037c0| 66 45 78 69 74 28 22 5c | 30 30 37 53 65 74 4c 75 |fExit("\|007SetLu|
|000037d0| 6d 69 6e 61 6e 63 65 3a | 20 69 6c 6c 65 67 61 6c |minance:| illegal|
|000037e0| 20 65 6e 74 72 79 20 25 | 64 5c 6e 22 2c 74 68 65 | entry %|d\n",the|
|000037f0| 45 6e 74 72 79 29 3b 0d | 09 0d 09 53 65 74 4c 75 |Entry);.|...SetLu|
|00003800| 6d 69 6e 61 6e 63 65 52 | 61 6e 67 65 28 4c 50 2c |minanceR|ange(LP,|
|00003810| 6c 6f 77 4c 75 6d 69 6e | 61 6e 63 65 2c 68 69 67 |lowLumin|ance,hig|
|00003820| 68 4c 75 6d 69 6e 61 6e | 63 65 29 3b 0d 09 5f 6c |hLuminan|ce);.._l|
|00003830| 75 6d 69 6e 61 6e 63 65 | 3d 44 6f 75 62 6c 65 54 |uminance|=DoubleT|
|00003840| 6f 46 69 78 28 6c 75 6d | 69 6e 61 6e 63 65 29 3b |oFix(lum|inance);|
|00003850| 0d 09 5f 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 28 |.._SetLu|minance(|
|00003860| 4c 50 2c 74 68 65 45 6e | 74 72 79 2c 5f 6c 75 6d |LP,theEn|try,_lum|
|00003870| 69 6e 61 6e 63 65 29 3b | 0d 09 69 66 28 64 65 76 |inance);|..if(dev|
|00003880| 69 63 65 20 21 3d 20 4e | 55 4c 4c 29 4c 6f 61 64 |ice != N|ULL)Load|
|00003890| 4c 75 6d 69 6e 61 6e 63 | 65 73 28 64 65 76 69 63 |Luminanc|es(devic|
|000038a0| 65 2c 4c 50 2c 74 68 65 | 45 6e 74 72 79 2c 74 68 |e,LP,the|Entry,th|
|000038b0| 65 45 6e 74 72 79 29 3b | 0d 09 72 65 74 75 72 6e |eEntry);|..return|
|000038c0| 20 46 69 78 54 6f 44 6f | 75 62 6c 65 28 5f 54 6f | FixToDo|uble(_To|
|000038d0| 6c 65 72 61 6e 63 65 28 | 4c 50 2c 5f 6c 75 6d 69 |lerance(|LP,_lumi|
|000038e0| 6e 61 6e 63 65 29 29 3b | 0d 7d 0d 0d 64 6f 75 62 |nance));|.}..doub|
|000038f0| 6c 65 20 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |le SetLu|minances|
|00003900| 28 47 44 48 61 6e 64 6c | 65 20 64 65 76 69 63 65 |(GDHandl|e device|
|00003910| 2c 4c 75 6d 69 6e 61 6e | 63 65 52 65 63 6f 72 64 |,Luminan|ceRecord|
|00003920| 20 2a 4c 50 0d 09 2c 69 | 6e 74 20 66 69 72 73 74 | *LP..,i|nt first|
|00003930| 45 6e 74 72 79 2c 69 6e | 74 20 6c 61 73 74 45 6e |Entry,in|t lastEn|
|00003940| 74 72 79 0d 09 2c 64 6f | 75 62 6c 65 20 66 69 72 |try..,do|uble fir|
|00003950| 73 74 4c 75 6d 69 6e 61 | 6e 63 65 2c 64 6f 75 62 |stLumina|nce,doub|
|00003960| 6c 65 20 6c 61 73 74 4c | 75 6d 69 6e 61 6e 63 65 |le lastL|uminance|
|00003970| 29 0d 2f 2a 0d 53 65 74 | 20 61 20 73 65 72 69 65 |)./*.Set| a serie|
|00003980| 73 20 6f 66 20 65 6e 74 | 72 69 65 73 20 69 6e 20 |s of ent|ries in |
|00003990| 74 68 65 20 43 6f 6c 6f | 72 53 70 65 63 20 74 61 |the Colo|rSpec ta|
|000039a0| 62 6c 65 20 28 61 6e 64 | 20 74 68 65 20 63 6c 75 |ble (and| the clu|
|000039b0| 74 20 69 66 20 64 65 76 | 69 63 65 20 69 73 20 6e |t if dev|ice is n|
|000039c0| 6f 74 20 4e 55 4c 4c 29 | 0d 74 6f 20 61 20 6c 69 |ot NULL)|.to a li|
|000039d0| 6e 65 61 72 20 73 65 71 | 75 65 6e 63 65 20 6f 66 |near seq|uence of|
|000039e0| 20 6c 75 6d 69 6e 61 6e | 63 65 73 2e 20 41 73 73 | luminan|ces. Ass|
|000039f0| 75 6d 65 20 74 68 69 73 | 20 69 73 20 74 68 65 20 |ume this| is the |
|00003a00| 65 6e 74 69 72 65 20 6c | 75 6d 69 6e 61 6e 63 65 |entire l|uminance|
|00003a10| 20 72 61 6e 67 65 20 6f | 66 20 0d 69 6e 74 65 72 | range o|f .inter|
|00003a20| 65 73 74 2e 0d 2a 2f 0d | 7b 0d 09 72 65 74 75 72 |est..*/.|{..retur|
|00003a30| 6e 20 53 65 74 4c 75 6d | 69 6e 61 6e 63 65 73 41 |n SetLum|inancesA|
|00003a40| 6e 64 52 61 6e 67 65 28 | 64 65 76 69 63 65 2c 4c |ndRange(|device,L|
|00003a50| 50 2c 66 69 72 73 74 45 | 6e 74 72 79 2c 6c 61 73 |P,firstE|ntry,las|
|00003a60| 74 45 6e 74 72 79 0d 09 | 09 2c 66 69 72 73 74 4c |tEntry..|.,firstL|
|00003a70| 75 6d 69 6e 61 6e 63 65 | 2c 6c 61 73 74 4c 75 6d |uminance|,lastLum|
|00003a80| 69 6e 61 6e 63 65 2c 66 | 69 72 73 74 4c 75 6d 69 |inance,f|irstLumi|
|00003a90| 6e 61 6e 63 65 2c 6c 61 | 73 74 4c 75 6d 69 6e 61 |nance,la|stLumina|
|00003aa0| 6e 63 65 29 3b 0d 7d 0d | 0d 64 6f 75 62 6c 65 20 |nce);.}.|.double |
|00003ab0| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 73 41 6e 64 |SetLumin|ancesAnd|
|00003ac0| 52 61 6e 67 65 28 47 44 | 48 61 6e 64 6c 65 20 64 |Range(GD|Handle d|
|00003ad0| 65 76 69 63 65 2c 4c 75 | 6d 69 6e 61 6e 63 65 52 |evice,Lu|minanceR|
|00003ae0| 65 63 6f 72 64 20 2a 4c | 50 0d 09 2c 69 6e 74 20 |ecord *L|P..,int |
|00003af0| 66 69 72 73 74 45 6e 74 | 72 79 2c 69 6e 74 20 6c |firstEnt|ry,int l|
|00003b00| 61 73 74 45 6e 74 72 79 | 0d 09 2c 64 6f 75 62 6c |astEntry|..,doubl|
|00003b10| 65 20 66 69 72 73 74 4c | 75 6d 69 6e 61 6e 63 65 |e firstL|uminance|
|00003b20| 2c 64 6f 75 62 6c 65 20 | 6c 61 73 74 4c 75 6d 69 |,double |lastLumi|
|00003b30| 6e 61 6e 63 65 0d 09 2c | 64 6f 75 62 6c 65 20 6c |nance..,|double l|
|00003b40| 6f 77 4c 75 6d 69 6e 61 | 6e 63 65 2c 64 6f 75 62 |owLumina|nce,doub|
|00003b50| 6c 65 20 68 69 67 68 4c | 75 6d 69 6e 61 6e 63 65 |le highL|uminance|
|00003b60| 29 0d 2f 2a 0d 53 65 74 | 20 61 20 73 65 72 69 65 |)./*.Set| a serie|
|00003b70| 73 20 6f 66 20 65 6e 74 | 72 69 65 73 20 69 6e 20 |s of ent|ries in |
|00003b80| 74 68 65 20 43 6f 6c 6f | 72 53 70 65 63 20 74 61 |the Colo|rSpec ta|
|00003b90| 62 6c 65 20 28 61 6e 64 | 20 74 68 65 20 63 6c 75 |ble (and| the clu|
|00003ba0| 74 20 69 66 20 64 65 76 | 69 63 65 20 69 73 20 6e |t if dev|ice is n|
|00003bb0| 6f 74 0d 4e 55 4c 4c 29 | 20 74 6f 20 61 20 6c 69 |ot.NULL)| to a li|
|00003bc0| 6e 65 61 72 20 73 65 71 | 75 65 6e 63 65 20 6f 66 |near seq|uence of|
|00003bd0| 20 6c 75 6d 69 6e 61 6e | 63 65 73 2e 20 55 73 65 | luminan|ces. Use|
|00003be0| 73 20 6c 61 73 74 20 74 | 77 6f 20 61 72 67 75 6d |s last t|wo argum|
|00003bf0| 65 6e 74 73 20 74 6f 20 | 73 65 74 20 74 68 65 0d |ents to |set the.|
|00003c00| 6c 75 6d 69 6e 61 6e 63 | 65 20 72 61 6e 67 65 2e |luminanc|e range.|
|00003c10| 0d 0d 49 20 69 6e 74 72 | 6f 64 75 63 65 64 20 61 |..I intr|oduced a|
|00003c20| 20 73 74 61 63 6b 2d 73 | 70 61 63 65 20 63 68 65 | stack-s|pace che|
|00003c30| 63 6b 20 62 65 66 6f 72 | 65 20 63 61 6c 6c 69 6e |ck befor|e callin|
|00003c40| 67 20 5f 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |g _SetLu|minances|
|00003c50| 28 29 2c 20 73 69 6e 63 | 65 20 69 74 20 63 61 6c |(), sinc|e it cal|
|00003c60| 6c 73 0d 69 74 73 65 6c | 66 20 72 65 63 75 72 73 |ls.itsel|f recurs|
|00003c70| 69 76 65 6c 79 20 61 6e | 64 20 6d 61 79 20 75 73 |ively an|d may us|
|00003c80| 65 20 31 30 30 30 20 62 | 79 74 65 73 20 61 6c 6c |e 1000 b|ytes all|
|00003c90| 20 74 6f 67 65 74 68 65 | 72 2e 20 48 6f 77 65 76 | togethe|r. Howev|
|00003ca0| 65 72 2c 20 70 72 69 6e | 74 69 6e 67 20 61 6e 0d |er, prin|ting an.|
|00003cb0| 65 72 72 6f 72 20 6d 65 | 73 73 61 67 65 20 72 65 |error me|ssage re|
|00003cc0| 71 75 69 72 65 73 20 61 | 74 20 6c 65 61 73 74 20 |quires a|t least |
|00003cd0| 34 35 30 30 20 62 79 74 | 65 73 2e 20 53 6f 20 49 |4500 byt|es. So I|
|00003ce0| 20 71 75 69 74 20 69 66 | 20 74 68 65 20 73 74 61 | quit if| the sta|
|00003cf0| 63 6b 20 67 65 74 73 20 | 62 65 6c 6f 77 0d 36 30 |ck gets |below.60|
|00003d00| 30 30 2c 20 73 6f 20 74 | 68 61 74 20 74 68 65 20 |00, so t|hat the |
|00003d10| 75 73 65 72 20 77 69 6c | 6c 20 62 65 20 70 72 65 |user wil|l be pre|
|00003d20| 73 65 6e 74 65 64 20 77 | 69 74 68 20 61 6e 20 75 |sented w|ith an u|
|00003d30| 6e 64 65 72 73 74 61 6e | 64 61 62 6c 65 20 65 72 |nderstan|dable er|
|00003d40| 72 6f 72 20 6d 65 73 73 | 61 67 65 0d 72 61 74 68 |ror mess|age.rath|
|00003d50| 65 72 20 74 68 61 6e 20 | 61 20 6d 79 73 74 65 72 |er than |a myster|
|00003d60| 69 6f 75 73 20 71 75 69 | 74 20 6f 72 20 63 72 61 |ious qui|t or cra|
|00003d70| 73 68 2e 0d 2a 2f 0d 7b | 0d 09 46 49 58 45 44 20 |sh..*/.{|..FIXED |
|00003d80| 5f 74 6f 6c 65 72 61 6e | 63 65 2c 5f 74 2c 5f 64 |_toleran|ce,_t,_d|
|00003d90| 4c 36 34 3b 0d 09 46 49 | 58 45 44 20 5f 66 69 72 |L64;..FI|XED _fir|
|00003da0| 73 74 4c 2c 5f 6c 61 73 | 74 4c 2c 5f 66 69 72 73 |stL,_las|tL,_firs|
|00003db0| 74 56 2c 5f 6c 61 73 74 | 56 3b 0d 09 0d 09 69 66 |tV,_last|V;....if|
|00003dc0| 28 66 69 72 73 74 45 6e | 74 72 79 3c 30 20 7c 7c |(firstEn|try<0 |||
|00003dd0| 20 66 69 72 73 74 45 6e | 74 72 79 3e 6c 61 73 74 | firstEn|try>last|
|00003de0| 45 6e 74 72 79 20 7c 7c | 20 6c 61 73 74 45 6e 74 |Entry ||| lastEnt|
|00003df0| 72 79 3e 3d 43 4f 4c 4f | 52 53 20 0d 09 09 7c 7c |ry>=COLO|RS ...|||
|00003e00| 20 64 65 76 69 63 65 21 | 3d 4e 55 4c 4c 20 26 26 | device!|=NULL &&|
|00003e10| 20 6c 61 73 74 45 6e 74 | 72 79 3e 3d 47 44 43 4c | lastEnt|ry>=GDCL|
|00003e20| 55 54 53 49 5a 45 28 64 | 65 76 69 63 65 29 20 29 |UTSIZE(d|evice) )|
|00003e30| 0d 09 09 50 72 69 6e 74 | 66 45 78 69 74 28 22 5c |...Print|fExit("\|
|00003e40| 30 30 37 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |007SetLu|minances|
|00003e50| 41 6e 64 52 61 6e 67 65 | 3a 20 69 6c 6c 65 67 61 |AndRange|: illega|
|00003e60| 6c 20 65 6e 74 72 69 65 | 73 20 25 64 20 25 64 5c |l entrie|s %d %d\|
|00003e70| 6e 22 2c 66 69 72 73 74 | 45 6e 74 72 79 2c 6c 61 |n",first|Entry,la|
|00003e80| 73 74 45 6e 74 72 79 29 | 3b 0d 09 69 66 28 53 74 |stEntry)|;..if(St|
|00003e90| 61 63 6b 53 70 61 63 65 | 28 29 3c 36 30 30 30 29 |ackSpace|()<6000)|
|00003ea0| 50 72 69 6e 74 66 45 78 | 69 74 28 22 53 65 74 4c |PrintfEx|it("SetL|
|00003eb0| 75 6d 69 6e 61 6e 63 65 | 73 41 6e 64 52 61 6e 67 |uminance|sAndRang|
|00003ec0| 65 3a 20 6e 6f 74 20 65 | 6e 6f 75 67 68 20 73 74 |e: not e|nough st|
|00003ed0| 61 63 6b 20 73 70 61 63 | 65 2e 5c 30 30 37 5c 6e |ack spac|e.\007\n|
|00003ee0| 22 29 3b 0d 09 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |");..Set|Luminanc|
|00003ef0| 65 52 61 6e 67 65 28 4c | 50 2c 6c 6f 77 4c 75 6d |eRange(L|P,lowLum|
|00003f00| 69 6e 61 6e 63 65 2c 68 | 69 67 68 4c 75 6d 69 6e |inance,h|ighLumin|
|00003f10| 61 6e 63 65 29 3b 0d 09 | 5f 66 69 72 73 74 4c 3d |ance);..|_firstL=|
|00003f20| 44 6f 75 62 6c 65 54 6f | 46 69 78 28 66 69 72 73 |DoubleTo|Fix(firs|
|00003f30| 74 4c 75 6d 69 6e 61 6e | 63 65 29 3b 0d 09 5f 6c |tLuminan|ce);.._l|
|00003f40| 61 73 74 4c 3d 44 6f 75 | 62 6c 65 54 6f 46 69 78 |astL=Dou|bleToFix|
|00003f50| 28 6c 61 73 74 4c 75 6d | 69 6e 61 6e 63 65 29 3b |(lastLum|inance);|
|00003f60| 0d 09 5f 66 69 72 73 74 | 56 3d 5f 4c 54 6f 56 28 |.._first|V=_LToV(|
|00003f70| 4c 50 2c 5f 66 69 72 73 | 74 4c 20 2b 20 4c 50 2d |LP,_firs|tL + LP-|
|00003f80| 3e 5f 4c 4f 66 66 73 65 | 74 29 3b 0d 09 5f 6c 61 |>_LOffse|t);.._la|
|00003f90| 73 74 56 3d 5f 4c 54 6f | 56 28 4c 50 2c 5f 6c 61 |stV=_LTo|V(LP,_la|
|00003fa0| 73 74 4c 20 2b 20 4c 50 | 2d 3e 5f 4c 4f 66 66 73 |stL + LP|->_LOffs|
|00003fb0| 65 74 29 3b 0d 09 69 66 | 28 6c 61 73 74 45 6e 74 |et);..if|(lastEnt|
|00003fc0| 72 79 20 21 3d 20 66 69 | 72 73 74 45 6e 74 72 79 |ry != fi|rstEntry|
|00003fd0| 29 7b 0d 09 09 23 69 66 | 20 46 41 53 54 5f 4c 55 |){...#if| FAST_LU|
|00003fe0| 4d 49 4e 41 4e 43 45 0d | 09 09 5f 64 4c 36 34 3d |MINANCE.|.._dL64=|
|00003ff0| 44 6f 75 62 6c 65 54 6f | 46 69 78 28 36 34 2e 30 |DoubleTo|Fix(64.0|
|00004000| 2a 28 6c 61 73 74 4c 75 | 6d 69 6e 61 6e 63 65 2d |*(lastLu|minance-|
|00004010| 66 69 72 73 74 4c 75 6d | 69 6e 61 6e 63 65 29 2f |firstLum|inance)/|
|00004020| 28 6c 61 73 74 45 6e 74 | 72 79 2d 66 69 72 73 74 |(lastEnt|ry-first|
|00004030| 45 6e 74 72 79 29 29 3b | 0d 09 09 23 65 6c 73 65 |Entry));|...#else|
|00004040| 0d 09 09 5f 64 4c 36 34 | 3d 44 6f 75 62 6c 65 54 |..._dL64|=DoubleT|
|00004050| 6f 46 69 78 28 28 6c 61 | 73 74 4c 75 6d 69 6e 61 |oFix((la|stLumina|
|00004060| 6e 63 65 2d 66 69 72 73 | 74 4c 75 6d 69 6e 61 6e |nce-firs|tLuminan|
|00004070| 63 65 29 2f 28 6c 61 73 | 74 45 6e 74 72 79 2d 66 |ce)/(las|tEntry-f|
|00004080| 69 72 73 74 45 6e 74 72 | 79 29 29 3b 0d 09 09 23 |irstEntr|y));...#|
|00004090| 65 6e 64 69 66 0d 09 7d | 65 6c 73 65 20 5f 64 4c |endif..}|else _dL|
|000040a0| 36 34 3d 30 3b 0d 09 5f | 53 65 74 4c 75 6d 69 6e |64=0;.._|SetLumin|
|000040b0| 61 6e 63 65 73 28 4c 50 | 2c 66 69 72 73 74 45 6e |ances(LP|,firstEn|
|000040c0| 74 72 79 2c 6c 61 73 74 | 45 6e 74 72 79 2c 5f 66 |try,last|Entry,_f|
|000040d0| 69 72 73 74 4c 2c 5f 64 | 4c 36 34 2c 5f 66 69 72 |irstL,_d|L64,_fir|
|000040e0| 73 74 56 2c 5f 6c 61 73 | 74 56 29 3b 0d 09 69 66 |stV,_las|tV);..if|
|000040f0| 28 64 65 76 69 63 65 20 | 21 3d 20 4e 55 4c 4c 29 |(device |!= NULL)|
|00004100| 4c 6f 61 64 4c 75 6d 69 | 6e 61 6e 63 65 73 28 64 |LoadLumi|nances(d|
|00004110| 65 76 69 63 65 2c 4c 50 | 2c 66 69 72 73 74 45 6e |evice,LP|,firstEn|
|00004120| 74 72 79 2c 6c 61 73 74 | 45 6e 74 72 79 29 3b 09 |try,last|Entry);.|
|00004130| 0d 09 0d 09 2f 2a 20 71 | 75 69 63 6b 20 61 6e 64 |..../* q|uick and|
|00004140| 20 64 69 72 74 79 20 65 | 73 74 69 6d 61 74 65 20 | dirty e|stimate |
|00004150| 6f 66 20 74 6f 6c 65 72 | 61 6e 63 65 20 2a 2f 0d |of toler|ance */.|
|00004160| 09 5f 74 6f 6c 65 72 61 | 6e 63 65 3d 4c 50 2d 3e |._tolera|nce=LP->|
|00004170| 4c 2e 5f 4c 75 5b 30 5d | 20 2d 20 5f 66 69 72 73 |L._Lu[0]| - _firs|
|00004180| 74 4c 3b 0d 09 5f 74 3d | 5f 6c 61 73 74 4c 20 2d |tL;.._t=|_lastL -|
|00004190| 20 4c 50 2d 3e 4c 2e 5f | 4c 75 5b 4c 55 4d 49 4e | LP->L._|Lu[LUMIN|
|000041a0| 41 4e 43 45 53 5f 49 4e | 5f 54 41 42 4c 45 2d 31 |ANCES_IN|_TABLE-1|
|000041b0| 5d 3b 0d 09 69 66 28 5f | 74 6f 6c 65 72 61 6e 63 |];..if(_|toleranc|
|000041c0| 65 3c 5f 74 29 5f 74 6f | 6c 65 72 61 6e 63 65 3d |e<_t)_to|lerance=|
|000041d0| 5f 74 3b 0d 09 69 66 28 | 5f 74 6f 6c 65 72 61 6e |_t;..if(|_toleran|
|000041e0| 63 65 3c 30 29 5f 74 6f | 6c 65 72 61 6e 63 65 3d |ce<0)_to|lerance=|
|000041f0| 30 3b 0d 09 5f 74 6f 6c | 65 72 61 6e 63 65 2b 3d |0;.._tol|erance+=|
|00004200| 4c 50 2d 3e 5f 74 6f 6c | 65 72 61 6e 63 65 3b 0d |LP->_tol|erance;.|
|00004210| 09 72 65 74 75 72 6e 20 | 46 69 78 54 6f 44 6f 75 |.return |FixToDou|
|00004220| 62 6c 65 28 5f 74 6f 6c | 65 72 61 6e 63 65 29 3b |ble(_tol|erance);|
|00004230| 09 2f 2a 20 65 73 74 69 | 6d 61 74 65 20 6f 66 20 |./* esti|mate of |
|00004240| 6d 61 78 20 65 72 72 6f | 72 20 69 6e 20 c6 4c 20 |max erro|r in .L |
|00004250| 2a 2f 0d 7d 0d 0d 76 6f | 69 64 20 5f 53 65 74 4c |*/.}..vo|id _SetL|
|00004260| 75 6d 69 6e 61 6e 63 65 | 73 28 4c 75 6d 69 6e 61 |uminance|s(Lumina|
|00004270| 6e 63 65 52 65 63 6f 72 | 64 20 2a 4c 50 74 72 2c |nceRecor|d *LPtr,|
|00004280| 69 6e 74 20 66 69 72 73 | 74 2c 69 6e 74 20 6c 61 |int firs|t,int la|
|00004290| 73 74 0d 09 2c 46 49 58 | 45 44 20 5f 66 69 72 73 |st..,FIX|ED _firs|
|000042a0| 74 4c 2c 46 49 58 45 44 | 20 5f 64 4c 36 34 2c 46 |tL,FIXED| _dL64,F|
|000042b0| 49 58 45 44 20 5f 66 69 | 72 73 74 56 2c 46 49 58 |IXED _fi|rstV,FIX|
|000042c0| 45 44 20 5f 6c 61 73 74 | 56 29 0d 2f 2a 0d 54 68 |ED _last|V)./*.Th|
|000042d0| 69 73 20 72 6f 75 74 69 | 6e 65 20 65 6c 69 6d 69 |is routi|ne elimi|
|000042e0| 6e 61 74 65 73 20 6d 6f | 73 74 20 6f 66 20 74 68 |nates mo|st of th|
|000042f0| 65 20 74 68 65 20 73 6c | 6f 77 20 5f 4c 54 6f 56 |e the sl|ow _LToV|
|00004300| 28 29 20 74 61 62 6c 65 | 20 6c 6f 6f 6b 75 70 73 |() table| lookups|
|00004310| 20 61 6e 64 0d 69 6e 74 | 65 72 70 6f 6c 61 74 69 | and.int|erpolati|
|00004320| 6f 6e 73 20 62 79 20 61 | 73 73 75 6d 69 6e 67 20 |ons by a|ssuming |
|00004330| 74 68 61 74 20 74 68 65 | 20 67 61 6d 6d 61 20 66 |that the| gamma f|
|00004340| 75 6e 63 74 69 6f 6e 20 | 69 73 20 73 6d 6f 6f 74 |unction |is smoot|
|00004350| 68 20 65 6e 6f 75 67 68 | 20 74 68 61 74 20 77 65 |h enough| that we|
|00004360| 20 6d 61 79 0d 6c 69 6e | 65 61 72 6c 79 20 69 6e | may.lin|early in|
|00004370| 74 65 72 70 6f 6c 61 74 | 65 20 6f 76 65 72 20 61 |terpolat|e over a|
|00004380| 6e 79 20 69 6e 74 65 72 | 76 61 6c 20 6f 66 20 56 |ny inter|val of V|
|00004390| 20 6e 6f 20 77 69 64 65 | 72 20 74 68 61 6e 20 4c | no wide|r than L|
|000043a0| 49 4e 45 41 52 5f 56 5f | 44 4f 4d 41 49 4e 2e 20 |INEAR_V_|DOMAIN. |
|000043b0| 53 69 6e 63 65 0d 74 68 | 65 20 67 61 6d 6d 61 20 |Since.th|e gamma |
|000043c0| 66 75 6e 63 74 69 6f 6e | 20 69 73 20 72 6f 75 67 |function| is roug|
|000043d0| 68 6c 79 20 70 61 72 61 | 62 6f 6c 69 63 2c 20 74 |hly para|bolic, t|
|000043e0| 68 65 20 63 6f 6e 73 65 | 71 75 65 6e 74 20 65 72 |he conse|quent er|
|000043f0| 72 6f 72 20 69 6e 20 4c | 20 77 69 6c 6c 20 62 65 |ror in L| will be|
|00004400| 0d 70 72 6f 70 6f 72 74 | 69 6f 6e 61 6c 20 74 6f |.proport|ional to|
|00004410| 20 74 68 65 20 73 71 75 | 61 72 65 20 6f 66 20 4c | the squ|are of L|
|00004420| 49 4e 45 41 52 5f 56 5f | 44 4f 4d 41 49 4e 2c 20 |INEAR_V_|DOMAIN, |
|00004430| 61 6e 64 20 69 6e 64 65 | 70 65 6e 64 65 6e 74 20 |and inde|pendent |
|00004440| 6f 66 20 77 68 65 72 65 | 20 74 68 69 73 0d 69 6e |of where| this.in|
|00004450| 74 65 72 76 61 6c 20 69 | 73 20 61 6c 6f 6e 67 20 |terval i|s along |
|00004460| 56 2e 20 53 69 6e 63 65 | 20 77 65 27 72 65 20 69 |V. Since| we're i|
|00004470| 6e 73 63 72 69 62 69 6e | 67 20 73 74 72 61 69 67 |nscribin|g straig|
|00004480| 68 74 20 6c 69 6e 65 20 | 73 65 67 6d 65 6e 74 73 |ht line |segments|
|00004490| 20 69 6e 20 61 0d 70 6f | 73 69 74 69 76 65 6c 79 | in a.po|sitively|
|000044a0| 20 61 63 63 65 6c 65 72 | 61 74 69 6e 67 20 67 61 | acceler|ating ga|
|000044b0| 6d 6d 61 20 66 75 6e 63 | 74 69 6f 6e 2c 20 77 65 |mma func|tion, we|
|000044c0| 20 77 69 6c 6c 20 6f 76 | 65 72 65 73 74 69 6d 61 | will ov|erestima|
|000044d0| 74 65 20 6c 75 6d 69 6e | 61 6e 63 65 2c 20 61 6e |te lumin|ance, an|
|000044e0| 64 0d 63 6f 6e 73 65 71 | 75 65 6e 74 6c 79 20 56 |d.conseq|uently V|
|000044f0| 20 77 69 6c 6c 20 62 65 | 20 74 6f 6f 20 6c 6f 77 | will be| too low|
|00004500| 2e 20 54 68 65 20 65 72 | 72 6f 72 20 77 69 6c 6c |. The er|ror will|
|00004510| 20 62 65 20 67 72 65 61 | 74 65 73 74 20 61 74 20 | be grea|test at |
|00004520| 74 68 65 20 6d 69 64 64 | 6c 65 20 6f 66 20 65 61 |the midd|le of ea|
|00004530| 63 68 0d 6c 69 6e 65 61 | 72 6c 79 20 69 6e 74 65 |ch.linea|rly inte|
|00004540| 72 70 6f 6c 61 74 65 64 | 20 56 20 69 6e 74 65 72 |rpolated| V inter|
|00004550| 76 61 6c 2e 0d 0d 49 66 | 20 74 68 65 20 72 65 71 |val...If| the req|
|00004560| 75 65 73 74 65 64 20 56 | 20 69 6e 74 65 72 76 61 |uested V| interva|
|00004570| 6c 20 69 73 20 6c 61 72 | 67 65 72 20 74 68 61 6e |l is lar|ger than|
|00004580| 20 4c 49 4e 45 41 52 5f | 56 5f 44 4f 4d 41 49 4e | LINEAR_|V_DOMAIN|
|00004590| 2c 20 74 68 65 6e 20 69 | 74 20 69 73 20 73 70 6c |, then i|t is spl|
|000045a0| 69 74 0d 69 6e 74 6f 20 | 74 77 6f 20 69 6e 74 65 |it.into |two inte|
|000045b0| 72 76 61 6c 73 20 62 79 | 20 6d 61 6b 69 6e 67 20 |rvals by| making |
|000045c0| 61 20 70 61 69 72 20 6f | 66 20 72 65 63 75 72 73 |a pair o|f recurs|
|000045d0| 69 76 65 20 63 61 6c 6c | 73 2e 20 4c 49 4e 45 41 |ive call|s. LINEA|
|000045e0| 52 5f 56 5f 44 4f 4d 41 | 49 4e 20 69 73 0d 64 65 |R_V_DOMA|IN is.de|
|000045f0| 66 69 6e 65 64 20 69 6e | 20 4c 75 6d 69 6e 61 6e |fined in| Luminan|
|00004600| 63 65 2e 68 2e 20 49 20 | 73 75 67 67 65 73 74 20 |ce.h. I |suggest |
|00004610| 61 20 76 61 6c 75 65 20 | 6f 66 20 34 2c 20 62 75 |a value |of 4, bu|
|00004620| 74 20 69 74 20 6d 61 79 | 20 62 65 20 73 65 74 20 |t it may| be set |
|00004630| 6c 61 72 67 65 72 20 74 | 6f 0d 61 74 74 61 69 6e |larger t|o.attain|
|00004640| 20 73 6c 69 67 68 74 6c | 79 20 68 69 67 68 65 72 | slightl|y higher|
|00004650| 20 73 70 65 65 64 20 61 | 74 20 6c 6f 77 65 72 20 | speed a|t lower |
|00004660| 61 63 63 75 72 61 63 79 | 2e 0d 0d 43 41 55 54 49 |accuracy|...CAUTI|
|00004670| 4f 4e 3a 20 54 68 69 73 | 20 72 6f 75 74 69 6e 65 |ON: This| routine|
|00004680| 20 69 73 20 61 20 73 74 | 61 63 6b 20 68 6f 67 2e | is a st|ack hog.|
|00004690| 20 45 61 63 68 20 63 61 | 6c 6c 20 75 73 65 73 20 | Each ca|ll uses |
|000046a0| 75 70 20 61 62 6f 75 74 | 20 36 34 20 62 79 74 65 |up about| 64 byte|
|000046b0| 73 20 6f 6e 20 74 68 65 | 0d 73 74 61 63 6b 2c 20 |s on the|.stack, |
|000046c0| 61 6e 64 20 69 74 20 63 | 61 6c 6c 73 20 69 74 73 |and it c|alls its|
|000046d0| 65 6c 66 20 72 65 63 75 | 72 73 69 76 65 6c 79 2c |elf recu|rsively,|
|000046e0| 20 75 70 20 74 6f 20 6c | 6f 67 32 28 32 35 36 2f | up to l|og2(256/|
|000046f0| 4c 49 4e 45 41 52 5f 56 | 5f 44 4f 4d 41 49 4e 29 |LINEAR_V|_DOMAIN)|
|00004700| 20 74 69 6d 65 73 2e 0d | 44 6f 20 4e 4f 54 20 63 | times..|Do NOT c|
|00004710| 68 61 6e 67 65 20 61 6e | 79 20 6f 66 20 74 68 65 |hange an|y of the|
|00004720| 20 64 65 63 6c 61 72 61 | 74 69 6f 6e 73 20 6f 66 | declara|tions of|
|00004730| 20 74 68 65 20 22 6e 65 | 77 22 20 76 61 72 69 61 | the "ne|w" varia|
|00004740| 62 6c 65 73 20 75 73 65 | 64 20 69 6e 20 74 68 65 |bles use|d in the|
|00004750| 20 66 69 72 73 74 0d 69 | 66 7b 7d 20 74 6f 20 22 | first.i|f{} to "|
|00004760| 73 74 61 74 69 63 22 2c | 20 61 73 20 74 68 61 74 |static",| as that|
|00004770| 20 77 6f 75 6c 64 20 63 | 61 75 73 65 20 74 68 65 | would c|ause the|
|00004780| 20 72 65 63 75 72 73 69 | 6f 6e 20 74 6f 20 66 61 | recursi|on to fa|
|00004790| 69 6c 2e 0d 2a 2f 0d 7b | 0d 09 73 74 61 74 69 63 |il..*/.{|..static|
|000047a0| 20 69 6e 74 20 64 6f 4c | 61 73 74 3d 31 3b 0d 09 | int doL|ast=1;..|
|000047b0| 69 6e 74 20 73 61 76 65 | 44 6f 4c 61 73 74 3b 0d |int save|DoLast;.|
|000047c0| 09 69 6e 74 20 6e 65 77 | 4f 6e 65 3b 0d 09 46 49 |.int new|One;..FI|
|000047d0| 58 45 44 20 5f 6e 65 77 | 4c 2c 5f 6e 65 77 56 3b |XED _new|L,_newV;|
|000047e0| 0d 09 72 65 67 69 73 74 | 65 72 20 4c 75 6d 69 6e |..regist|er Lumin|
|000047f0| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 3d 4c |anceReco|rd *LP=L|
|00004800| 50 74 72 3b 0d 09 72 65 | 67 69 73 74 65 72 20 69 |Ptr;..re|gister i|
|00004810| 6e 74 20 69 2c 56 69 3b | 0d 09 72 65 67 69 73 74 |nt i,Vi;|..regist|
|00004820| 65 72 20 46 49 58 45 44 | 20 5f 56 54 6f 47 6f 2c |er FIXED| _VToGo,|
|00004830| 5f 67 3b 0d 09 73 74 61 | 74 69 63 20 52 47 42 43 |_g;..sta|tic RGBC|
|00004840| 6f 6c 6f 72 20 2a 52 47 | 42 50 74 72 3b 09 2f 2a |olor *RG|BPtr;./*|
|00004850| 20 73 74 61 74 69 63 20 | 69 6e 20 6f 72 64 65 72 | static |in order|
|00004860| 20 74 6f 20 6d 69 6e 69 | 6d 69 7a 65 20 73 74 61 | to mini|mize sta|
|00004870| 63 6b 20 75 73 61 67 65 | 20 2a 2f 0d 09 73 74 61 |ck usage| */..sta|
|00004880| 74 69 63 20 69 6e 74 20 | 74 68 65 45 6e 74 72 79 |tic int |theEntry|
|00004890| 3b 09 09 2f 2a 20 73 74 | 61 74 69 63 20 69 6e 20 |;../* st|atic in |
|000048a0| 6f 72 64 65 72 20 74 6f | 20 6d 69 6e 69 6d 69 7a |order to| minimiz|
|000048b0| 65 20 73 74 61 63 6b 20 | 75 73 61 67 65 20 2a 2f |e stack |usage */|
|000048c0| 0d 09 73 74 61 74 69 63 | 20 46 49 58 45 44 20 5f |..static| FIXED _|
|000048d0| 56 2c 5f 64 56 3b 09 09 | 2f 2a 20 73 74 61 74 69 |V,_dV;..|/* stati|
|000048e0| 63 20 69 6e 20 6f 72 64 | 65 72 20 74 6f 20 6d 69 |c in ord|er to mi|
|000048f0| 6e 69 6d 69 7a 65 20 73 | 74 61 63 6b 20 75 73 61 |nimize s|tack usa|
|00004900| 67 65 20 2a 2f 0d 09 72 | 65 67 69 73 74 65 72 20 |ge */..r|egister |
|00004910| 73 68 6f 72 74 20 6c 65 | 66 74 53 68 69 66 74 3b |short le|ftShift;|
|00004920| 0d 09 0d 09 69 66 28 6c | 61 73 74 2d 66 69 72 73 |....if(l|ast-firs|
|00004930| 74 3e 31 20 29 7b 0d 09 | 09 5f 64 56 3d 5f 6c 61 |t>1 ){..|._dV=_la|
|00004940| 73 74 56 2d 5f 66 69 72 | 73 74 56 3b 0d 09 09 69 |stV-_fir|stV;...i|
|00004950| 66 28 5f 64 56 3e 4c 6f | 6e 67 54 6f 46 69 78 28 |f(_dV>Lo|ngToFix(|
|00004960| 4c 49 4e 45 41 52 5f 56 | 5f 44 4f 4d 41 49 4e 29 |LINEAR_V|_DOMAIN)|
|00004970| 20 7c 7c 20 5f 64 56 3c | 4c 6f 6e 67 54 6f 46 69 | || _dV<|LongToFi|
|00004980| 78 28 2d 4c 49 4e 45 41 | 52 5f 56 5f 44 4f 4d 41 |x(-LINEA|R_V_DOMA|
|00004990| 49 4e 29 29 7b 0d 09 09 | 09 6e 65 77 4f 6e 65 3d |IN)){...|.newOne=|
|000049a0| 28 66 69 72 73 74 2b 6c | 61 73 74 29 3e 3e 31 3b |(first+l|ast)>>1;|
|000049b0| 0d 09 09 09 23 69 66 20 | 46 41 53 54 5f 4c 55 4d |....#if |FAST_LUM|
|000049c0| 49 4e 41 4e 43 45 0d 09 | 09 09 09 5f 6e 65 77 4c |INANCE..|..._newL|
|000049d0| 3d 5f 66 69 72 73 74 4c | 2b 28 28 6e 65 77 4f 6e |=_firstL|+((newOn|
|000049e0| 65 2d 66 69 72 73 74 29 | 2a 5f 64 4c 36 34 3e 3e |e-first)|*_dL64>>|
|000049f0| 36 29 3b 0d 09 09 09 23 | 65 6c 73 65 0d 09 09 09 |6);....#|else....|
|00004a00| 09 5f 6e 65 77 4c 3d 5f | 66 69 72 73 74 4c 2b 28 |._newL=_|firstL+(|
|00004a10| 6e 65 77 4f 6e 65 2d 66 | 69 72 73 74 29 2a 5f 64 |newOne-f|irst)*_d|
|00004a20| 4c 36 34 3b 0d 09 09 09 | 23 65 6e 64 69 66 0d 09 |L64;....|#endif..|
|00004a30| 09 09 5f 6e 65 77 56 3d | 5f 4c 54 6f 56 28 4c 50 |.._newV=|_LToV(LP|
|00004a40| 2c 5f 6e 65 77 4c 20 2b | 20 4c 50 2d 3e 5f 4c 4f |,_newL +| LP->_LO|
|00004a50| 66 66 73 65 74 29 3b 0d | 09 09 09 73 61 76 65 44 |ffset);.|...saveD|
|00004a60| 6f 4c 61 73 74 3d 64 6f | 4c 61 73 74 3b 0d 09 09 |oLast=do|Last;...|
|00004a70| 09 64 6f 4c 61 73 74 3d | 30 3b 0d 09 09 09 5f 53 |.doLast=|0;...._S|
|00004a80| 65 74 4c 75 6d 69 6e 61 | 6e 63 65 73 28 4c 50 2c |etLumina|nces(LP,|
|00004a90| 66 69 72 73 74 2c 6e 65 | 77 4f 6e 65 2c 5f 66 69 |first,ne|wOne,_fi|
|00004aa0| 72 73 74 4c 2c 5f 64 4c | 36 34 2c 5f 66 69 72 73 |rstL,_dL|64,_firs|
|00004ab0| 74 56 2c 5f 6e 65 77 56 | 29 3b 0d 09 09 09 64 6f |tV,_newV|);....do|
|00004ac0| 4c 61 73 74 3d 73 61 76 | 65 44 6f 4c 61 73 74 3b |Last=sav|eDoLast;|
|00004ad0| 0d 09 09 09 5f 53 65 74 | 4c 75 6d 69 6e 61 6e 63 |...._Set|Luminanc|
|00004ae0| 65 73 28 4c 50 2c 6e 65 | 77 4f 6e 65 2c 6c 61 73 |es(LP,ne|wOne,las|
|00004af0| 74 2c 5f 6e 65 77 4c 2c | 5f 64 4c 36 34 2c 5f 6e |t,_newL,|_dL64,_n|
|00004b00| 65 77 56 2c 5f 6c 61 73 | 74 56 29 3b 0d 09 09 09 |ewV,_las|tV);....|
|00004b10| 72 65 74 75 72 6e 3b 0d | 09 09 7d 0d 09 7d 0d 09 |return;.|..}..}..|
|00004b20| 69 66 28 6c 61 73 74 21 | 3d 66 69 72 73 74 29 5f |if(last!|=first)_|
|00004b30| 64 56 3d 28 5f 6c 61 73 | 74 56 2d 5f 66 69 72 73 |dV=(_las|tV-_firs|
|00004b40| 74 56 29 2f 28 6c 61 73 | 74 2d 66 69 72 73 74 29 |tV)/(las|t-first)|
|00004b50| 3b 0d 09 65 6c 73 65 20 | 5f 64 56 3d 30 3b 0d 09 |;..else |_dV=0;..|
|00004b60| 69 66 28 21 64 6f 4c 61 | 73 74 29 6c 61 73 74 2d |if(!doLa|st)last-|
|00004b70| 2d 3b 0d 09 6c 65 66 74 | 53 68 69 66 74 3d 4c 50 |-;..left|Shift=LP|
|00004b80| 2d 3e 6c 65 66 74 53 68 | 69 66 74 3b 0d 09 66 6f |->leftSh|ift;..fo|
|00004b90| 72 28 74 68 65 45 6e 74 | 72 79 3d 66 69 72 73 74 |r(theEnt|ry=first|
|00004ba0| 2c 5f 56 3d 5f 66 69 72 | 73 74 56 3b 74 68 65 45 |,_V=_fir|stV;theE|
|00004bb0| 6e 74 72 79 3c 3d 6c 61 | 73 74 3b 74 68 65 45 6e |ntry<=la|st;theEn|
|00004bc0| 74 72 79 2b 2b 2c 5f 56 | 2b 3d 5f 64 56 29 7b 0d |try++,_V|+=_dV){.|
|00004bd0| 09 09 2f 2a 2a 2a 2a 2a | 2a 20 54 68 69 73 20 73 |../*****|* This s|
|00004be0| 65 63 74 69 6f 6e 20 6f | 66 20 63 6f 64 65 20 69 |ection o|f code i|
|00004bf0| 73 20 63 6f 70 69 65 64 | 20 66 72 6f 6d 20 5f 53 |s copied| from _S|
|00004c00| 65 74 4c 75 6d 69 6e 61 | 6e 63 65 28 29 20 2a 2a |etLumina|nce() **|
|00004c10| 2a 2a 2f 0d 09 09 52 47 | 42 50 74 72 20 3d 20 26 |**/...RG|BPtr = &|
|00004c20| 4c 50 2d 3e 74 61 62 6c | 65 5b 74 68 65 45 6e 74 |LP->tabl|e[theEnt|
|00004c30| 72 79 5d 2e 72 67 62 3b | 0d 09 09 2a 52 47 42 50 |ry].rgb;|...*RGBP|
|00004c40| 74 72 3d 4c 50 2d 3e 72 | 67 62 3b 09 09 09 09 09 |tr=LP->r|gb;.....|
|00004c50| 09 2f 2a 20 6c 6f 61 64 | 20 66 6f 72 20 66 69 78 |./* load| for fix|
|00004c60| 65 64 20 44 41 43 73 20 | 2a 2f 0d 09 09 5f 56 54 |ed DACs |*/..._VT|
|00004c70| 6f 47 6f 3d 5f 56 20 2d | 20 4c 50 2d 3e 5f 56 46 |oGo=_V -| LP->_VF|
|00004c80| 69 78 65 64 20 2b 20 4c | 50 2d 3e 5f 56 48 61 6c |ixed + L|P->_VHal|
|00004c90| 66 53 74 65 70 3b 0d 09 | 09 66 6f 72 28 69 3d 4c |fStep;..|.for(i=L|
|00004ca0| 50 2d 3e 66 69 78 65 64 | 3b 69 3c 4c 50 2d 3e 64 |P->fixed|;i<LP->d|
|00004cb0| 61 63 73 3b 69 2b 2b 29 | 20 7b 0d 09 09 09 5f 67 |acs;i++)| {...._g|
|00004cc0| 3d 4c 50 2d 3e 5f 67 61 | 69 6e 5b 69 5d 3b 0d 09 |=LP->_ga|in[i];..|
|00004cd0| 09 09 56 69 3d 5f 56 54 | 6f 47 6f 2f 5f 67 3b 09 |..Vi=_VT|oGo/_g;.|
|00004ce0| 09 09 09 09 09 2f 2a 20 | 74 72 75 6e 63 61 74 65 |...../* |truncate|
|00004cf0| 20 74 6f 20 69 6e 74 65 | 67 65 72 20 2a 2f 0d 09 | to inte|ger */..|
|00004d00| 09 09 69 66 28 56 69 3e | 4c 50 2d 3e 56 4d 61 78 |..if(Vi>|LP->VMax|
|00004d10| 29 56 69 3d 4c 50 2d 3e | 56 4d 61 78 3b 0d 09 09 |)Vi=LP->|VMax;...|
|00004d20| 09 69 66 28 56 69 3c 4c | 50 2d 3e 56 4d 69 6e 29 |.if(Vi<L|P->VMin)|
|00004d30| 56 69 3d 4c 50 2d 3e 56 | 4d 69 6e 3b 0d 09 09 09 |Vi=LP->V|Min;....|
|00004d40| 5f 56 54 6f 47 6f 20 2d | 3d 20 56 69 2a 5f 67 3b |_VToGo -|= Vi*_g;|
|00004d50| 0d 09 09 09 28 28 73 68 | 6f 72 74 20 2a 29 52 47 |....((sh|ort *)RG|
|00004d60| 42 50 74 72 29 5b 4c 50 | 2d 3e 64 61 63 5b 69 5d |BPtr)[LP|->dac[i]|
|00004d70| 5d 3d 56 69 3c 3c 6c 65 | 66 74 53 68 69 66 74 3b |]=Vi<<le|ftShift;|
|00004d80| 0d 09 09 7d 0d 09 09 2f | 2a 2a 2a 2a 2a 2a 2a 2a |...}.../|********|
|00004d90| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004da0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004db0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004dc0| 2a 2a 2a 2a 2a 2a 2a 2f | 0d 09 7d 0d 09 72 65 74 |*******/|..}..ret|
|00004dd0| 75 72 6e 3b 0d 7d 0d 0d | 76 6f 69 64 20 5f 53 65 |urn;.}..|void _Se|
|00004de0| 74 4c 75 6d 69 6e 61 6e | 63 65 28 4c 75 6d 69 6e |tLuminan|ce(Lumin|
|00004df0| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 74 72 |anceReco|rd *LPtr|
|00004e00| 2c 69 6e 74 20 74 68 65 | 45 6e 74 72 79 2c 46 49 |,int the|Entry,FI|
|00004e10| 58 45 44 20 5f 6c 75 6d | 69 6e 61 6e 63 65 29 0d |XED _lum|inance).|
|00004e20| 2f 2a 0d 53 65 74 20 6f | 6e 65 20 65 6e 74 72 79 |/*.Set o|ne entry|
|00004e30| 20 69 6e 20 74 68 65 20 | 43 6f 6c 6f 72 53 70 65 | in the |ColorSpe|
|00004e40| 63 20 74 61 62 6c 65 20 | 74 6f 20 61 20 73 70 65 |c table |to a spe|
|00004e50| 63 69 66 69 65 64 20 6c | 75 6d 69 6e 61 6e 63 65 |cified l|uminance|
|00004e60| 2e 20 54 68 69 73 20 69 | 73 20 74 68 65 0d 70 72 |. This i|s the.pr|
|00004e70| 69 76 61 74 65 20 73 75 | 62 72 6f 75 74 69 6e 65 |ivate su|broutine|
|00004e80| 20 74 68 61 74 20 61 63 | 74 75 61 6c 6c 79 20 64 | that ac|tually d|
|00004e90| 6f 65 73 20 61 6c 6c 20 | 74 68 65 20 77 6f 72 6b |oes all |the work|
|00004ea0| 20 66 6f 72 20 53 65 74 | 4c 75 6d 69 6e 61 6e 63 | for Set|Luminanc|
|00004eb0| 65 28 29 2e 20 54 68 69 | 73 0d 72 6f 75 74 69 6e |e(). Thi|s.routin|
|00004ec0| 65 20 69 73 20 64 65 73 | 69 67 6e 65 64 20 74 6f |e is des|igned to|
|00004ed0| 20 72 75 6e 20 61 73 20 | 66 61 73 74 20 61 73 20 | run as |fast as |
|00004ee0| 70 6f 73 73 69 62 6c 65 | 2e 0d 2a 2f 0d 7b 0d 09 |possible|..*/.{..|
|00004ef0| 72 65 67 69 73 74 65 72 | 20 4c 75 6d 69 6e 61 6e |register| Luminan|
|00004f00| 63 65 52 65 63 6f 72 64 | 20 2a 4c 50 3d 4c 50 74 |ceRecord| *LP=LPt|
|00004f10| 72 3b 0d 09 72 65 67 69 | 73 74 65 72 20 69 6e 74 |r;..regi|ster int|
|00004f20| 20 69 2c 56 69 3b 0d 09 | 72 65 67 69 73 74 65 72 | i,Vi;..|register|
|00004f30| 20 46 49 58 45 44 20 5f | 56 54 6f 47 6f 2c 5f 67 | FIXED _|VToGo,_g|
|00004f40| 3b 0d 09 52 47 42 43 6f | 6c 6f 72 20 2a 52 47 42 |;..RGBCo|lor *RGB|
|00004f50| 50 74 72 3b 0d 09 72 65 | 67 69 73 74 65 72 20 73 |Ptr;..re|gister s|
|00004f60| 68 6f 72 74 20 6c 65 66 | 74 53 68 69 66 74 3d 4c |hort lef|tShift=L|
|00004f70| 50 2d 3e 6c 65 66 74 53 | 68 69 66 74 3b 0d 09 0d |P->leftS|hift;...|
|00004f80| 09 52 47 42 50 74 72 20 | 3d 20 26 4c 50 2d 3e 74 |.RGBPtr |= &LP->t|
|00004f90| 61 62 6c 65 5b 74 68 65 | 45 6e 74 72 79 5d 2e 72 |able[the|Entry].r|
|00004fa0| 67 62 3b 0d 09 2a 52 47 | 42 50 74 72 3d 4c 50 2d |gb;..*RG|BPtr=LP-|
|00004fb0| 3e 72 67 62 3b 09 09 09 | 09 09 09 2f 2a 20 6c 6f |>rgb;...|.../* lo|
|00004fc0| 61 64 20 66 6f 72 20 66 | 69 78 65 64 20 44 41 43 |ad for f|ixed DAC|
|00004fd0| 73 20 2a 2f 0d 09 5f 56 | 54 6f 47 6f 3d 5f 4c 54 |s */.._V|ToGo=_LT|
|00004fe0| 6f 56 28 4c 50 2c 5f 6c | 75 6d 69 6e 61 6e 63 65 |oV(LP,_l|uminance|
|00004ff0| 20 2b 20 4c 50 2d 3e 5f | 4c 4f 66 66 73 65 74 29 | + LP->_|LOffset)|
|00005000| 20 2d 20 4c 50 2d 3e 5f | 56 46 69 78 65 64 20 2b | - LP->_|VFixed +|
|00005010| 20 4c 50 2d 3e 5f 56 48 | 61 6c 66 53 74 65 70 3b | LP->_VH|alfStep;|
|00005020| 0d 09 66 6f 72 28 69 3d | 4c 50 2d 3e 66 69 78 65 |..for(i=|LP->fixe|
|00005030| 64 3b 69 3c 4c 50 2d 3e | 64 61 63 73 3b 69 2b 2b |d;i<LP->|dacs;i++|
|00005040| 29 20 7b 0d 09 09 5f 67 | 3d 4c 50 2d 3e 5f 67 61 |) {..._g|=LP->_ga|
|00005050| 69 6e 5b 69 5d 3b 0d 09 | 09 56 69 3d 5f 56 54 6f |in[i];..|.Vi=_VTo|
|00005060| 47 6f 2f 5f 67 3b 09 09 | 09 09 09 09 2f 2a 20 74 |Go/_g;..|..../* t|
|00005070| 72 75 6e 63 61 74 65 20 | 74 6f 20 69 6e 74 65 67 |runcate |to integ|
|00005080| 65 72 20 2a 2f 0d 09 09 | 69 66 28 56 69 3e 4c 50 |er */...|if(Vi>LP|
|00005090| 2d 3e 56 4d 61 78 29 56 | 69 3d 4c 50 2d 3e 56 4d |->VMax)V|i=LP->VM|
|000050a0| 61 78 3b 0d 09 09 69 66 | 28 56 69 3c 4c 50 2d 3e |ax;...if|(Vi<LP->|
|000050b0| 56 4d 69 6e 29 56 69 3d | 4c 50 2d 3e 56 4d 69 6e |VMin)Vi=|LP->VMin|
|000050c0| 3b 0d 09 09 5f 56 54 6f | 47 6f 20 2d 3d 20 56 69 |;..._VTo|Go -= Vi|
|000050d0| 2a 5f 67 3b 0d 09 09 28 | 28 73 68 6f 72 74 20 2a |*_g;...(|(short *|
|000050e0| 29 52 47 42 50 74 72 29 | 5b 4c 50 2d 3e 64 61 63 |)RGBPtr)|[LP->dac|
|000050f0| 5b 69 5d 5d 3d 56 69 3c | 3c 6c 65 66 74 53 68 69 |[i]]=Vi<|<leftShi|
|00005100| 66 74 3b 0d 09 7d 0d 7d | 0d 0d 76 6f 69 64 20 49 |ft;..}.}|..void I|
|00005110| 6e 63 72 65 6d 65 6e 74 | 4c 75 6d 69 6e 61 6e 63 |ncrement|Luminanc|
|00005120| 65 28 47 44 48 61 6e 64 | 6c 65 20 64 65 76 69 63 |e(GDHand|le devic|
|00005130| 65 2c 72 65 67 69 73 74 | 65 72 20 4c 75 6d 69 6e |e,regist|er Lumin|
|00005140| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 2c 69 |anceReco|rd *LP,i|
|00005150| 6e 74 20 74 68 65 45 6e | 74 72 79 29 0d 2f 2a 0d |nt theEn|try)./*.|
|00005160| 4d 61 6b 65 20 73 6d 61 | 6c 6c 65 73 74 20 70 6f |Make sma|llest po|
|00005170| 73 73 69 62 6c 65 20 69 | 6e 63 72 65 61 73 65 20 |ssible i|ncrease |
|00005180| 6f 66 20 74 68 65 20 6c | 75 6d 69 6e 61 6e 63 65 |of the l|uminance|
|00005190| 20 6f 66 20 6f 6e 65 20 | 65 6e 74 72 79 20 69 6e | of one |entry in|
|000051a0| 20 74 68 65 20 43 6f 6c | 6f 72 53 70 65 63 0d 74 | the Col|orSpec.t|
|000051b0| 61 62 6c 65 2e 20 49 66 | 20 6e 65 63 65 73 73 61 |able. If| necessa|
|000051c0| 72 79 2c 20 62 75 6d 70 | 20 75 70 20 74 68 65 20 |ry, bump| up the |
|000051d0| 75 70 70 65 72 20 6c 75 | 6d 69 6e 61 6e 63 65 20 |upper lu|minance |
|000051e0| 62 6f 75 6e 64 20 74 6f | 20 69 6e 63 6c 75 64 65 |bound to| include|
|000051f0| 20 74 68 65 20 69 6e 63 | 72 65 6d 65 6e 74 65 64 | the inc|remented|
|00005200| 20 6c 75 6d 69 6e 61 6e | 63 65 2e 0d 2a 2f 0d 7b | luminan|ce..*/.{|
|00005210| 0d 09 64 6f 75 62 6c 65 | 20 56 2c 4c 2c 68 69 67 |..double| V,L,hig|
|00005220| 68 4c 3b 0d 09 0d 09 56 | 3d 47 65 74 56 28 64 65 |hL;....V|=GetV(de|
|00005230| 76 69 63 65 2c 4c 50 2c | 74 68 65 45 6e 74 72 79 |vice,LP,|theEntry|
|00005240| 29 3b 0d 09 56 2b 3d 4c | 50 2d 3e 56 48 61 6c 66 |);..V+=L|P->VHalf|
|00005250| 53 74 65 70 3b 0d 09 56 | 2b 3d 4c 50 2d 3e 56 48 |Step;..V|+=LP->VH|
|00005260| 61 6c 66 53 74 65 70 3b | 0d 09 4c 3d 56 54 6f 4c |alfStep;|..L=VToL|
|00005270| 28 4c 50 2c 56 29 3b 0d | 09 69 66 28 4c 3e 4c 50 |(LP,V);.|.if(L>LP|
|00005280| 2d 3e 68 69 67 68 4c 75 | 6d 69 6e 61 6e 63 65 29 |->highLu|minance)|
|00005290| 68 69 67 68 4c 3d 4c 3b | 0d 09 65 6c 73 65 20 68 |highL=L;|..else h|
|000052a0| 69 67 68 4c 3d 4c 50 2d | 3e 68 69 67 68 4c 75 6d |ighL=LP-|>highLum|
|000052b0| 69 6e 61 6e 63 65 3b 0d | 09 53 65 74 4c 75 6d 69 |inance;.|.SetLumi|
|000052c0| 6e 61 6e 63 65 28 64 65 | 76 69 63 65 2c 4c 50 2c |nance(de|vice,LP,|
|000052d0| 74 68 65 45 6e 74 72 79 | 2c 4c 2c 4c 50 2d 3e 6c |theEntry|,L,LP->l|
|000052e0| 6f 77 4c 75 6d 69 6e 61 | 6e 63 65 2c 68 69 67 68 |owLumina|nce,high|
|000052f0| 4c 29 3b 0d 7d 0d 0d 46 | 49 58 45 44 20 5f 54 6f |L);.}..F|IXED _To|
|00005300| 6c 65 72 61 6e 63 65 28 | 4c 75 6d 69 6e 61 6e 63 |lerance(|Luminanc|
|00005310| 65 52 65 63 6f 72 64 20 | 2a 4c 50 74 72 2c 46 49 |eRecord |*LPtr,FI|
|00005320| 58 45 44 20 5f 6c 75 6d | 69 6e 61 6e 63 65 29 0d |XED _lum|inance).|
|00005330| 7b 0d 09 72 65 67 69 73 | 74 65 72 20 4c 75 6d 69 |{..regis|ter Lumi|
|00005340| 6e 61 6e 63 65 52 65 63 | 6f 72 64 20 2a 4c 50 3d |nanceRec|ord *LP=|
|00005350| 4c 50 74 72 3b 0d 09 72 | 65 67 69 73 74 65 72 20 |LPtr;..r|egister |
|00005360| 46 49 58 45 44 20 5f 74 | 6f 6c 65 72 61 6e 63 65 |FIXED _t|olerance|
|00005370| 2c 5f 74 3b 0d 09 0d 09 | 2f 2a 20 71 75 69 63 6b |,_t;....|/* quick|
|00005380| 20 61 6e 64 20 64 69 72 | 74 79 20 65 73 74 69 6d | and dir|ty estim|
|00005390| 61 74 65 20 6f 66 20 74 | 6f 6c 65 72 61 6e 63 65 |ate of t|olerance|
|000053a0| 20 2a 2f 0d 09 69 66 28 | 4c 50 2d 3e 4c 2e 65 78 | */..if(|LP->L.ex|
|000053b0| 69 73 74 73 3d 3d 6c 75 | 6d 69 6e 61 6e 63 65 53 |ists==lu|minanceS|
|000053c0| 65 74 29 7b 0d 09 09 5f | 74 6f 6c 65 72 61 6e 63 |et){..._|toleranc|
|000053d0| 65 3d 4c 50 2d 3e 4c 2e | 5f 4c 75 5b 30 5d 20 2d |e=LP->L.|_Lu[0] -|
|000053e0| 20 5f 6c 75 6d 69 6e 61 | 6e 63 65 3b 0d 09 09 5f | _lumina|nce;..._|
|000053f0| 74 3d 5f 6c 75 6d 69 6e | 61 6e 63 65 20 2d 20 4c |t=_lumin|ance - L|
|00005400| 50 2d 3e 4c 2e 5f 4c 75 | 5b 4c 55 4d 49 4e 41 4e |P->L._Lu|[LUMINAN|
|00005410| 43 45 53 5f 49 4e 5f 54 | 41 42 4c 45 2d 31 5d 3b |CES_IN_T|ABLE-1];|
|00005420| 0d 09 09 69 66 28 5f 74 | 6f 6c 65 72 61 6e 63 65 |...if(_t|olerance|
|00005430| 3c 5f 74 29 5f 74 6f 6c | 65 72 61 6e 63 65 3d 5f |<_t)_tol|erance=_|
|00005440| 74 3b 0d 09 09 69 66 28 | 5f 74 6f 6c 65 72 61 6e |t;...if(|_toleran|
|00005450| 63 65 3c 30 29 5f 74 6f | 6c 65 72 61 6e 63 65 3d |ce<0)_to|lerance=|
|00005460| 30 3b 0d 09 09 5f 74 6f | 6c 65 72 61 6e 63 65 2b |0;..._to|lerance+|
|00005470| 3d 4c 50 2d 3e 5f 74 6f | 6c 65 72 61 6e 63 65 3b |=LP->_to|lerance;|
|00005480| 0d 09 7d 0d 09 65 6c 73 | 65 20 5f 74 6f 6c 65 72 |..}..els|e _toler|
|00005490| 61 6e 63 65 3d 4c 50 2d | 3e 5f 74 6f 6c 65 72 61 |ance=LP-|>_tolera|
|000054a0| 6e 63 65 3b 0d 09 72 65 | 74 75 72 6e 20 5f 74 6f |nce;..re|turn _to|
|000054b0| 6c 65 72 61 6e 63 65 3b | 0d 7d 0d 0d 64 6f 75 62 |lerance;|.}..doub|
|000054c0| 6c 65 20 47 65 74 4c 75 | 6d 69 6e 61 6e 63 65 28 |le GetLu|minance(|
|000054d0| 47 44 48 61 6e 64 6c 65 | 20 64 65 76 69 63 65 2c |GDHandle| device,|
|000054e0| 4c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |Luminanc|eRecord |
|000054f0| 2a 4c 50 2c 69 6e 74 20 | 74 68 65 45 6e 74 72 79 |*LP,int |theEntry|
|00005500| 29 0d 2f 2a 0d 49 66 20 | 64 65 76 69 63 65 20 69 |)./*.If |device i|
|00005510| 73 20 6e 6f 74 20 4e 55 | 4c 4c 20 74 68 65 6e 20 |s not NU|LL then |
|00005520| 65 78 61 6d 69 6e 65 73 | 20 6f 6e 65 20 65 6e 74 |examines| one ent|
|00005530| 72 79 20 69 6e 20 74 68 | 65 20 61 63 74 75 61 6c |ry in th|e actual|
|00005540| 20 63 6c 75 74 2c 20 6f | 74 68 65 72 77 69 73 65 | clut, o|therwise|
|00005550| 0d 65 78 61 6d 69 6e 65 | 73 20 74 68 65 20 43 6f |.examine|s the Co|
|00005560| 6c 6f 72 53 70 65 63 20 | 74 61 62 6c 65 20 63 6f |lorSpec |table co|
|00005570| 6e 74 61 69 6e 65 64 20 | 69 6e 20 2a 4c 50 2c 20 |ntained |in *LP, |
|00005580| 61 6e 64 20 69 6e 20 65 | 69 74 68 65 72 20 63 61 |and in e|ither ca|
|00005590| 73 65 20 72 65 74 75 72 | 6e 73 20 74 68 65 0d 6c |se retur|ns the.l|
|000055a0| 75 6d 69 6e 61 6e 63 65 | 20 74 68 61 74 20 77 69 |uminance| that wi|
|000055b0| 6c 6c 20 62 65 20 70 72 | 6f 64 75 63 65 64 2e 20 |ll be pr|oduced. |
|000055c0| 53 75 70 70 6c 79 69 6e | 67 20 61 6e 20 69 6c 6c |Supplyin|g an ill|
|000055d0| 65 67 61 6c 20 65 6e 74 | 72 79 20 76 61 6c 75 65 |egal ent|ry value|
|000055e0| 20 72 65 73 75 6c 74 73 | 20 69 6e 20 61 0d 72 65 | results| in a.re|
|000055f0| 74 75 72 6e 65 64 20 76 | 61 6c 75 65 20 6f 66 20 |turned v|alue of |
|00005600| 2d 49 4e 46 2e 0d 2a 2f | 0d 7b 0d 09 64 6f 75 62 |-INF..*/|.{..doub|
|00005610| 6c 65 20 76 3b 0d 73 74 | 61 74 69 63 20 4c 75 6d |le v;.st|atic Lum|
|00005620| 69 6e 61 6e 63 65 52 65 | 63 6f 72 64 20 2a 4c 50 |inanceRe|cord *LP|
|00005630| 53 61 76 65 3b 0d 4c 50 | 53 61 76 65 3d 4c 50 3b |Save;.LP|Save=LP;|
|00005640| 0d 09 76 3d 47 65 74 56 | 28 64 65 76 69 63 65 2c |..v=GetV|(device,|
|00005650| 4c 50 2c 74 68 65 45 6e | 74 72 79 29 3b 0d 61 73 |LP,theEn|try);.as|
|00005660| 73 65 72 74 28 4c 50 3d | 3d 4c 50 53 61 76 65 29 |sert(LP=|=LPSave)|
|00005670| 3b 0d 09 72 65 74 75 72 | 6e 20 56 54 6f 4c 28 4c |;..retur|n VToL(L|
|00005680| 50 2c 76 29 3b 0d 7d 0d | 0d 64 6f 75 62 6c 65 20 |P,v);.}.|.double |
|00005690| 47 65 74 56 28 47 44 48 | 61 6e 64 6c 65 20 64 65 |GetV(GDH|andle de|
|000056a0| 76 69 63 65 2c 4c 75 6d | 69 6e 61 6e 63 65 52 65 |vice,Lum|inanceRe|
|000056b0| 63 6f 72 64 20 2a 4c 50 | 2c 69 6e 74 20 74 68 65 |cord *LP|,int the|
|000056c0| 45 6e 74 72 79 29 0d 2f | 2a 0d 49 66 20 64 65 76 |Entry)./|*.If dev|
|000056d0| 69 63 65 20 69 73 20 6e | 6f 74 20 4e 55 4c 4c 20 |ice is n|ot NULL |
|000056e0| 28 61 6e 64 20 68 61 73 | 20 61 20 64 72 69 76 65 |(and has| a drive|
|000056f0| 72 29 20 74 68 65 6e 20 | 65 78 61 6d 69 6e 65 73 |r) then |examines|
|00005700| 20 6f 6e 65 20 65 6e 74 | 72 79 20 69 6e 20 74 68 | one ent|ry in th|
|00005710| 65 20 61 63 74 75 61 6c | 20 63 6c 75 74 2c 20 6f |e actual| clut, o|
|00005720| 74 68 65 72 77 69 73 65 | 0d 65 78 61 6d 69 6e 65 |therwise|.examine|
|00005730| 73 20 74 68 65 20 43 6f | 6c 6f 72 53 70 65 63 20 |s the Co|lorSpec |
|00005740| 74 61 62 6c 65 20 63 6f | 6e 74 61 69 6e 65 64 20 |table co|ntained |
|00005750| 69 6e 20 2a 4c 50 2c 20 | 61 6e 64 20 69 6e 20 65 |in *LP, |and in e|
|00005760| 69 74 68 65 72 20 63 61 | 73 65 20 72 65 74 75 72 |ither ca|se retur|
|00005770| 6e 73 20 74 68 65 20 56 | 0d 74 68 61 74 20 77 69 |ns the V|.that wi|
|00005780| 6c 6c 20 62 65 20 70 72 | 6f 64 75 63 65 64 2e 20 |ll be pr|oduced. |
|00005790| 53 75 70 70 6c 79 69 6e | 67 20 61 6e 20 69 6c 6c |Supplyin|g an ill|
|000057a0| 65 67 61 6c 20 65 6e 74 | 72 79 20 76 61 6c 75 65 |egal ent|ry value|
|000057b0| 20 72 65 73 75 6c 74 73 | 20 69 6e 20 61 20 72 65 | results| in a re|
|000057c0| 74 75 72 6e 65 64 0d 76 | 61 6c 75 65 20 6f 66 20 |turned.v|alue of |
|000057d0| 2d 49 4e 46 2e 0d 2a 2f | 0d 7b 0d 09 52 47 42 43 |-INF..*/|.{..RGBC|
|000057e0| 6f 6c 6f 72 20 2a 6d 79 | 52 47 42 50 74 72 3d 4e |olor *my|RGBPtr=N|
|000057f0| 55 4c 4c 3b 0d 09 43 6f | 6c 6f 72 53 70 65 63 20 |ULL;..Co|lorSpec |
|00005800| 74 61 62 6c 65 5b 32 35 | 36 5d 3b 0d 09 64 6f 75 |table[25|6];..dou|
|00005810| 62 6c 65 20 56 3b 0d 09 | 69 6e 74 20 65 72 72 6f |ble V;..|int erro|
|00005820| 72 3d 30 3b 0d 09 0d 09 | 69 66 28 64 65 76 69 63 |r=0;....|if(devic|
|00005830| 65 20 21 3d 20 4e 55 4c | 4c 20 26 26 20 28 2a 64 |e != NUL|L && (*d|
|00005840| 65 76 69 63 65 29 2d 3e | 67 64 52 65 66 4e 75 6d |evice)->|gdRefNum|
|00005850| 21 3d 30 29 20 7b 0d 09 | 09 69 66 28 74 68 65 45 |!=0) {..|.if(theE|
|00005860| 6e 74 72 79 3c 30 20 7c | 7c 20 74 68 65 45 6e 74 |ntry<0 ||| theEnt|
|00005870| 72 79 3e 3d 47 44 43 4c | 55 54 53 49 5a 45 28 64 |ry>=GDCL|UTSIZE(d|
|00005880| 65 76 69 63 65 29 29 7b | 0d 09 09 09 50 72 69 6e |evice)){|....Prin|
|00005890| 74 66 45 78 69 74 28 22 | 47 65 74 4c 75 6d 69 6e |tfExit("|GetLumin|
|000058a0| 61 6e 63 65 3a 20 69 6c | 6c 65 67 61 6c 20 65 6e |ance: il|legal en|
|000058b0| 74 72 79 20 25 64 5c 6e | 22 2c 74 68 65 45 6e 74 |try %d\n|",theEnt|
|000058c0| 72 79 29 3b 0d 09 09 7d | 0d 09 09 61 73 73 65 72 |ry);...}|...asser|
|000058d0| 74 28 47 44 43 4c 55 54 | 53 49 5a 45 28 64 65 76 |t(GDCLUT|SIZE(dev|
|000058e0| 69 63 65 29 3c 3d 32 35 | 36 29 3b 0d 09 09 65 72 |ice)<=25|6);...er|
|000058f0| 72 6f 72 3d 47 44 47 65 | 74 45 6e 74 72 69 65 73 |ror=GDGe|tEntries|
|00005900| 28 64 65 76 69 63 65 2c | 30 2c 47 44 43 4c 55 54 |(device,|0,GDCLUT|
|00005910| 53 49 5a 45 28 64 65 76 | 69 63 65 29 2d 31 2c 74 |SIZE(dev|ice)-1,t|
|00005920| 61 62 6c 65 29 3b 0d 09 | 09 69 66 28 65 72 72 6f |able);..|.if(erro|
|00005930| 72 29 7b 0d 09 09 09 50 | 72 69 6e 74 66 45 78 69 |r){....P|rintfExi|
|00005940| 74 28 22 47 65 74 4c 75 | 6d 69 6e 61 6e 63 65 3a |t("GetLu|minance:|
|00005950| 20 47 44 47 65 74 45 6e | 74 72 69 65 73 20 65 72 | GDGetEn|tries er|
|00005960| 72 6f 72 20 25 64 5c 30 | 30 37 22 2c 65 72 72 6f |ror %d\0|07",erro|
|00005970| 72 29 3b 0d 09 09 7d 0d | 09 09 6d 79 52 47 42 50 |r);...}.|..myRGBP|
|00005980| 74 72 3d 26 74 61 62 6c | 65 5b 74 68 65 45 6e 74 |tr=&tabl|e[theEnt|
|00005990| 72 79 5d 2e 72 67 62 3b | 0d 09 7d 65 6c 73 65 7b |ry].rgb;|..}else{|
|000059a0| 0d 09 09 69 66 28 4c 50 | 21 3d 4e 55 4c 4c 20 26 |...if(LP|!=NULL &|
|000059b0| 26 20 74 68 65 45 6e 74 | 72 79 3e 3d 30 20 26 26 |& theEnt|ry>=0 &&|
|000059c0| 20 74 68 65 45 6e 74 72 | 79 3c 43 4f 4c 4f 52 53 | theEntr|y<COLORS|
|000059d0| 29 20 0d 09 09 09 6d 79 | 52 47 42 50 74 72 3d 26 |) ....my|RGBPtr=&|
|000059e0| 4c 50 2d 3e 74 61 62 6c | 65 5b 74 68 65 45 6e 74 |LP->tabl|e[theEnt|
|000059f0| 72 79 5d 2e 72 67 62 3b | 0d 09 7d 0d 09 69 66 28 |ry].rgb;|..}..if(|
|00005a00| 6d 79 52 47 42 50 74 72 | 20 3d 3d 20 4e 55 4c 4c |myRGBPtr| == NULL|
|00005a10| 29 20 72 65 74 75 72 6e | 20 2d 49 4e 46 3b 0d 09 |) return| -INF;..|
|00005a20| 56 20 3d 20 4c 50 2d 3e | 72 2a 28 6d 79 52 47 42 |V = LP->|r*(myRGB|
|00005a30| 50 74 72 2d 3e 72 65 64 | 3e 3e 38 29 3b 0d 09 56 |Ptr->red|>>8);..V|
|00005a40| 20 2b 3d 20 4c 50 2d 3e | 67 2a 28 6d 79 52 47 42 | += LP->|g*(myRGB|
|00005a50| 50 74 72 2d 3e 67 72 65 | 65 6e 3e 3e 38 29 3b 0d |Ptr->gre|en>>8);.|
|00005a60| 09 56 20 2b 3d 20 4c 50 | 2d 3e 62 2a 28 6d 79 52 |.V += LP|->b*(myR|
|00005a70| 47 42 50 74 72 2d 3e 62 | 6c 75 65 3e 3e 38 29 3b |GBPtr->b|lue>>8);|
|00005a80| 0d 09 72 65 74 75 72 6e | 20 56 3b 0d 7d 0d 0d 76 |..return| V;.}..v|
|00005a90| 6f 69 64 20 4c 6f 61 64 | 4c 75 6d 69 6e 61 6e 63 |oid Load|Luminanc|
|00005aa0| 65 73 28 47 44 48 61 6e | 64 6c 65 20 64 65 76 69 |es(GDHan|dle devi|
|00005ab0| 63 65 2c 20 4c 75 6d 69 | 6e 61 6e 63 65 52 65 63 |ce, Lumi|nanceRec|
|00005ac0| 6f 72 64 20 2a 4c 50 2c | 0d 09 69 6e 74 20 66 69 |ord *LP,|..int fi|
|00005ad0| 72 73 74 45 6e 74 72 79 | 2c 20 69 6e 74 20 6c 61 |rstEntry|, int la|
|00005ae0| 73 74 45 6e 74 72 79 29 | 0d 2f 2a 0d 54 68 69 73 |stEntry)|./*.This|
|00005af0| 20 6a 75 73 74 20 63 61 | 6c 6c 73 20 47 44 53 65 | just ca|lls GDSe|
|00005b00| 74 45 6e 74 72 69 65 73 | 28 29 20 6f 72 20 47 44 |tEntries|() or GD|
|00005b10| 44 69 72 65 63 74 53 65 | 74 45 6e 74 72 69 65 73 |DirectSe|tEntries|
|00005b20| 28 29 20 74 6f 20 6c 6f | 61 64 20 79 6f 75 72 20 |() to lo|ad your |
|00005b30| 43 6f 6c 6f 72 53 70 65 | 63 0d 74 61 62 6c 65 20 |ColorSpe|c.table |
|00005b40| 69 6e 74 6f 20 74 68 65 | 20 63 6c 75 74 20 6f 66 |into the| clut of|
|00005b50| 20 79 6f 75 72 20 73 63 | 72 65 65 6e 20 64 65 76 | your sc|reen dev|
|00005b60| 69 63 65 2e 20 49 74 20 | 69 73 20 68 65 72 65 20 |ice. It |is here |
|00005b70| 73 69 6d 70 6c 79 20 74 | 6f 20 70 72 6f 76 69 64 |simply t|o provid|
|00005b80| 65 20 61 0d 63 6f 73 6d | 65 74 69 63 20 6d 61 74 |e a.cosm|etic mat|
|00005b90| 63 68 20 74 6f 20 74 68 | 65 20 63 61 6c 6c 20 74 |ch to th|e call t|
|00005ba0| 6f 20 53 65 74 4c 75 6d | 69 6e 61 6e 63 65 73 28 |o SetLum|inances(|
|00005bb0| 29 2c 20 66 6f 72 20 77 | 68 69 63 68 20 6c 6f 61 |), for w|hich loa|
|00005bc0| 64 69 6e 67 20 74 68 65 | 20 63 6c 75 74 20 69 73 |ding the| clut is|
|00005bd0| 0d 6f 70 74 69 6f 6e 61 | 6c 2e 20 4e 6f 74 65 3a |.optiona|l. Note:|
|00005be0| 20 69 66 20 79 6f 75 20 | 70 72 65 66 65 72 2c 20 | if you |prefer, |
|00005bf0| 69 6e 73 74 65 61 64 20 | 6f 66 20 4c 50 20 79 6f |instead |of LP yo|
|00005c00| 75 20 6d 61 79 20 73 65 | 6e 64 20 6a 75 73 74 20 |u may se|nd just |
|00005c10| 74 68 65 20 61 64 64 72 | 65 73 73 20 6f 66 20 61 |the addr|ess of a|
|00005c20| 0d 43 6f 6c 6f 72 53 70 | 65 63 20 74 61 62 6c 65 |.ColorSp|ec table|
|00005c30| 2c 20 63 61 73 74 20 74 | 6f 20 28 4c 75 6d 69 6e |, cast t|o (Lumin|
|00005c40| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 29 2c 20 73 |anceReco|rd *), s|
|00005c50| 69 6e 63 65 20 61 20 4c | 75 6d 69 6e 61 6e 63 65 |ince a L|uminance|
|00005c60| 52 65 63 6f 72 64 20 62 | 65 67 69 6e 73 0d 77 69 |Record b|egins.wi|
|00005c70| 74 68 20 61 20 43 6f 6c | 6f 72 53 70 65 63 20 74 |th a Col|orSpec t|
|00005c80| 61 62 6c 65 2e 0d 2a 2f | 0d 7b 0d 09 69 6e 74 20 |able..*/|.{..int |
|00005c90| 65 72 72 6f 72 3b 0d 09 | 73 68 6f 72 74 20 69 73 |error;..|short is|
|00005ca0| 47 72 61 79 2c 69 3b 0d | 09 52 47 42 43 6f 6c 6f |Gray,i;.|.RGBColo|
|00005cb0| 72 20 2a 52 47 42 50 74 | 72 3b 0d 09 43 6f 6c 6f |r *RGBPt|r;..Colo|
|00005cc0| 72 53 70 65 63 20 74 61 | 62 6c 65 5b 32 35 36 5d |rSpec ta|ble[256]|
|00005cd0| 2c 2a 74 61 62 6c 65 50 | 74 72 3b 0d 0d 09 69 66 |,*tableP|tr;...if|
|00005ce0| 28 64 65 76 69 63 65 3d | 3d 4e 55 4c 4c 20 7c 7c |(device=|=NULL |||
|00005cf0| 20 28 2a 64 65 76 69 63 | 65 29 2d 3e 67 64 52 65 | (*devic|e)->gdRe|
|00005d00| 66 4e 75 6d 3d 3d 30 29 | 72 65 74 75 72 6e 3b 09 |fNum==0)|return;.|
|00005d10| 2f 2f 20 6e 6f 20 64 65 | 76 69 63 65 2c 20 6f 72 |// no de|vice, or|
|00005d20| 20 6e 6f 20 64 65 76 69 | 63 65 20 64 72 69 76 65 | no devi|ce drive|
|00005d30| 72 0d 09 69 73 47 72 61 | 79 3d 21 54 65 73 74 44 |r..isGra|y=!TestD|
|00005d40| 65 76 69 63 65 41 74 74 | 72 69 62 75 74 65 28 64 |eviceAtt|ribute(d|
|00005d50| 65 76 69 63 65 2c 67 64 | 44 65 76 54 79 70 65 29 |evice,gd|DevType)|
|00005d60| 3b 0d 09 69 66 28 69 73 | 47 72 61 79 29 7b 0d 09 |;..if(is|Gray){..|
|00005d70| 09 66 6f 72 28 69 3d 66 | 69 72 73 74 45 6e 74 72 |.for(i=f|irstEntr|
|00005d80| 79 3b 69 3c 3d 6c 61 73 | 74 45 6e 74 72 79 3b 69 |y;i<=las|tEntry;i|
|00005d90| 2b 2b 29 7b 0d 09 09 09 | 52 47 42 50 74 72 3d 26 |++){....|RGBPtr=&|
|00005da0| 74 61 62 6c 65 5b 69 5d | 2e 72 67 62 3b 0d 09 09 |table[i]|.rgb;...|
|00005db0| 09 52 47 42 50 74 72 2d | 3e 72 65 64 3d 52 47 42 |.RGBPtr-|>red=RGB|
|00005dc0| 50 74 72 2d 3e 67 72 65 | 65 6e 3d 52 47 42 50 74 |Ptr->gre|en=RGBPt|
|00005dd0| 72 2d 3e 62 6c 75 65 3d | 4c 50 2d 3e 74 61 62 6c |r->blue=|LP->tabl|
|00005de0| 65 5b 69 5d 2e 72 67 62 | 2e 67 72 65 65 6e 3b 0d |e[i].rgb|.green;.|
|00005df0| 09 09 7d 0d 09 09 74 61 | 62 6c 65 50 74 72 3d 74 |..}...ta|blePtr=t|
|00005e00| 61 62 6c 65 3b 0d 09 7d | 65 6c 73 65 20 74 61 62 |able;..}|else tab|
|00005e10| 6c 65 50 74 72 3d 4c 50 | 2d 3e 74 61 62 6c 65 3b |lePtr=LP|->table;|
|00005e20| 0d 09 73 77 69 74 63 68 | 28 28 2a 64 65 76 69 63 |..switch|((*devic|
|00005e30| 65 29 2d 3e 67 64 54 79 | 70 65 29 7b 0d 09 63 61 |e)->gdTy|pe){..ca|
|00005e40| 73 65 20 66 69 78 65 64 | 54 79 70 65 3a 0d 09 09 |se fixed|Type:...|
|00005e50| 70 72 69 6e 74 66 28 22 | 4c 6f 61 64 4c 75 6d 69 |printf("|LoadLumi|
|00005e60| 6e 61 6e 63 65 73 3a 20 | 74 68 69 73 20 64 65 76 |nances: |this dev|
|00005e70| 69 63 65 20 68 61 73 20 | 61 20 66 69 78 65 64 20 |ice has |a fixed |
|00005e80| 43 4c 55 54 2e 5c 6e 22 | 29 3b 0d 09 09 72 65 74 |CLUT.\n"|);...ret|
|00005e90| 75 72 6e 3b 0d 09 63 61 | 73 65 20 63 6c 75 74 54 |urn;..ca|se clutT|
|00005ea0| 79 70 65 3a 0d 09 09 65 | 72 72 6f 72 3d 47 44 53 |ype:...e|rror=GDS|
|00005eb0| 65 74 45 6e 74 72 69 65 | 73 28 64 65 76 69 63 65 |etEntrie|s(device|
|00005ec0| 2c 66 69 72 73 74 45 6e | 74 72 79 2c 6c 61 73 74 |,firstEn|try,last|
|00005ed0| 45 6e 74 72 79 2d 66 69 | 72 73 74 45 6e 74 72 79 |Entry-fi|rstEntry|
|00005ee0| 2c 74 61 62 6c 65 50 74 | 72 2b 66 69 72 73 74 45 |,tablePt|r+firstE|
|00005ef0| 6e 74 72 79 29 3b 0d 09 | 09 62 72 65 61 6b 3b 0d |ntry);..|.break;.|
|00005f00| 09 63 61 73 65 20 64 69 | 72 65 63 74 54 79 70 65 |.case di|rectType|
|00005f10| 3a 0d 09 09 65 72 72 6f | 72 3d 47 44 44 69 72 65 |:...erro|r=GDDire|
|00005f20| 63 74 53 65 74 45 6e 74 | 72 69 65 73 28 64 65 76 |ctSetEnt|ries(dev|
|00005f30| 69 63 65 2c 66 69 72 73 | 74 45 6e 74 72 79 2c 6c |ice,firs|tEntry,l|
|00005f40| 61 73 74 45 6e 74 72 79 | 2d 66 69 72 73 74 45 6e |astEntry|-firstEn|
|00005f50| 74 72 79 2c 74 61 62 6c | 65 50 74 72 2b 66 69 72 |try,tabl|ePtr+fir|
|00005f60| 73 74 45 6e 74 72 79 29 | 3b 0d 09 09 62 72 65 61 |stEntry)|;...brea|
|00005f70| 6b 3b 0d 09 7d 0d 09 69 | 66 28 65 72 72 6f 72 29 |k;..}..i|f(error)|
|00005f80| 20 70 72 69 6e 74 66 28 | 22 5c 30 30 37 4c 6f 61 | printf(|"\007Loa|
|00005f90| 64 4c 75 6d 69 6e 61 6e | 63 65 73 3a 20 65 72 72 |dLuminan|ces: err|
|00005fa0| 6f 72 20 25 64 5c 6e 22 | 2c 65 72 72 6f 72 29 3b |or %d\n"|,error);|
|00005fb0| 0d 7d 0d 0d 64 6f 75 62 | 6c 65 20 4c 54 6f 4c 28 |.}..doub|le LToL(|
|00005fc0| 4c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |Luminanc|eRecord |
|00005fd0| 2a 4c 50 2c 64 6f 75 62 | 6c 65 20 4c 29 0d 7b 0d |*LP,doub|le L).{.|
|00005fe0| 09 69 66 28 4c 20 3e 20 | 4c 50 2d 3e 4c 4d 61 78 |.if(L > |LP->LMax|
|00005ff0| 29 20 72 65 74 75 72 6e | 20 4c 50 2d 3e 4c 4d 61 |) return| LP->LMa|
|00006000| 78 3b 0d 09 69 66 28 4c | 20 3c 20 4c 50 2d 3e 4c |x;..if(L| < LP->L|
|00006010| 4d 69 6e 29 20 72 65 74 | 75 72 6e 20 4c 50 2d 3e |Min) ret|urn LP->|
|00006020| 4c 4d 69 6e 3b 0d 09 72 | 65 74 75 72 6e 20 4c 3b |LMin;..r|eturn L;|
|00006030| 0d 7d 0d 0d 64 6f 75 62 | 6c 65 20 56 54 6f 4c 28 |.}..doub|le VToL(|
|00006040| 4c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |Luminanc|eRecord |
|00006050| 2a 4c 50 2c 64 6f 75 62 | 6c 65 20 56 29 0d 2f 2a |*LP,doub|le V)./*|
|00006060| 0d 52 65 74 75 72 6e 20 | 74 68 65 20 6c 75 6d 69 |.Return |the lumi|
|00006070| 6e 61 6e 63 65 20 74 68 | 61 74 20 77 6f 75 6c 64 |nance th|at would|
|00006080| 20 72 65 73 75 6c 74 20 | 66 72 6f 6d 20 61 20 6e | result |from a n|
|00006090| 6f 6d 69 6e 61 6c 20 76 | 6f 6c 74 61 67 65 2e 0d |ominal v|oltage..|
|000060a0| 2a 2f 0d 7b 0d 61 73 73 | 65 72 74 28 4c 50 2d 3e |*/.{.ass|ert(LP->|
|000060b0| 64 61 63 53 69 7a 65 3d | 3d 38 29 3b 0d 09 72 65 |dacSize=|=8);..re|
|000060c0| 74 75 72 6e 20 46 69 78 | 54 6f 44 6f 75 62 6c 65 |turn Fix|ToDouble|
|000060d0| 28 5f 56 54 6f 4c 28 4c | 50 2c 44 6f 75 62 6c 65 |(_VToL(L|P,Double|
|000060e0| 54 6f 46 69 78 28 56 29 | 29 29 3b 0d 7d 0d 0d 46 |ToFix(V)|));.}..F|
|000060f0| 49 58 45 44 20 5f 56 54 | 6f 4c 28 4c 75 6d 69 6e |IXED _VT|oL(Lumin|
|00006100| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 2c 46 |anceReco|rd *LP,F|
|00006110| 49 58 45 44 20 5f 56 29 | 0d 2f 2a 0d 52 65 74 75 |IXED _V)|./*.Retu|
|00006120| 72 6e 20 74 68 65 20 6c | 75 6d 69 6e 61 6e 63 65 |rn the l|uminance|
|00006130| 20 74 68 61 74 20 77 6f | 75 6c 64 20 72 65 73 75 | that wo|uld resu|
|00006140| 6c 74 20 66 72 6f 6d 20 | 61 20 6e 6f 6d 69 6e 61 |lt from |a nomina|
|00006150| 6c 20 76 6f 6c 74 61 67 | 65 2e 0d 2a 2f 0d 7b 0d |l voltag|e..*/.{.|
|00006160| 09 72 65 67 69 73 74 65 | 72 20 69 6e 74 20 69 3b |.registe|r int i;|
|00006170| 0d 09 72 65 67 69 73 74 | 65 72 20 4c 75 6d 69 6e |..regist|er Lumin|
|00006180| 61 6e 63 65 54 61 62 6c | 65 20 2a 4c 54 3b 0d 09 |anceTabl|e *LT;..|
|00006190| 72 65 67 69 73 74 65 72 | 20 46 49 58 45 44 20 5f |register| FIXED _|
|000061a0| 64 69 3b 0d 09 64 6f 75 | 62 6c 65 20 4c 46 2c 56 |di;..dou|ble LF,V|
|000061b0| 46 3b 0d 09 0d 09 4c 54 | 3d 26 4c 50 2d 3e 4c 3b |F;....LT|=&LP->L;|
|000061c0| 0d 09 69 66 28 4c 54 2d | 3e 65 78 69 73 74 73 3d |..if(LT-|>exists=|
|000061d0| 3d 6c 75 6d 69 6e 61 6e | 63 65 53 65 74 29 7b 0d |=luminan|ceSet){.|
|000061e0| 09 09 5f 64 69 3d 46 69 | 78 44 69 76 28 5f 56 2d |.._di=Fi|xDiv(_V-|
|000061f0| 4c 54 2d 3e 5f 56 4d 69 | 6e 2c 4c 54 2d 3e 5f 64 |LT->_VMi|n,LT->_d|
|00006200| 56 29 3b 0d 09 09 69 3d | 46 69 78 54 6f 4c 6f 6e |V);...i=|FixToLon|
|00006210| 67 28 5f 64 69 29 3b 0d | 09 09 5f 64 69 20 2d 3d |g(_di);.|.._di -=|
|00006220| 20 4c 6f 6e 67 54 6f 46 | 69 78 28 69 29 3b 0d 09 | LongToF|ix(i);..|
|00006230| 09 69 66 28 69 3c 30 29 | 72 65 74 75 72 6e 20 4c |.if(i<0)|return L|
|00006240| 54 2d 3e 5f 4c 75 5b 30 | 5d 3b 0d 09 09 69 66 28 |T->_Lu[0|];...if(|
|00006250| 69 3e 3d 4c 55 4d 49 4e | 41 4e 43 45 53 5f 49 4e |i>=LUMIN|ANCES_IN|
|00006260| 5f 54 41 42 4c 45 2d 31 | 29 72 65 74 75 72 6e 20 |_TABLE-1|)return |
|00006270| 4c 54 2d 3e 5f 4c 75 5b | 4c 55 4d 49 4e 41 4e 43 |LT->_Lu[|LUMINANC|
|00006280| 45 53 5f 49 4e 5f 54 41 | 42 4c 45 2d 31 5d 3b 0d |ES_IN_TA|BLE-1];.|
|00006290| 09 09 72 65 74 75 72 6e | 20 4c 54 2d 3e 5f 4c 75 |..return| LT->_Lu|
|000062a0| 5b 69 5d 2b 46 69 78 4d | 75 6c 28 5f 64 69 2c 4c |[i]+FixM|ul(_di,L|
|000062b0| 54 2d 3e 5f 4c 75 5b 69 | 2b 31 5d 2d 4c 54 2d 3e |T->_Lu[i|+1]-LT->|
|000062c0| 5f 4c 75 5b 69 5d 29 3b | 0d 09 7d 0d 09 56 46 3d |_Lu[i]);|..}..VF=|
|000062d0| 46 69 78 54 6f 44 6f 75 | 62 6c 65 28 5f 56 29 3b |FixToDou|ble(_V);|
|000062e0| 0d 09 69 66 28 4c 50 2d | 3e 70 6f 77 65 72 45 72 |..if(LP-|>powerEr|
|000062f0| 72 6f 72 20 3c 20 32 2e | 30 2a 4c 50 2d 3e 70 6f |ror < 2.|0*LP->po|
|00006300| 6c 79 6e 6f 6d 69 61 6c | 45 72 72 6f 72 29 20 4c |lynomial|Error) L|
|00006310| 46 3d 56 54 6f 4c 50 6f | 77 65 72 28 4c 50 2c 56 |F=VToLPo|wer(LP,V|
|00006320| 46 29 3b 0d 09 65 6c 73 | 65 20 4c 46 3d 56 54 6f |F);..els|e LF=VTo|
|00006330| 4c 50 6f 6c 79 6e 6f 6d | 69 61 6c 28 4c 50 2c 56 |LPolynom|ial(LP,V|
|00006340| 46 29 3b 0d 09 72 65 74 | 75 72 6e 20 44 6f 75 62 |F);..ret|urn Doub|
|00006350| 6c 65 54 6f 46 69 78 28 | 4c 46 29 3b 0d 7d 0d 0d |leToFix(|LF);.}..|
|00006360| 64 6f 75 62 6c 65 20 4c | 54 6f 56 28 4c 75 6d 69 |double L|ToV(Lumi|
|00006370| 6e 61 6e 63 65 52 65 63 | 6f 72 64 20 2a 4c 50 2c |nanceRec|ord *LP,|
|00006380| 64 6f 75 62 6c 65 20 4c | 29 0d 7b 0d 09 72 65 74 |double L|).{..ret|
|00006390| 75 72 6e 20 46 69 78 54 | 6f 44 6f 75 62 6c 65 28 |urn FixT|oDouble(|
|000063a0| 5f 4c 54 6f 56 28 4c 50 | 2c 44 6f 75 62 6c 65 54 |_LToV(LP|,DoubleT|
|000063b0| 6f 46 69 78 28 4c 29 29 | 29 3b 0d 7d 0d 0d 46 49 |oFix(L))|);.}..FI|
|000063c0| 58 45 44 20 5f 4c 54 6f | 56 28 4c 75 6d 69 6e 61 |XED _LTo|V(Lumina|
|000063d0| 6e 63 65 52 65 63 6f 72 | 64 20 2a 4c 50 2c 46 49 |nceRecor|d *LP,FI|
|000063e0| 58 45 44 20 5f 4c 75 29 | 0d 2f 2a 0d 4e 65 77 2c |XED _Lu)|./*.New,|
|000063f0| 20 66 61 73 74 65 72 20 | 76 65 72 73 69 6f 6e 20 | faster |version |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.