]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/html/man/TIFFcolor.3tiff.html
fix wxGTK1 compilation after wxTextEntry DoGetValue() change
[wxWidgets.git] / src / tiff / html / man / TIFFcolor.3tiff.html
1 <!-- Creator : groff version 1.18.1 -->
2 <!-- CreationDate: Mon Mar 13 18:03:08 2006 -->
3 <html>
4 <head>
5 <meta name="generator" content="groff -Thtml, see www.gnu.org">
6 <meta name="Content-Style" content="text/css">
7 <title>COLOR</title>
8 </head>
9 <body>
10
11 <h1 align=center>COLOR</h1>
12 <a href="#NAME">NAME</a><br>
13 <a href="#SYNOPSIS">SYNOPSIS</a><br>
14 <a href="#DESCRIPTION">DESCRIPTION</a><br>
15 <a href="#SEE ALSO">SEE ALSO</a><br>
16
17 <hr>
18 <a name="NAME"></a>
19 <h2>NAME</h2>
20 <!-- INDENTATION -->
21 <table width="100%" border=0 rules="none" frame="void"
22 cols="2" cellspacing="0" cellpadding="0">
23 <tr valign="top" align="left">
24 <td width="8%"></td>
25 <td width="91%">
26 <p>TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit,
27 TIFFCIELabToXYZ, TIFFXYZToRGB &minus; color conversion
28 routines.</p>
29 </td>
30 </table>
31 <a name="SYNOPSIS"></a>
32 <h2>SYNOPSIS</h2>
33 <!-- INDENTATION -->
34 <table width="100%" border=0 rules="none" frame="void"
35 cols="2" cellspacing="0" cellpadding="0">
36 <tr valign="top" align="left">
37 <td width="8%"></td>
38 <td width="91%">
39 <p><b>#include &lt;tiffio.h&gt;</b></p>
40 <!-- INDENTATION -->
41 <p><b>int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB
42 *</b><i>ycbcr</i><b>, float *</b><i>luma</i><b>, float
43 *</b><i>refBlackWhite&quot;</i><b>);&quot;<br>
44 void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *</b><i>ycbcr</i><b>,
45 uint32</b> <i>Y</i><b>, int32</b> <i>Cb</i><b>, int32</b>
46 <i>Cr</i><b>, uint32 *</b><i>R</i><b>, uint32
47 *</b><i>G</i><b>, uint32 *</b><i>B</i> <b>);</b></p>
48 <!-- INDENTATION -->
49 <p><b>int TIFFCIELabToRGBInit(TIFFCIELabToRGB
50 *</b><i>cielab</i><b>, TIFFDisplay *</b><i>display</i><b>,
51 float *</b><i>refWhite</i><b>);<br>
52 void TIFFCIELabToXYZ(TIFFCIELabToRGB *</b><i>cielab</i><b>,
53 uint32</b> <i>L</i><b>, int32</b> <i>a</i><b>, int32</b>
54 <i>b</i><b>, float *</b><i>X</i><b>, float *</b><i>Y</i><b>,
55 float *</b><i>Z</i><b>);<br>
56 void TIFFXYZToRGB(TIFFCIELabToRGB *</b><i>cielab</i><b>,
57 float</b> <i>X</i><b>, float</b> <i>Y</i><b>, float</b>
58 <i>Z&quot;</i><b>,</b><i>uint32</i><b>*&quot;</b><i>R</i><b>,
59 uint32 *</b><i>G</i><b>, uint32 *</b><i>B</i><b>);</b></p>
60 </td>
61 </table>
62 <a name="DESCRIPTION"></a>
63 <h2>DESCRIPTION</h2>
64 <!-- INDENTATION -->
65 <table width="100%" border=0 rules="none" frame="void"
66 cols="2" cellspacing="0" cellpadding="0">
67 <tr valign="top" align="left">
68 <td width="8%"></td>
69 <td width="91%">
70 <p>TIFF supports several color spaces for images stored in
71 that format. There is usually a problem of application to
72 handle the data properly and convert between different
73 colorspaces for displaying and printing purposes. To
74 simplify this task libtiff implements several color
75 conversion routines itself. In particular, these routines
76 used in <b>TIFFRGBAImage(3TIFF)</b> interface.</p>
77 <!-- INDENTATION -->
78 <p><b>TIFFYCbCrToRGBInit()</b> used to initialize
79 <i>YCbCr</i> to <i>RGB</i> conversion state. Allocating and
80 freeing of the <i>ycbcr</i> structure belongs to programmer.
81 <i>TIFFYCbCrToRGB</i> defined in <b>tiffio.h</b> as</p>
82 </td>
83 </table>
84 <!-- INDENTATION -->
85 <table width="100%" border=0 rules="none" frame="void"
86 cols="2" cellspacing="0" cellpadding="0">
87 <tr valign="top" align="left">
88 <td width="17%"></td>
89 <td width="82%">
90 <pre>typedef struct { /* YCbCr-&gt;RGB support */
91 TIFFRGBValue* clamptab; /* range clamping table */
92 </pre>
93 </td>
94 </table>
95 <!-- TABS -->
96
97 <table width="100%" border=0 rules="none" frame="void"
98 cols="5" cellspacing="0" cellpadding="0">
99 <tr valign="top" align="left">
100
101 <p>int*</p>
102 <td width="28%"></td>
103 <td width="-3%"></td>
104 <td width="12%"></td>
105 <td width="6%">
106
107 <p>Cr_r_tab;<br>
108 int*</p>
109 </td>
110 <td width="56%">
111 </td>
112 <tr valign="top" align="left">
113 <td width="28%"></td>
114 <td width="-3%"></td>
115 <td width="12%"></td>
116 <td width="6%">
117
118 <p>Cb_b_tab;<br>
119 int32*</p>
120 </td>
121 <td width="56%">
122 </td>
123 <tr valign="top" align="left">
124 <td width="28%"></td>
125 <td width="-3%"></td>
126 <td width="12%"></td>
127 <td width="6%">
128
129 <p>Cr_g_tab;<br>
130 int32*</p>
131 </td>
132 <td width="56%">
133 </td>
134 <tr valign="top" align="left">
135 <td width="28%"></td>
136 <td width="-3%"></td>
137 <td width="12%"></td>
138 <td width="6%">
139
140 <p>Cb_g_tab;</p>
141 </td>
142 <td width="56%">
143 </td>
144 </table>
145 <!-- INDENTATION -->
146 <table width="100%" border=0 rules="none" frame="void"
147 cols="2" cellspacing="0" cellpadding="0">
148 <tr valign="top" align="left">
149 <td width="17%"></td>
150 <td width="82%">
151 <p>int32* Y_tab;<br>
152 } TIFFYCbCrToRGB;</p></td>
153 </table>
154 <!-- INDENTATION -->
155 <table width="100%" border=0 rules="none" frame="void"
156 cols="2" cellspacing="0" cellpadding="0">
157 <tr valign="top" align="left">
158 <td width="8%"></td>
159 <td width="91%">
160 <p><i>luma</i> is a float array of three values representing
161 proportions of the red, green and blue in luminance, Y (see
162 section 21 of the TIFF 6.0 specification, where the YCbCr
163 images discussed). <i>TIFFTAG_YCBCRCOEFFICIENTS</i> holds
164 that values in TIFF file. <i>refBlackWhite</i> is a float
165 array of 6 values which specifies a pair of headroom and
166 footroom image data values (codes) for each image component
167 (see section 20 of the TIFF 6.0 specification where the
168 colorinmetry fields discussed).
169 <i>TIFFTAG_REFERENCEBLACKWHITE</i> is responsible for
170 storing these values in TIFF file. Following code snippet
171 should helps to understand the the technique:</p>
172 </td>
173 </table>
174 <!-- INDENTATION -->
175 <table width="100%" border=0 rules="none" frame="void"
176 cols="2" cellspacing="0" cellpadding="0">
177 <tr valign="top" align="left">
178 <td width="17%"></td>
179 <td width="82%">
180 <pre>float *luma, *refBlackWhite;
181 uint16 hs, vs;
182
183 /* Initialize structures */
184 ycbcr = (TIFFYCbCrToRGB*)
185 </pre>
186 </td>
187 </table>
188 <!-- TABS -->
189
190 <table width="100%" border=0 rules="none" frame="void"
191 cols="2" cellspacing="0" cellpadding="0">
192 <tr valign="top" align="left">
193 <td width="24%"></td>
194 <td width="75%">
195
196 <p>_TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB),
197 sizeof(long))</p>
198 </td>
199 <tr valign="top" align="left">
200 <td width="24%"></td>
201 <td width="75%">
202
203 <p>+ 4*256*sizeof(TIFFRGBValue)</p>
204 </td>
205 <tr valign="top" align="left">
206 <td width="24%"></td>
207 <td width="75%">
208
209 <p>+ 2*256*sizeof(int)</p>
210 </td>
211 <tr valign="top" align="left">
212 <td width="24%"></td>
213 <td width="75%">
214
215 <p>+ 3*256*sizeof(int32));</p>
216 </td>
217 </table>
218 <!-- INDENTATION -->
219 <table width="100%" border=0 rules="none" frame="void"
220 cols="2" cellspacing="0" cellpadding="0">
221 <tr valign="top" align="left">
222 <td width="17%"></td>
223 <td width="82%">
224 <p>if (ycbcr == NULL) {<br>
225 TIFFError(&quot;YCbCr-&gt;RGB&quot;,</p></td>
226 </table>
227 <!-- TABS -->
228 <table width="100%" border=0 rules="none" frame="void"
229 cols="4" cellspacing="0" cellpadding="0">
230 <tr valign="top" align="left">
231 <td width="24%"></td>
232 <td width="6%">
233 </td>
234 <td width="6%">
235
236 <p>&quot;No space for YCbCr-&gt;RGB conversion
237 state&quot;);</p>
238 </td>
239 <td width="62%">
240 </td>
241 </table>
242 <!-- INDENTATION -->
243 <table width="100%" border=0 rules="none" frame="void"
244 cols="2" cellspacing="0" cellpadding="0">
245 <tr valign="top" align="left">
246 <td width="17%"></td>
247 <td width="82%">
248 <p>exit(0);<br>
249 }</p>
250 <!-- INDENTATION -->
251 <p>TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS,
252 &amp;luma);<br>
253 TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE,
254 &amp;refBlackWhite);<br>
255 if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) &lt;
256 0)</p></td>
257 </table>
258 <!-- TABS -->
259 <table width="100%" border=0 rules="none" frame="void"
260 cols="2" cellspacing="0" cellpadding="0">
261 <tr valign="top" align="left">
262 <td width="24%"></td>
263 <td width="75%">
264
265 <p>exit(0);</p>
266 </td>
267 </table>
268 <!-- INDENTATION -->
269 <table width="100%" border=0 rules="none" frame="void"
270 cols="2" cellspacing="0" cellpadding="0">
271 <tr valign="top" align="left">
272 <td width="17%"></td>
273 <td width="82%">
274 <p>/* Start conversion */<br>
275 uint32 r, g, b;<br>
276 uint32 Y;<br>
277 int32 Cb, Cr;</p>
278 <!-- INDENTATION -->
279 <p>for each pixel in image</p></td>
280 </table>
281 <!-- TABS -->
282 <table width="100%" border=0 rules="none" frame="void"
283 cols="2" cellspacing="0" cellpadding="0">
284 <tr valign="top" align="left">
285 <td width="24%"></td>
286 <td width="75%">
287
288 <p>TIFFYCbCrtoRGB(img-&gt;ycbcr, Y, Cb, Cr, &amp;r, &amp;g,
289 &amp;b);</p>
290 </td>
291 </table>
292 <!-- INDENTATION -->
293 <table width="100%" border=0 rules="none" frame="void"
294 cols="2" cellspacing="0" cellpadding="0">
295 <tr valign="top" align="left">
296 <td width="17%"></td>
297 <td width="82%">
298 <p>/* Free state structure */<br>
299 _TIFFfree(ycbcr);</p></td>
300 </table>
301 <!-- INDENTATION -->
302 <table width="100%" border=0 rules="none" frame="void"
303 cols="2" cellspacing="0" cellpadding="0">
304 <tr valign="top" align="left">
305 <td width="8%"></td>
306 <td width="91%">
307 <p><b>TIFFCIELabToRGBInit()</b> initializes the <i>CIE
308 L*a*b* 1976</i> to <i>RGB</i> conversion state.
309 <b>TIFFCIELabToRGB</b> defined as</p>
310 </td>
311 </table>
312 <!-- INDENTATION -->
313 <table width="100%" border=0 rules="none" frame="void"
314 cols="2" cellspacing="0" cellpadding="0">
315 <tr valign="top" align="left">
316 <td width="17%"></td>
317 <td width="82%">
318 <pre>#define CIELABTORGB_TABLE_RANGE 1500
319
320 </pre>
321 </td>
322 </table>
323 <!-- TABS -->
324
325 <table width="100%" border=0 rules="none" frame="void"
326 cols="9" cellspacing="0" cellpadding="0">
327 <tr valign="top" align="left">
328 <td width="17%"></td>
329 <td width="6%">
330
331 <p>typedef struct {</p>
332 </td>
333 <td width="6%"></td>
334 <td width="6%"></td>
335 <td width="6%"></td>
336 <td width="6%">
337 </td>
338 <td width="6%">
339
340 <p>/* CIE Lab 1976-&gt;RGB support */</p>
341 </td>
342 <td width="6%"></td>
343 <td width="37%">
344 </td>
345 <tr valign="top" align="left">
346 <td width="17%"></td>
347 <td width="6%">
348 </td>
349 <td width="6%">
350
351 <p>int</p>
352 </td>
353 <td width="6%">
354
355 <p>range;</p>
356 </td>
357 <td width="6%"></td>
358 <td width="6%">
359 </td>
360 <td width="6%">
361
362 <p>/* Size of conversion table */</p>
363 </td>
364 <td width="6%"></td>
365 <td width="37%">
366 </td>
367 <tr valign="top" align="left">
368 <td width="17%"></td>
369 <td width="6%">
370 </td>
371 <td width="6%">
372
373 <p>float</p>
374 </td>
375 <td width="6%"></td>
376 <td width="6%">
377
378 <p>rstep, gstep, bstep;</p>
379 </td>
380 <td width="6%"></td>
381 <td width="6%"></td>
382 <td width="6%"></td>
383 <td width="37%">
384 </td>
385 <tr valign="top" align="left">
386 <td width="17%"></td>
387 <td width="6%">
388 </td>
389 <td width="6%">
390
391 <p>float</p>
392 </td>
393 <td width="6%"></td>
394 <td width="6%">
395
396 <p>X0, Y0, Z0;</p>
397 </td>
398 <td width="6%"></td>
399 <td width="6%"></td>
400 <td width="6%">
401
402 <p>/* Reference white point */</p>
403 </td>
404 <td width="37%">
405 </td>
406 <tr valign="top" align="left">
407 <td width="17%"></td>
408 <td width="6%"></td>
409 <td width="6%">
410
411 <p>TIFFDisplay display;</p>
412 </td>
413 <td width="6%"></td>
414 <td width="6%"></td>
415 <td width="6%"></td>
416 <td width="6%"></td>
417 <td width="6%"></td>
418 <td width="37%">
419 </td>
420 <tr valign="top" align="left">
421 <td width="17%"></td>
422 <td width="6%">
423 </td>
424 <td width="6%">
425
426 <p>float</p>
427 </td>
428 <td width="6%"></td>
429 <td width="6%">
430
431 <p>Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr
432 to r */</p>
433 </td>
434 <td width="6%"></td>
435 <td width="6%"></td>
436 <td width="6%"></td>
437 <td width="37%">
438 </td>
439 <tr valign="top" align="left">
440 <td width="17%"></td>
441 <td width="6%">
442 </td>
443 <td width="6%">
444
445 <p>float</p>
446 </td>
447 <td width="6%"></td>
448 <td width="6%">
449
450 <p>Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg
451 to g */</p>
452 </td>
453 <td width="6%"></td>
454 <td width="6%"></td>
455 <td width="6%"></td>
456 <td width="37%">
457 </td>
458 <tr valign="top" align="left">
459 <td width="17%"></td>
460 <td width="6%">
461 </td>
462 <td width="6%">
463
464 <p>float</p>
465 </td>
466 <td width="6%"></td>
467 <td width="6%">
468
469 <p>Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb
470 to b */</p>
471 </td>
472 <td width="6%"></td>
473 <td width="6%"></td>
474 <td width="6%"></td>
475 <td width="37%">
476 </td>
477 </table>
478 <!-- INDENTATION -->
479 <table width="100%" border=0 rules="none" frame="void"
480 cols="2" cellspacing="0" cellpadding="0">
481 <tr valign="top" align="left">
482 <td width="17%"></td>
483 <td width="82%">
484 <p>} TIFFCIELabToRGB;</p></td>
485 </table>
486 <!-- INDENTATION -->
487 <table width="100%" border=0 rules="none" frame="void"
488 cols="2" cellspacing="0" cellpadding="0">
489 <tr valign="top" align="left">
490 <td width="8%"></td>
491 <td width="91%">
492 <p><i>display</i> is a display device description, declared
493 as</p>
494 </td>
495 </table>
496 <!-- INDENTATION -->
497 <table width="100%" border=0 rules="none" frame="void"
498 cols="2" cellspacing="0" cellpadding="0">
499 <tr valign="top" align="left">
500 <td width="17%"></td>
501 <td width="82%">
502 <pre>typedef struct {
503 </pre>
504 </td>
505 </table>
506 <!-- TABS -->
507
508 <table width="100%" border=0 rules="none" frame="void"
509 cols="2" cellspacing="0" cellpadding="0">
510 <tr valign="top" align="left">
511 <td width="24%"></td>
512 <td width="75%">
513
514 <p>float d_mat[3][3]; /* XYZ -&gt; luminance matrix */</p>
515 </td>
516 <tr valign="top" align="left">
517 <td width="24%"></td>
518 <td width="75%">
519
520 <p>float d_YCR; /* Light o/p for reference white */</p>
521 </td>
522 <tr valign="top" align="left">
523 <td width="24%"></td>
524 <td width="75%">
525
526 <p>float d_YCG;</p>
527 </td>
528 <tr valign="top" align="left">
529 <td width="24%"></td>
530 <td width="75%">
531
532 <p>float d_YCB;</p>
533 </td>
534 <tr valign="top" align="left">
535 <td width="24%"></td>
536 <td width="75%">
537
538 <p>uint32 d_Vrwr; /* Pixel values for ref. white */</p>
539 </td>
540 <tr valign="top" align="left">
541 <td width="24%"></td>
542 <td width="75%">
543
544 <p>uint32 d_Vrwg;</p>
545 </td>
546 <tr valign="top" align="left">
547 <td width="24%"></td>
548 <td width="75%">
549
550 <p>uint32 d_Vrwb;</p>
551 </td>
552 <tr valign="top" align="left">
553 <td width="24%"></td>
554 <td width="75%">
555
556 <p>float d_Y0R; /* Residual light for black pixel */</p>
557 </td>
558 <tr valign="top" align="left">
559 <td width="24%"></td>
560 <td width="75%">
561
562 <p>float d_Y0G;</p>
563 </td>
564 <tr valign="top" align="left">
565 <td width="24%"></td>
566 <td width="75%">
567
568 <p>float d_Y0B;</p>
569 </td>
570 <tr valign="top" align="left">
571 <td width="24%"></td>
572 <td width="75%">
573
574 <p>float d_gammaR; /* Gamma values for the three guns
575 */</p>
576 </td>
577 <tr valign="top" align="left">
578 <td width="24%"></td>
579 <td width="75%">
580
581 <p>float d_gammaG;</p>
582 </td>
583 <tr valign="top" align="left">
584 <td width="24%"></td>
585 <td width="75%">
586
587 <p>float d_gammaB;</p>
588 </td>
589 </table>
590 <!-- INDENTATION -->
591 <table width="100%" border=0 rules="none" frame="void"
592 cols="2" cellspacing="0" cellpadding="0">
593 <tr valign="top" align="left">
594 <td width="17%"></td>
595 <td width="82%">
596 <p>} TIFFDisplay;</p></td>
597 </table>
598 <!-- INDENTATION -->
599 <table width="100%" border=0 rules="none" frame="void"
600 cols="2" cellspacing="0" cellpadding="0">
601 <tr valign="top" align="left">
602 <td width="8%"></td>
603 <td width="91%">
604 <p>For example, the one can use sRGB device, which has the
605 following parameters:</p>
606 </td>
607 </table>
608 <!-- INDENTATION -->
609 <table width="100%" border=0 rules="none" frame="void"
610 cols="2" cellspacing="0" cellpadding="0">
611 <tr valign="top" align="left">
612 <td width="17%"></td>
613 <td width="82%">
614 <pre>TIFFDisplay display_sRGB = {
615 </pre>
616 </td>
617 </table>
618 <!-- TABS -->
619
620 <table width="100%" border=0 rules="none" frame="void"
621 cols="5" cellspacing="0" cellpadding="0">
622 <tr valign="top" align="left">
623 <td width="24%"></td>
624 <td width="0%"></td>
625 <td width="6%">
626
627 <p>{ /* XYZ -&gt; luminance matrix */</p>
628 </td>
629 <td width="6%"></td>
630 <td width="62%">
631 </td>
632 <tr valign="top" align="left">
633 <td width="24%"></td>
634 <td width="0%"></td>
635 <td width="6%">
636 </td>
637 <td width="6%">
638
639 <p>{ 3.2410F, -1.5374F, -0.4986F },</p>
640 </td>
641 <td width="62%">
642 </td>
643 <tr valign="top" align="left">
644 <td width="24%"></td>
645 <td width="0%"></td>
646 <td width="6%">
647 </td>
648 <td width="6%">
649
650 <p>{ -0.9692F, 1.8760F, 0.0416F },</p>
651 </td>
652 <td width="62%">
653 </td>
654 <tr valign="top" align="left">
655 <td width="24%"></td>
656 <td width="0%"></td>
657 <td width="6%">
658 </td>
659 <td width="6%">
660
661 <p>{ 0.0556F, -0.2040F, 1.0570F }</p>
662 </td>
663 <td width="62%">
664 </td>
665 <tr valign="top" align="left">
666 <td width="24%"></td>
667 <td width="0%"></td>
668 <td width="6%">
669
670 <p>},</p>
671 </td>
672 <td width="6%">
673 </td>
674 <td width="62%">
675 </td>
676 <tr valign="top" align="left">
677 <td width="24%"></td>
678 <td width="0%"></td>
679 <td width="6%">
680
681 <p>100.0F, 100.0F, 100.0F, /* Light o/p for reference white
682 */</p>
683 </td>
684 <td width="6%"></td>
685 <td width="62%">
686 </td>
687 <tr valign="top" align="left">
688 <td width="24%"></td>
689 <td width="0%"></td>
690 <td width="6%">
691
692 <p>255, 255, 255, /* Pixel values for ref. white */</p>
693 </td>
694 <td width="6%"></td>
695 <td width="62%">
696 </td>
697 <tr valign="top" align="left">
698 <td width="24%"></td>
699 <td width="0%"></td>
700 <td width="6%">
701
702 <p>1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel
703 */</p>
704 </td>
705 <td width="6%"></td>
706 <td width="62%">
707 </td>
708 <tr valign="top" align="left">
709 <td width="24%"></td>
710 <td width="0%"></td>
711 <td width="6%">
712
713 <p>2.4F, 2.4F, 2.4F, /* Gamma values for the three guns
714 */</p>
715 </td>
716 <td width="6%"></td>
717 <td width="62%">
718 </td>
719 </table>
720 <!-- INDENTATION -->
721 <table width="100%" border=0 rules="none" frame="void"
722 cols="2" cellspacing="0" cellpadding="0">
723 <tr valign="top" align="left">
724 <td width="17%"></td>
725 <td width="82%">
726 <p>};</p></td>
727 </table>
728 <!-- INDENTATION -->
729 <table width="100%" border=0 rules="none" frame="void"
730 cols="2" cellspacing="0" cellpadding="0">
731 <tr valign="top" align="left">
732 <td width="8%"></td>
733 <td width="91%">
734 <p><i>refWhite</i> is a color temperature of the reference
735 white. The <i>TIFFTAG_WHITEPOINT</i> contains the
736 chromaticity of the white point of the image from where the
737 reference white can be calculated using following
738 formulae:</p>
739 </td>
740 </table>
741 <!-- INDENTATION -->
742 <table width="100%" border=0 rules="none" frame="void"
743 cols="2" cellspacing="0" cellpadding="0">
744 <tr valign="top" align="left">
745 <td width="17%"></td>
746 <td width="82%">
747 <p>refWhite_Y = 100.0<br>
748 refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y<br>
749 refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) /
750 whitePoint_y * refWhite_X</p></td>
751 </table>
752 <!-- INDENTATION -->
753 <table width="100%" border=0 rules="none" frame="void"
754 cols="2" cellspacing="0" cellpadding="0">
755 <tr valign="top" align="left">
756 <td width="8%"></td>
757 <td width="91%">
758 <p>The conversion itself performed in two steps: at the
759 first one we will convert <i>CIE L*a*b* 1976</i> to <i>CIE
760 XYZ</i> using <b>TIFFCIELabToXYZ()</b> routine, and at the
761 second step we will convert <i>CIE XYZ</i> to <i>RGB</i>
762 using <b>TIFFXYZToRGB().</b> Look at the code sample
763 below:</p>
764 </td>
765 </table>
766 <!-- INDENTATION -->
767 <table width="100%" border=0 rules="none" frame="void"
768 cols="2" cellspacing="0" cellpadding="0">
769 <tr valign="top" align="left">
770 <td width="17%"></td>
771 <td width="82%">
772 <pre>float *whitePoint;
773 float refWhite[3];
774
775 /* Initialize structures */
776 img-&gt;cielab = (TIFFCIELabToRGB *)
777 </pre>
778 </td>
779 </table>
780 <!-- TABS -->
781
782 <table width="100%" border=0 rules="none" frame="void"
783 cols="2" cellspacing="0" cellpadding="0">
784 <tr valign="top" align="left">
785 <td width="24%"></td>
786 <td width="75%">
787
788 <p>_TIFFmalloc(sizeof(TIFFCIELabToRGB));</p>
789 </td>
790 </table>
791 <!-- INDENTATION -->
792 <table width="100%" border=0 rules="none" frame="void"
793 cols="2" cellspacing="0" cellpadding="0">
794 <tr valign="top" align="left">
795 <td width="17%"></td>
796 <td width="82%">
797 <p>if (!cielab) {</p></td>
798 </table>
799 <!-- TABS -->
800 <table width="100%" border=0 rules="none" frame="void"
801 cols="5" cellspacing="0" cellpadding="0">
802 <tr valign="top" align="left">
803 <td width="24%"></td>
804 <td width="0%"></td>
805 <td width="6%">
806
807 <p>TIFFError(&quot;CIE L*a*b*-&gt;RGB&quot;,</p>
808 </td>
809 <td width="6%"></td>
810 <td width="62%">
811 </td>
812 <tr valign="top" align="left">
813 <td width="24%"></td>
814 <td width="0%"></td>
815 <td width="6%">
816 </td>
817 <td width="6%">
818
819 <p>&quot;No space for CIE L*a*b*-&gt;RGB conversion
820 state.&quot;);</p>
821 </td>
822 <td width="62%">
823 </td>
824 <tr valign="top" align="left">
825 <td width="24%"></td>
826 <td width="0%"></td>
827 <td width="6%">
828
829 <p>exit(0);</p>
830 </td>
831 <td width="6%"></td>
832 <td width="62%">
833 </td>
834 </table>
835 <!-- INDENTATION -->
836 <table width="100%" border=0 rules="none" frame="void"
837 cols="2" cellspacing="0" cellpadding="0">
838 <tr valign="top" align="left">
839 <td width="17%"></td>
840 <td width="82%">
841 <p>}</p>
842 <!-- INDENTATION -->
843 <p>TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT,
844 &amp;whitePoint);<br>
845 refWhite[1] = 100.0F;<br>
846 refWhite[0] = whitePoint[0] / whitePoint[1] *
847 refWhite[1];<br>
848 refWhite[2] = (1.0F - whitePoint[0] -
849 whitePoint[1])</p></td>
850 </table>
851 <!-- TABS -->
852 <table width="100%" border=0 rules="none" frame="void"
853 cols="2" cellspacing="0" cellpadding="0">
854 <tr valign="top" align="left">
855 <td width="24%"></td>
856 <td width="75%">
857
858 <p>/ whitePoint[1] * refWhite[1];</p>
859 </td>
860 </table>
861 <!-- INDENTATION -->
862 <table width="100%" border=0 rules="none" frame="void"
863 cols="2" cellspacing="0" cellpadding="0">
864 <tr valign="top" align="left">
865 <td width="17%"></td>
866 <td width="82%">
867 <p>if (TIFFCIELabToRGBInit(cielab, &amp;display_sRGB,
868 refWhite) &lt; 0) {</p></td>
869 </table>
870 <!-- TABS -->
871 <table width="100%" border=0 rules="none" frame="void"
872 cols="5" cellspacing="0" cellpadding="0">
873 <tr valign="top" align="left">
874 <td width="24%"></td>
875 <td width="0%"></td>
876 <td width="6%">
877
878 <p>TIFFError(&quot;CIE L*a*b*-&gt;RGB&quot;,</p>
879 </td>
880 <td width="6%"></td>
881 <td width="62%">
882 </td>
883 <tr valign="top" align="left">
884 <td width="24%"></td>
885 <td width="0%"></td>
886 <td width="6%">
887 </td>
888 <td width="6%">
889
890 <p>&quot;Failed to initialize CIE L*a*b*-&gt;RGB conversion
891 state.&quot;);</p>
892 </td>
893 <td width="62%">
894 </td>
895 <tr valign="top" align="left">
896 <td width="24%"></td>
897 <td width="0%"></td>
898 <td width="6%">
899
900 <p>_TIFFfree(cielab);</p>
901 </td>
902 <td width="6%"></td>
903 <td width="62%">
904 </td>
905 <tr valign="top" align="left">
906 <td width="24%"></td>
907 <td width="0%"></td>
908 <td width="6%">
909
910 <p>exit(0);</p>
911 </td>
912 <td width="6%"></td>
913 <td width="62%">
914 </td>
915 </table>
916 <!-- INDENTATION -->
917 <table width="100%" border=0 rules="none" frame="void"
918 cols="2" cellspacing="0" cellpadding="0">
919 <tr valign="top" align="left">
920 <td width="17%"></td>
921 <td width="82%">
922 <p>}</p>
923 <!-- INDENTATION -->
924 <p>/* Now we can start to convert */<br>
925 uint32 r, g, b;<br>
926 uint32 L;<br>
927 int32 a, b;<br>
928 float X, Y, Z;</p>
929 <!-- INDENTATION -->
930 <p>for each pixel in image</p></td>
931 </table>
932 <!-- TABS -->
933 <table width="100%" border=0 rules="none" frame="void"
934 cols="2" cellspacing="0" cellpadding="0">
935 <tr valign="top" align="left">
936 <td width="24%"></td>
937 <td width="75%">
938
939 <p>TIFFCIELabToXYZ(cielab, L, a, b, &amp;X, &amp;Y,
940 &amp;Z);</p>
941 </td>
942 <tr valign="top" align="left">
943 <td width="24%"></td>
944 <td width="75%">
945
946 <p>TIFFXYZToRGB(cielab, X, Y, Z, &amp;r, &amp;g,
947 &amp;b);</p>
948 </td>
949 </table>
950 <!-- INDENTATION -->
951 <table width="100%" border=0 rules="none" frame="void"
952 cols="2" cellspacing="0" cellpadding="0">
953 <tr valign="top" align="left">
954 <td width="17%"></td>
955 <td width="82%">
956 <p>/* Don&rsquo;t forget to free the state structure */<br>
957 _TIFFfree(cielab);</p></td>
958 </table>
959 <a name="SEE ALSO"></a>
960 <h2>SEE ALSO</h2>
961 <!-- INDENTATION -->
962 <table width="100%" border=0 rules="none" frame="void"
963 cols="2" cellspacing="0" cellpadding="0">
964 <tr valign="top" align="left">
965 <td width="8%"></td>
966 <td width="91%">
967 <p><b>TIFFRGBAImage</b>(3TIFF) <b>libtiff</b>(3TIFF),</p>
968 <!-- INDENTATION -->
969 <p>Libtiff library home page:
970 <b>http://www.remotesensing.org/libtiff/</b></p>
971 </td>
972 </table>
973 <hr>
974 </body>
975 </html>