22 |
|
struct tmPackage *tmPkg[TM_MAXPKG]; |
23 |
|
int tmNumPkgs = 0; /* number of registered packages */ |
24 |
|
|
25 |
– |
int tmLastError; /* last error incurred by library */ |
26 |
– |
char *tmLastFunction; /* error-generating function name */ |
25 |
|
|
28 |
– |
|
26 |
|
TMstruct * |
27 |
|
tmInit( /* initialize new tone mapping */ |
28 |
|
int flags, |
68 |
|
tmnew->inpsf = WHTEFFICACY; |
69 |
|
tmnew->cmat[0][1] = tmnew->cmat[0][2] = tmnew->cmat[1][0] = |
70 |
|
tmnew->cmat[1][2] = tmnew->cmat[2][0] = tmnew->cmat[2][1] = 0.; |
71 |
+ |
tmnew->inpdat = NULL; |
72 |
|
tmnew->hbrmin = 10; tmnew->hbrmax = -10; |
73 |
|
tmnew->histo = NULL; |
74 |
|
tmnew->mbrmin = 10; tmnew->mbrmax = -10; |
76 |
|
/* zero private data */ |
77 |
|
for (i = TM_MAXPKG; i--; ) |
78 |
|
tmnew->pd[i] = NULL; |
79 |
+ |
tmnew->lastError = TM_E_OK; |
80 |
+ |
tmnew->lastFunc = "NoErr"; |
81 |
|
/* return new TMstruct */ |
82 |
|
return(tmnew); |
83 |
|
} |
87 |
|
tmSetSpace( /* set input color space for conversions */ |
88 |
|
TMstruct *tms, |
89 |
|
RGBPRIMP pri, |
90 |
< |
double sf |
90 |
> |
double sf, |
91 |
> |
MEM_PTR dat |
92 |
|
) |
93 |
|
{ |
94 |
< |
static char funcName[] = "tmSetSpace"; |
94 |
> |
static const char funcName[] = "tmSetSpace"; |
95 |
|
int i, j; |
96 |
|
/* error check */ |
97 |
|
if (tms == NULL) |
99 |
|
if (sf <= 1e-12) |
100 |
|
returnErr(TM_E_ILLEGAL); |
101 |
|
/* check if no change */ |
102 |
< |
if (pri == tms->inppri && FEQ(sf, tms->inpsf)) |
102 |
> |
if (pri == tms->inppri && FEQ(sf, tms->inpsf) && dat == tms->inpdat) |
103 |
|
returnOK; |
104 |
|
tms->inppri = pri; /* let's set it */ |
105 |
|
tms->inpsf = sf; |
106 |
+ |
tms->inpdat = dat; |
107 |
|
|
108 |
|
if (tms->flags & TM_F_BW) { /* color doesn't matter */ |
109 |
|
tms->monpri = tms->inppri; /* eliminate xform */ |
169 |
|
int len |
170 |
|
) |
171 |
|
{ |
172 |
< |
static char funcName[] = "tmCvColors"; |
172 |
> |
static const char funcName[] = "tmCvColors"; |
173 |
|
static COLOR csmall = {.5*MINLUM, .5*MINLUM, .5*MINLUM}; |
174 |
|
COLOR cmon; |
175 |
|
double lum, slum; |
247 |
|
int len |
248 |
|
) |
249 |
|
{ |
250 |
< |
static char funcName[] = "tmCvGrays"; |
250 |
> |
static const char funcName[] = "tmCvGrays"; |
251 |
|
double d; |
252 |
|
int i; |
253 |
|
|
274 |
|
int wt |
275 |
|
) |
276 |
|
{ |
277 |
< |
static char funcName[] = "tmAddHisto"; |
277 |
> |
static const char funcName[] = "tmAddHisto"; |
278 |
|
int oldorig=0, oldlen, horig, hlen; |
279 |
|
int i, j; |
280 |
|
|
377 |
|
double gamval |
378 |
|
) |
379 |
|
{ |
380 |
< |
static char funcName[] = "tmFixedMapping"; |
380 |
> |
static const char funcName[] = "tmFixedMapping"; |
381 |
|
double d; |
382 |
|
int i; |
383 |
|
|
404 |
|
double Ldmax |
405 |
|
) |
406 |
|
{ |
407 |
< |
static char funcName[] = "tmComputeMapping"; |
407 |
> |
static const char funcName[] = "tmComputeMapping"; |
408 |
|
int *histo; |
409 |
|
float *cumf; |
410 |
|
int brt0, histlen, threshold, ceiling, trimmings; |
512 |
|
int len |
513 |
|
) |
514 |
|
{ |
515 |
< |
static char funcName[] = "tmMapPixels"; |
515 |
> |
static const char funcName[] = "tmMapPixels"; |
516 |
|
int32 li, pv; |
517 |
|
|
518 |
|
if (tms == NULL || tms->lumap == NULL) |
624 |
|
|
625 |
|
int |
626 |
|
tmErrorReturn( /* error return (with message) */ |
627 |
< |
char *func, |
627 |
> |
const char *func, |
628 |
|
TMstruct *tms, |
629 |
|
int err |
630 |
|
) |
631 |
|
{ |
632 |
< |
tmLastFunction = func; |
633 |
< |
tmLastError = err; |
634 |
< |
if (tms != NULL && tms->flags & TM_F_NOSTDERR) |
635 |
< |
return(err); |
632 |
> |
if (tms != NULL) { |
633 |
> |
tms->lastFunc = func; |
634 |
> |
tms->lastError = err; |
635 |
> |
if (tms->flags & TM_F_NOSTDERR) |
636 |
> |
return(err); |
637 |
> |
} |
638 |
|
fputs(func, stderr); |
639 |
|
fputs(": ", stderr); |
640 |
|
fputs(tmErrorMessage[err], stderr); |