18 |
|
|
19 |
|
#include "standard.h" |
20 |
|
|
21 |
– |
#include <string.h> |
21 |
|
#include <signal.h> |
23 |
– |
#include <unistd.h> |
24 |
– |
#include <sys/types.h> |
22 |
|
#include <sys/wait.h> |
23 |
|
#include <X11/Xlib.h> |
24 |
|
#include <X11/cursorfont.h> |
25 |
|
#include <X11/Xutil.h> |
26 |
|
#include <X11/Xatom.h> |
27 |
|
|
28 |
+ |
#include "paths.h" |
29 |
|
#include "color.h" |
30 |
|
#include "tonemap.h" |
31 |
|
#include "clrtab.h" |
116 |
|
char icondata[ICONSIZ*ICONSIZ/8]; /* icon bitmap data */ |
117 |
|
int iconwidth = 0, iconheight = 0; |
118 |
|
|
121 |
– |
char *progname; |
122 |
– |
|
119 |
|
char errmsg[128]; |
120 |
|
|
121 |
|
uby8 clrtab[256][3]; /* global color map */ |
164 |
|
int i; |
165 |
|
int pid; |
166 |
|
|
167 |
< |
progname = argv[0]; |
167 |
> |
fixargv0(argv[0]); /* sets global progname */ |
168 |
|
fin = stdin; |
169 |
|
|
170 |
|
for (i = 1; i < argc; i++) |
308 |
|
XTextProperty windowName, iconName; |
309 |
|
XGCValues xgcv; |
310 |
|
char *name; |
311 |
< |
register int i; |
311 |
> |
int i; |
312 |
|
|
313 |
|
if (fname != NULL) { |
314 |
|
scanpos = (long *)malloc(ymax*sizeof(long)); |
418 |
|
char *err |
419 |
|
) |
420 |
|
{ |
421 |
< |
register int es; |
421 |
> |
int es; |
422 |
|
int cs; |
423 |
|
|
424 |
|
if ( (es = (err != NULL)) ) |
439 |
|
|
440 |
|
static int |
441 |
|
viscmp( /* compare visual to see which is better, descending */ |
442 |
< |
register XVisualInfo *v1, |
443 |
< |
register XVisualInfo *v2 |
442 |
> |
XVisualInfo *v1, |
443 |
> |
XVisualInfo *v2 |
444 |
|
) |
445 |
|
{ |
446 |
|
int bad1 = 0, bad2 = 0; |
447 |
< |
register int *rp; |
447 |
> |
int *rp; |
448 |
|
|
449 |
|
if (v1->class == v2->class) { |
450 |
|
if ((v1->class == TrueColor) | (v1->class == DirectColor)) { |
501 |
|
}; |
502 |
|
XVisualInfo *xvi; |
503 |
|
int vismatched; |
504 |
< |
register int i, j; |
504 |
> |
int i, j; |
505 |
|
|
506 |
|
if (greyscale) { |
507 |
|
ourrank = rankings[2]; |
672 |
|
RREAL hv[2]; |
673 |
|
FVECT rorg, rdir; |
674 |
|
COLOR cval; |
675 |
< |
register char *cp; |
675 |
> |
char *cp; |
676 |
|
|
677 |
|
bbox.xmin = xpos; bbox.xsiz = 1; |
678 |
|
bbox.ymin = ypos; bbox.ysiz = 1; |
950 |
|
|
951 |
|
static void |
952 |
|
colavg( |
953 |
< |
register COLR *scn, |
954 |
< |
register int n, |
953 |
> |
COLR *scn, |
954 |
> |
int n, |
955 |
|
void *cavg |
956 |
|
) |
957 |
|
{ |
958 |
|
COLOR col; |
959 |
|
|
960 |
|
while (n--) { |
961 |
< |
colr_color(col, *scn++); |
961 |
> |
colr_color(col, *scn); |
962 |
|
addcolor((COLORV*)cavg, col); |
963 |
+ |
scn++; |
964 |
|
} |
965 |
|
} |
966 |
|
|
971 |
|
) |
972 |
|
{ |
973 |
|
double d; |
974 |
< |
register int rval; |
974 |
> |
int rval; |
975 |
|
|
976 |
|
setcolor(cavg, 0., 0., 0.); |
977 |
< |
rval = dobox(colavg, (void *)cavg); |
977 |
> |
rval = dobox(colavg, cavg); |
978 |
|
if (rval > 0) { |
979 |
|
d = 1./rval; |
980 |
|
scalecolor(cavg, d); |
985 |
|
|
986 |
|
static int |
987 |
|
dobox( /* run function over bbox */ |
991 |
– |
//void (*f)(), /* function to call for each subscan */ |
988 |
|
doboxf_t *f, /* function to call for each subscan */ |
989 |
|
void *p /* pointer to private data */ |
990 |
|
) |
1009 |
|
if (top >= bottom) |
1010 |
|
return(0); |
1011 |
|
for (y = top; y < bottom; y++) { |
1012 |
< |
if (getscan(y) == -1) |
1012 |
> |
if (getscan(y) < 0) |
1013 |
|
return(-1); |
1014 |
|
(*f)(scanline+left, right-left, p); |
1015 |
|
} |
1082 |
|
} |
1083 |
|
} |
1084 |
|
tmCurrent = tmDup(tmGlobal); /* add fixations to duplicate map */ |
1085 |
< |
dobox(addfix, (void *)tmCurrent); |
1085 |
> |
dobox(addfix, tmCurrent); |
1086 |
|
/* (re)compute tone mapping */ |
1087 |
|
if (tmComputeMapping(tmCurrent, gamcor, 0., 0.)) |
1088 |
|
goto tmerr; |
1096 |
|
|
1097 |
|
static void |
1098 |
|
tmap_colrs( /* apply tone mapping to scanline */ |
1099 |
< |
register COLR *scn, |
1099 |
> |
COLR *scn, |
1100 |
|
int len |
1101 |
|
) |
1102 |
|
{ |
1103 |
< |
register uby8 *ps; |
1103 |
> |
uby8 *ps; |
1104 |
|
|
1105 |
|
if (tmflags == TM_F_LINEAR) { |
1106 |
|
if (scale) |
1138 |
|
static void |
1139 |
|
getmono(void) /* get monochrome data */ |
1140 |
|
{ |
1141 |
< |
register unsigned char *dp; |
1142 |
< |
register int x, err; |
1141 |
> |
unsigned char *dp; |
1142 |
> |
int x, err; |
1143 |
|
int y, errp; |
1144 |
|
short *cerr; |
1145 |
|
|
1164 |
|
cerr[x] = err + errp; |
1165 |
|
} |
1166 |
|
} |
1167 |
< |
free((void *)cerr); |
1167 |
> |
free(cerr); |
1168 |
|
} |
1169 |
|
|
1170 |
|
|
1178 |
|
static int ynext; |
1179 |
|
static char *dp; |
1180 |
|
COLR clr; |
1181 |
< |
register int err; |
1182 |
< |
register int x, ti; |
1181 |
> |
int err; |
1182 |
> |
int x, ti; |
1183 |
|
int errp; |
1184 |
|
|
1185 |
|
if (iconheight == 0) { /* initialize */ |
1226 |
|
getfull(void) /* get full (24-bit) data */ |
1227 |
|
{ |
1228 |
|
int y; |
1229 |
< |
register uint32 *dp; |
1230 |
< |
register uint16 *dph; |
1231 |
< |
register int x; |
1229 |
> |
uint32 *dp; |
1230 |
> |
uint16 *dph; |
1231 |
> |
int x; |
1232 |
|
/* initialize tone mapping */ |
1233 |
|
make_tonemap(); |
1234 |
|
/* read and convert file */ |
1294 |
|
getgrey(void) /* get greyscale data */ |
1295 |
|
{ |
1296 |
|
int y; |
1297 |
< |
register unsigned char *dp; |
1298 |
< |
register int x; |
1297 |
> |
unsigned char *dp; |
1298 |
> |
int x; |
1299 |
|
/* initialize tone mapping */ |
1300 |
|
make_tonemap(); |
1301 |
|
/* read and convert file */ |
1353 |
|
|
1354 |
|
static void |
1355 |
|
scale_rcolors( /* scale color map */ |
1356 |
< |
register XRASTER *xr, |
1356 |
> |
XRASTER *xr, |
1357 |
|
double sf |
1358 |
|
) |
1359 |
|
{ |
1360 |
< |
register int i; |
1360 |
> |
int i; |
1361 |
|
long maxv; |
1362 |
|
|
1363 |
|
if (xr->pixels == NULL) |
1388 |
|
{ |
1389 |
|
static int trunced = -1; /* truncated file? */ |
1390 |
|
skipit: |
1391 |
< |
if (trunced >= 0 && y >= trunced) { |
1392 |
< |
memset(scanline, '\0', xmax*sizeof(COLR)); |
1391 |
> |
if (y == cury-1) /* already got it? */ |
1392 |
> |
return(0); |
1393 |
> |
if ((trunced >= 0) & (y >= trunced)) { |
1394 |
> |
memset(scanline, 0, xmax*sizeof(COLR)); |
1395 |
|
return(-1); |
1396 |
|
} |
1397 |
|
if (y != cury) { |
1398 |
< |
if (scanpos == NULL || scanpos[y] == -1) |
1398 |
> |
if (scanpos == NULL || scanpos[y] < 0) |
1399 |
|
return(-1); |
1400 |
< |
if (fseek(fin, scanpos[y], 0) == -1) |
1400 |
> |
if (fseek(fin, scanpos[y], 0) < 0) |
1401 |
|
quiterr("fseek error"); |
1402 |
|
cury = y; |
1403 |
< |
} else if (scanpos != NULL && scanpos[y] == -1) |
1403 |
> |
} else if (scanpos != NULL && scanpos[y] < 0) |
1404 |
|
scanpos[y] = ftell(fin); |
1405 |
|
|
1406 |
|
if (fread2colrs(scanline, xmax, fin, NCSAMP, WLPART) < 0) { |