| 1 |
– |
/* Copyright (c) 1997 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Routines for tone mapping on Radiance RGBE and XYZE pictures. |
| 6 |
< |
* See tonemap.h for detailed function descriptions. |
| 6 |
> |
* |
| 7 |
> |
* Externals declared in tonemap.h |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
+ |
/* ==================================================================== |
| 11 |
+ |
* The Radiance Software License, Version 1.0 |
| 12 |
+ |
* |
| 13 |
+ |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
| 14 |
+ |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
| 15 |
+ |
* |
| 16 |
+ |
* Redistribution and use in source and binary forms, with or without |
| 17 |
+ |
* modification, are permitted provided that the following conditions |
| 18 |
+ |
* are met: |
| 19 |
+ |
* |
| 20 |
+ |
* 1. Redistributions of source code must retain the above copyright |
| 21 |
+ |
* notice, this list of conditions and the following disclaimer. |
| 22 |
+ |
* |
| 23 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
| 24 |
+ |
* notice, this list of conditions and the following disclaimer in |
| 25 |
+ |
* the documentation and/or other materials provided with the |
| 26 |
+ |
* distribution. |
| 27 |
+ |
* |
| 28 |
+ |
* 3. The end-user documentation included with the redistribution, |
| 29 |
+ |
* if any, must include the following acknowledgment: |
| 30 |
+ |
* "This product includes Radiance software |
| 31 |
+ |
* (http://radsite.lbl.gov/) |
| 32 |
+ |
* developed by the Lawrence Berkeley National Laboratory |
| 33 |
+ |
* (http://www.lbl.gov/)." |
| 34 |
+ |
* Alternately, this acknowledgment may appear in the software itself, |
| 35 |
+ |
* if and wherever such third-party acknowledgments normally appear. |
| 36 |
+ |
* |
| 37 |
+ |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
| 38 |
+ |
* and "The Regents of the University of California" must |
| 39 |
+ |
* not be used to endorse or promote products derived from this |
| 40 |
+ |
* software without prior written permission. For written |
| 41 |
+ |
* permission, please contact [email protected]. |
| 42 |
+ |
* |
| 43 |
+ |
* 5. Products derived from this software may not be called "Radiance", |
| 44 |
+ |
* nor may "Radiance" appear in their name, without prior written |
| 45 |
+ |
* permission of Lawrence Berkeley National Laboratory. |
| 46 |
+ |
* |
| 47 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 48 |
+ |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 49 |
+ |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 50 |
+ |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
| 51 |
+ |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 52 |
+ |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 53 |
+ |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 54 |
+ |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 55 |
+ |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 56 |
+ |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 57 |
+ |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 58 |
+ |
* SUCH DAMAGE. |
| 59 |
+ |
* ==================================================================== |
| 60 |
+ |
* |
| 61 |
+ |
* This software consists of voluntary contributions made by many |
| 62 |
+ |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
| 63 |
+ |
* information on Lawrence Berkeley National Laboratory, please see |
| 64 |
+ |
* <http://www.lbl.gov/>. |
| 65 |
+ |
*/ |
| 66 |
+ |
|
| 67 |
|
#include <stdio.h> |
| 68 |
+ |
#include <string.h> |
| 69 |
|
#include <math.h> |
| 70 |
+ |
#include <time.h> |
| 71 |
|
#include "tmprivat.h" |
| 72 |
|
#include "resolu.h" |
| 73 |
|
|
| 74 |
+ |
#ifndef TM_PIC_CTRANS |
| 75 |
+ |
#define TM_PIC_CTRANS 1 /* transform colors? (expensive) */ |
| 76 |
+ |
#endif |
| 77 |
|
|
| 78 |
< |
extern char *tempbuffer(); |
| 78 |
> |
#define GAMTSZ 1024 |
| 79 |
|
|
| 80 |
+ |
typedef struct { |
| 81 |
+ |
BYTE gamb[GAMTSZ]; /* gamma lookup table */ |
| 82 |
+ |
COLR clfb; /* encoded tm->clf */ |
| 83 |
+ |
TMbright inpsfb; /* encoded tm->inpsf */ |
| 84 |
+ |
} COLRDATA; |
| 85 |
+ |
|
| 86 |
+ |
#ifdef NOPROTO |
| 87 |
+ |
static MEM_PTR colrInit(); |
| 88 |
+ |
static void colrNewSpace(); |
| 89 |
+ |
#else |
| 90 |
+ |
static MEM_PTR colrInit(struct tmStruct *); |
| 91 |
+ |
static void colrNewSpace(struct tmStruct *); |
| 92 |
+ |
#endif |
| 93 |
+ |
static struct tmPackage colrPkg = { /* our package functions */ |
| 94 |
+ |
colrInit, colrNewSpace, free |
| 95 |
+ |
}; |
| 96 |
+ |
static int colrReg = -1; /* our package registration number */ |
| 97 |
+ |
|
| 98 |
|
#define LOGISZ 260 |
| 99 |
|
static TMbright logi[LOGISZ]; |
| 22 |
– |
static BYTE photofact[BMESUPPER-BMESLOWER]; |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
int |
| 103 |
< |
tmCvColrs(ls, cs, scan, len) /* tone map RGBE/XYZE colors */ |
| 103 |
> |
tmCvColrs(ls, cs, scan, len) /* convert RGBE/XYZE colors */ |
| 104 |
|
TMbright *ls; |
| 105 |
|
BYTE *cs; |
| 106 |
|
COLR *scan; |
| 108 |
|
{ |
| 109 |
|
static char funcName[] = "tmCvColrs"; |
| 110 |
|
COLR cmon; |
| 111 |
+ |
register COLRDATA *cd; |
| 112 |
|
register int i, bi, li; |
| 113 |
|
|
| 114 |
|
if (tmTop == NULL) |
| 115 |
|
returnErr(TM_E_TMINVAL); |
| 116 |
< |
if (ls == NULL | scan == NULL | len <= 0) |
| 116 |
> |
if (ls == NULL | scan == NULL | len < 0) |
| 117 |
|
returnErr(TM_E_ILLEGAL); |
| 118 |
< |
if (tmTop->flags & TM_F_NEEDMAT) { /* need floating point */ |
| 118 |
> |
#if TM_PIC_CTRANS |
| 119 |
> |
if (tmNeedMatrix(tmTop)) { /* need floating point */ |
| 120 |
> |
#else |
| 121 |
> |
if (tmTop->inppri == TM_XYZPRIM) { /* no way around this */ |
| 122 |
> |
#endif |
| 123 |
|
register COLOR *newscan; |
| 124 |
|
newscan = (COLOR *)tempbuffer(len*sizeof(COLOR)); |
| 125 |
|
if (newscan == NULL) |
| 128 |
|
colr_color(newscan[i], scan[i]); |
| 129 |
|
return(tmCvColors(ls, cs, newscan, len)); |
| 130 |
|
} |
| 131 |
< |
if (logi[0] == 0) { /* build tables if necessary */ |
| 131 |
> |
if (colrReg < 0) { /* build tables if necessary */ |
| 132 |
> |
colrReg = tmRegPkg(&colrPkg); |
| 133 |
> |
if (colrReg < 0) |
| 134 |
> |
returnErr(TM_E_CODERR1); |
| 135 |
|
for (i = 256; i--; ) |
| 136 |
|
logi[i] = TM_BRTSCALE*log((i+.5)/256.) - .5; |
| 137 |
|
for (i = 256; i < LOGISZ; i++) |
| 138 |
< |
logi[i] = logi[255]; |
| 139 |
< |
for (i = BMESLOWER; i < BMESUPPER; i++) |
| 55 |
< |
photofact[i-BMESLOWER] = 256. * |
| 56 |
< |
(tmLuminance(i) - LMESLOWER) / |
| 57 |
< |
(LMESUPPER - LMESLOWER); |
| 138 |
> |
logi[i] = 0; |
| 139 |
> |
tmMkMesofact(); |
| 140 |
|
} |
| 141 |
+ |
if ((cd = (COLRDATA *)tmPkgData(tmTop,colrReg)) == NULL) |
| 142 |
+ |
returnErr(TM_E_NOMEM); |
| 143 |
|
for (i = len; i--; ) { |
| 144 |
|
copycolr(cmon, scan[i]); |
| 145 |
|
/* world luminance */ |
| 146 |
< |
li = ( tmTop->clfb[RED]*cmon[RED] + |
| 147 |
< |
tmTop->clfb[GRN]*cmon[GRN] + |
| 148 |
< |
tmTop->clfb[BLU]*cmon[BLU] ) >> 8; |
| 149 |
< |
bi = BRT2SCALE*(cmon[EXP]-COLXS) + |
| 150 |
< |
logi[li] + tmTop->inpsfb; |
| 151 |
< |
if (bi < MINBRT) { |
| 152 |
< |
bi = MINBRT-1; /* bogus value */ |
| 153 |
< |
li++; /* avoid li==0 */ |
| 146 |
> |
li = ( cd->clfb[RED]*cmon[RED] + |
| 147 |
> |
cd->clfb[GRN]*cmon[GRN] + |
| 148 |
> |
cd->clfb[BLU]*cmon[BLU] ) >> 8; |
| 149 |
> |
bi = BRT2SCALE(cmon[EXP]-COLXS) + |
| 150 |
> |
logi[li] + cd->inpsfb; |
| 151 |
> |
if (li <= 0) { |
| 152 |
> |
bi = TM_NOBRT; /* bogus value */ |
| 153 |
> |
li = 1; /* avoid li==0 */ |
| 154 |
|
} |
| 155 |
|
ls[i] = bi; |
| 156 |
|
if (cs == TM_NOCHROM) /* no color? */ |
| 163 |
|
else { |
| 164 |
|
if (tmTop->flags & TM_F_BW) |
| 165 |
|
cmon[RED] = cmon[GRN] = cmon[BLU] = li; |
| 166 |
< |
pf = photofact[bi-BMESLOWER]; |
| 166 |
> |
pf = tmMesofact[bi-BMESLOWER]; |
| 167 |
|
sli *= 256 - pf; |
| 168 |
|
cmon[RED] = ( sli + pf*cmon[RED] ) >> 8; |
| 169 |
|
cmon[GRN] = ( sli + pf*cmon[GRN] ) >> 8; |
| 172 |
|
} else if (tmTop->flags & TM_F_BW) { |
| 173 |
|
cmon[RED] = cmon[GRN] = cmon[BLU] = li; |
| 174 |
|
} |
| 175 |
< |
bi = ( (int4)TM_GAMTSZ*tmTop->clfb[RED]*cmon[RED]/li ) >> 8; |
| 176 |
< |
cs[3*i ] = bi>=TM_GAMTSZ ? 255 : tmTop->gamb[bi]; |
| 177 |
< |
bi = ( (int4)TM_GAMTSZ*tmTop->clfb[GRN]*cmon[GRN]/li ) >> 8; |
| 178 |
< |
cs[3*i+1] = bi>=TM_GAMTSZ ? 255 : tmTop->gamb[bi]; |
| 179 |
< |
bi = ( (int4)TM_GAMTSZ*tmTop->clfb[BLU]*cmon[BLU]/li ) >> 8; |
| 180 |
< |
cs[3*i+2] = bi>=TM_GAMTSZ ? 255 : tmTop->gamb[bi]; |
| 175 |
> |
bi = ( (int4)GAMTSZ*cd->clfb[RED]*cmon[RED]/li ) >> 8; |
| 176 |
> |
cs[3*i ] = bi>=GAMTSZ ? 255 : cd->gamb[bi]; |
| 177 |
> |
bi = ( (int4)GAMTSZ*cd->clfb[GRN]*cmon[GRN]/li ) >> 8; |
| 178 |
> |
cs[3*i+1] = bi>=GAMTSZ ? 255 : cd->gamb[bi]; |
| 179 |
> |
bi = ( (int4)GAMTSZ*cd->clfb[BLU]*cmon[BLU]/li ) >> 8; |
| 180 |
> |
cs[3*i+2] = bi>=GAMTSZ ? 255 : cd->gamb[bi]; |
| 181 |
|
} |
| 182 |
|
returnOK; |
| 183 |
|
} |
| 210 |
|
rh->format = FMTCIE; |
| 211 |
|
else |
| 212 |
|
rh->format = FMTBAD; |
| 213 |
< |
return; |
| 213 |
> |
return(0); |
| 214 |
|
} |
| 215 |
|
if (isexpos(s)) { |
| 216 |
|
rh->expos *= exposval(s); |
| 217 |
< |
return; |
| 217 |
> |
return(0); |
| 218 |
|
} |
| 219 |
|
if (isprims(s)) { |
| 220 |
|
primsval(rh->mypri, s); |
| 221 |
|
rh->primp = rh->mypri; |
| 222 |
< |
return; |
| 222 |
> |
return(0); |
| 223 |
|
} |
| 224 |
+ |
return(0); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
|
| 248 |
|
*xp = *yp = 0; /* error precaution */ |
| 249 |
|
if ((inpf = fp) == TM_GETFILE && (inpf = fopen(fname, "r")) == NULL) |
| 250 |
|
returnErr(TM_E_BADFILE); |
| 251 |
+ |
*lpp = NULL; |
| 252 |
+ |
if (cpp != TM_NOCHROMP) *cpp = NULL; |
| 253 |
|
info = rhdefault; /* get our header */ |
| 254 |
|
getheader(inpf, headline, (char *)&info); |
| 255 |
|
if (info.format == FMTBAD | info.expos <= 0. || |
| 292 |
|
if (fp == NULL) |
| 293 |
|
fclose(inpf); |
| 294 |
|
if (scanin != NULL) |
| 295 |
< |
free((char *)scanin); |
| 296 |
< |
if (err != TM_E_OK) |
| 295 |
> |
free((MEM_PTR)scanin); |
| 296 |
> |
if (err != TM_E_OK) { |
| 297 |
> |
if (*lpp != NULL) |
| 298 |
> |
free((MEM_PTR)*lpp); |
| 299 |
> |
if (cpp != TM_NOCHROMP && *cpp != NULL) |
| 300 |
> |
free((MEM_PTR)*cpp); |
| 301 |
|
returnErr(err); |
| 302 |
+ |
} |
| 303 |
|
returnOK; |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
|
| 307 |
+ |
#ifdef PCOND |
| 308 |
|
int /* run pcond to map picture */ |
| 309 |
|
dopcond(psp, xp, yp, flags, monpri, gamval, Lddyn, Ldmax, fname) |
| 310 |
|
BYTE **psp; |
| 315 |
|
char *fname; |
| 316 |
|
{ |
| 317 |
|
char *funcName = fname; |
| 318 |
< |
char cmdbuf[512]; |
| 318 |
> |
char cmdbuf[1024]; |
| 319 |
|
FILE *infp; |
| 320 |
|
register COLR *scan; |
| 321 |
|
register BYTE *rp; |
| 325 |
|
if (setcolrcor(pow, 1./gamval) < 0) |
| 326 |
|
returnErr(TM_E_NOMEM); |
| 327 |
|
/* create command */ |
| 328 |
< |
strcpy(cmdbuf, "pcond "); |
| 328 |
> |
strcpy(cmdbuf, PCOND); |
| 329 |
|
if (flags & TM_F_HCONTR) |
| 330 |
< |
strcat(cmdbuf, "-s "); |
| 330 |
> |
strcat(cmdbuf, " -s"); |
| 331 |
|
if (flags & TM_F_MESOPIC) |
| 332 |
< |
strcat(cmdbuf, "-c "); |
| 332 |
> |
strcat(cmdbuf, " -c"); |
| 333 |
|
if (flags & TM_F_LINEAR) |
| 334 |
< |
strcat(cmdbuf, "-l "); |
| 334 |
> |
strcat(cmdbuf, " -l"); |
| 335 |
|
if (flags & TM_F_ACUITY) |
| 336 |
< |
strcat(cmdbuf, "-a "); |
| 336 |
> |
strcat(cmdbuf, " -a"); |
| 337 |
|
if (flags & TM_F_VEIL) |
| 338 |
< |
strcat(cmdbuf, "-v "); |
| 338 |
> |
strcat(cmdbuf, " -v"); |
| 339 |
|
if (flags & TM_F_CWEIGHT) |
| 340 |
< |
strcat(cmdbuf, "-w "); |
| 341 |
< |
sprintf(cmdbuf+strlen(cmdbuf), |
| 342 |
< |
"-p %f %f %f %f %f %f %f %f -d %f -u %f %s", |
| 343 |
< |
monpri[RED][CIEX], monpri[RED][CIEY], |
| 344 |
< |
monpri[GRN][CIEX], monpri[GRN][CIEY], |
| 345 |
< |
monpri[BLU][CIEX], monpri[BLU][CIEY], |
| 346 |
< |
monpri[WHT][CIEX], monpri[WHT][CIEY], |
| 347 |
< |
Lddyn, Ldmax, fname); |
| 340 |
> |
strcat(cmdbuf, " -w"); |
| 341 |
> |
if (monpri != stdprims) |
| 342 |
> |
sprintf(cmdbuf+strlen(cmdbuf), " -p %f %f %f %f %f %f %f %f", |
| 343 |
> |
monpri[RED][CIEX], monpri[RED][CIEY], |
| 344 |
> |
monpri[GRN][CIEX], monpri[GRN][CIEY], |
| 345 |
> |
monpri[BLU][CIEX], monpri[BLU][CIEY], |
| 346 |
> |
monpri[WHT][CIEX], monpri[WHT][CIEY]); |
| 347 |
> |
sprintf(cmdbuf+strlen(cmdbuf), " -d %f -u %f %s", Lddyn, Ldmax, fname); |
| 348 |
|
/* start pcond */ |
| 349 |
|
if ((infp = popen(cmdbuf, "r")) == NULL) |
| 350 |
|
returnErr(TM_E_BADFILE); |
| 368 |
|
for (y = 0; y < *yp; y++) { |
| 369 |
|
if (freadcolrs(scan, *xp, infp) < 0) { |
| 370 |
|
pclose(infp); |
| 371 |
< |
free((char *)scan); |
| 372 |
< |
free((char *)*psp); |
| 371 |
> |
free((MEM_PTR)scan); |
| 372 |
> |
free((MEM_PTR)*psp); |
| 373 |
|
*psp = NULL; |
| 374 |
|
returnErr(TM_E_BADFILE); |
| 375 |
|
} |
| 384 |
|
*rp++ = scan[x][BLU]; |
| 385 |
|
} |
| 386 |
|
} |
| 387 |
< |
free((char *)scan); |
| 387 |
> |
free((MEM_PTR)scan); |
| 388 |
|
pclose(infp); |
| 389 |
|
returnOK; |
| 390 |
|
} |
| 391 |
+ |
#endif |
| 392 |
|
|
| 393 |
|
|
| 394 |
|
int /* map a Radiance picture */ |
| 402 |
|
FILE *fp; |
| 403 |
|
{ |
| 404 |
|
char *funcName = fname==NULL ? "tmMapPicture" : fname; |
| 311 |
– |
FILE *inpf; |
| 405 |
|
BYTE *cp; |
| 406 |
|
TMbright *lp; |
| 407 |
|
int err; |
| 414 |
|
if (Lddyn < MINLDDYN) Lddyn = DEFLDDYN; |
| 415 |
|
if (Ldmax < MINLDMAX) Ldmax = DEFLDMAX; |
| 416 |
|
if (flags & TM_F_BW) monpri = stdprims; |
| 417 |
+ |
#ifdef PCOND |
| 418 |
|
/* check for pcond run */ |
| 419 |
|
if (fp == TM_GETFILE && flags & TM_F_UNIMPL) |
| 420 |
|
return( dopcond(psp, xp, yp, flags, |
| 421 |
|
monpri, gamval, Lddyn, Ldmax, fname) ); |
| 422 |
+ |
#endif |
| 423 |
|
/* initialize tone mapping */ |
| 424 |
|
if (tmInit(flags, monpri, gamval) == NULL) |
| 425 |
|
returnErr(TM_E_NOMEM); |
| 434 |
|
if (flags & TM_F_BW) { |
| 435 |
|
*psp = (BYTE *)malloc(sizeof(BYTE) * *xp * *yp); |
| 436 |
|
if (*psp == NULL) { |
| 437 |
< |
free((char *)lp); |
| 437 |
> |
free((MEM_PTR)lp); |
| 438 |
|
tmDone(NULL); |
| 439 |
|
returnErr(TM_E_NOMEM); |
| 440 |
|
} |
| 452 |
|
err = tmMapPixels(*psp, lp, cp, *xp * *yp); |
| 453 |
|
|
| 454 |
|
done: /* clean up */ |
| 455 |
< |
free((char *)lp); |
| 455 |
> |
free((MEM_PTR)lp); |
| 456 |
|
tmDone(NULL); |
| 457 |
|
if (err != TM_E_OK) { /* free memory on error */ |
| 458 |
< |
free((char *)*psp); |
| 458 |
> |
free((MEM_PTR)*psp); |
| 459 |
|
*psp = NULL; |
| 460 |
|
returnErr(err); |
| 461 |
|
} |
| 462 |
|
returnOK; |
| 463 |
+ |
} |
| 464 |
+ |
|
| 465 |
+ |
|
| 466 |
+ |
static void |
| 467 |
+ |
colrNewSpace(tms) /* color space changed for tone mapping */ |
| 468 |
+ |
register struct tmStruct *tms; |
| 469 |
+ |
{ |
| 470 |
+ |
register COLRDATA *cd; |
| 471 |
+ |
double d; |
| 472 |
+ |
|
| 473 |
+ |
cd = (COLRDATA *)tms->pd[colrReg]; |
| 474 |
+ |
cd->clfb[RED] = 256.*tms->clf[RED] + .5; |
| 475 |
+ |
cd->clfb[GRN] = 256.*tms->clf[GRN] + .5; |
| 476 |
+ |
cd->clfb[BLU] = 256.*tms->clf[BLU] + .5; |
| 477 |
+ |
cd->clfb[EXP] = COLXS; |
| 478 |
+ |
d = TM_BRTSCALE*log(tms->inpsf); |
| 479 |
+ |
cd->inpsfb = d<0. ? d-.5 : d+.5; |
| 480 |
+ |
} |
| 481 |
+ |
|
| 482 |
+ |
|
| 483 |
+ |
static MEM_PTR |
| 484 |
+ |
colrInit(tms) /* initialize private data for tone mapping */ |
| 485 |
+ |
register struct tmStruct *tms; |
| 486 |
+ |
{ |
| 487 |
+ |
register COLRDATA *cd; |
| 488 |
+ |
register int i; |
| 489 |
+ |
/* allocate our data */ |
| 490 |
+ |
cd = (COLRDATA *)malloc(sizeof(COLRDATA)); |
| 491 |
+ |
if (cd == NULL) |
| 492 |
+ |
return(NULL); |
| 493 |
+ |
tms->pd[colrReg] = (MEM_PTR)cd; |
| 494 |
+ |
/* compute gamma table */ |
| 495 |
+ |
for (i = GAMTSZ; i--; ) |
| 496 |
+ |
cd->gamb[i] = 256.*pow((i+.5)/GAMTSZ, 1./tms->mongam); |
| 497 |
+ |
/* compute color and scale factors */ |
| 498 |
+ |
colrNewSpace(tms); |
| 499 |
+ |
return((MEM_PTR)cd); |
| 500 |
|
} |