98 |
|
|
99 |
|
int wrongformat = 0; /* input in another format? */ |
100 |
|
|
101 |
+ |
TMstruct *tmGlobal; /* base tone-mapping */ |
102 |
+ |
TMstruct *tmCurrent; /* curren tone-mapping */ |
103 |
+ |
|
104 |
|
GC ourgc; /* standard graphics context */ |
105 |
|
GC revgc; /* graphics context with GXinvert */ |
106 |
|
|
973 |
|
register int rval; |
974 |
|
|
975 |
|
setcolor(cavg, 0., 0., 0.); |
976 |
< |
rval = dobox(colavg, (char *)cavg); |
976 |
> |
rval = dobox(colavg, (void *)cavg); |
977 |
|
if (rval > 0) { |
978 |
|
d = 1./rval; |
979 |
|
scalecolor(cavg, d); |
1021 |
|
addfix( /* add fixation points to histogram */ |
1022 |
|
COLR *scn, |
1023 |
|
int n, |
1024 |
< |
void *p /*NOTUSED*/ |
1024 |
> |
void *p |
1025 |
|
) |
1026 |
|
{ |
1027 |
< |
if (tmCvColrs(lscan, TM_NOCHROM, scn, n)) |
1027 |
> |
TMstruct * tms = (TMstruct *)p; |
1028 |
> |
|
1029 |
> |
if (tmCvColrs(tms, lscan, TM_NOCHROM, scn, n)) |
1030 |
|
goto tmerr; |
1031 |
< |
if (tmAddHisto(lscan, n, FIXWEIGHT)) |
1031 |
> |
if (tmAddHisto(tms, lscan, n, FIXWEIGHT)) |
1032 |
|
goto tmerr; |
1033 |
|
return; |
1034 |
|
tmerr: |
1052 |
|
} |
1053 |
|
flags = tmflags; /* histogram adjustment */ |
1054 |
|
if (greyscale) flags |= TM_F_BW; |
1055 |
< |
if (tmTop != NULL) { /* reuse old histogram if one */ |
1056 |
< |
tmDone(tmTop); |
1057 |
< |
tmTop->flags = flags; |
1055 |
> |
if (tmGlobal != NULL) { /* reuse old histogram if one */ |
1056 |
> |
tmDone(tmCurrent); tmCurrent = NULL; |
1057 |
> |
tmGlobal->flags = flags; |
1058 |
|
} else { /* else initialize */ |
1059 |
|
if ((lscan = (TMbright *)malloc(xmax*sizeof(TMbright))) == NULL) |
1060 |
|
goto memerr; |
1066 |
|
== NULL) |
1067 |
|
goto memerr; |
1068 |
|
/* initialize tm library */ |
1069 |
< |
if (tmInit(flags, stdprims, gamcor) == NULL) |
1069 |
> |
tmGlobal = tmInit(flags, stdprims, gamcor); |
1070 |
> |
if (tmGlobal == NULL) |
1071 |
|
goto memerr; |
1072 |
< |
if (tmSetSpace(stdprims, WHTEFFICACY/exposure)) |
1072 |
> |
if (tmSetSpace(tmGlobal, stdprims, WHTEFFICACY/exposure)) |
1073 |
|
goto tmerr; |
1074 |
|
/* compute picture histogram */ |
1075 |
|
for (y = 0; y < ymax; y++) { |
1076 |
|
getscan(y); |
1077 |
< |
if (tmCvColrs(lscan, TM_NOCHROM, scanline, xmax)) |
1077 |
> |
if (tmCvColrs(tmGlobal, lscan, TM_NOCHROM, |
1078 |
> |
scanline, xmax)) |
1079 |
|
goto tmerr; |
1080 |
< |
if (tmAddHisto(lscan, xmax, 1)) |
1080 |
> |
if (tmAddHisto(tmGlobal, lscan, xmax, 1)) |
1081 |
|
goto tmerr; |
1082 |
|
} |
1083 |
|
} |
1084 |
< |
tmDup(); /* add fixations to duplicate map */ |
1085 |
< |
dobox(addfix, NULL); |
1084 |
> |
tmCurrent = tmDup(tmGlobal); /* add fixations to duplicate map */ |
1085 |
> |
dobox(addfix, (void *)tmCurrent); |
1086 |
|
/* (re)compute tone mapping */ |
1087 |
< |
if (tmComputeMapping(gamcor, 0., 0.)) |
1087 |
> |
if (tmComputeMapping(tmCurrent, gamcor, 0., 0.)) |
1088 |
|
goto tmerr; |
1089 |
|
return; |
1090 |
|
memerr: |
1110 |
|
} |
1111 |
|
if (len > xmax) |
1112 |
|
quiterr("code error 1 in tmap_colrs"); |
1113 |
< |
if (tmCvColrs(lscan, cscan, scn, len)) |
1113 |
> |
if (tmCvColrs(tmCurrent, lscan, cscan, scn, len)) |
1114 |
|
goto tmerr; |
1115 |
< |
if (tmMapPixels(pscan, lscan, cscan, len)) |
1115 |
> |
if (tmMapPixels(tmCurrent, pscan, lscan, cscan, len)) |
1116 |
|
goto tmerr; |
1117 |
|
ps = pscan; |
1118 |
|
if (greyscale) |