--- ray/src/px/ximage.c 1991/05/01 12:40:03 1.30 +++ ray/src/px/ximage.c 2003/04/23 00:52:34 2.10 @@ -1,9 +1,6 @@ -/* Copyright (c) 1987 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ximage.c,v 2.10 2003/04/23 00:52:34 greg Exp $"; #endif - /* * ximage.c - driver for X-windows * @@ -21,8 +18,12 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include "color.h" +#include "resolu.h" + #include "xraster.h" #include "view.h" @@ -35,7 +36,7 @@ static char SCCSid[] = "$SunId$ LBL"; #define FONTNAME "9x15" /* text font we'll use */ -#define CTRL(c) ('c'-'@') +#define CTRL(c) ((c)-'@') #define BORWIDTH 5 /* border width */ #define BARHEIGHT 25 /* menu bar size */ @@ -84,21 +85,19 @@ char *progname; char errmsg[128]; -extern long ftell(); -extern char *malloc(), *calloc(); - -extern double atof(), pow(), log(); - - main(argc, argv) int argc; char *argv[]; { + extern char *getenv(); + char *gv; int headline(); int i; progname = argv[0]; + if ((gv = getenv("DISPLAY_GAMMA")) != NULL) + gamcor = atof(gv); for (i = 1; i < argc; i++) if (argv[i][0] == '-') @@ -165,11 +164,10 @@ userr: } +int headline(s) /* get relevant info from header */ char *s; { - static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; - register char **an; char fmt[32]; if (isexpos(s)) @@ -177,13 +175,9 @@ char *s; else if (isformat(s)) { formatval(fmt, s); wrongformat = strcmp(fmt, COLRFMT); - } else - for (an = altname; *an != NULL; an++) - if (!strncmp(*an, s, strlen(*an))) { - if (sscanview(&ourview, s+strlen(*an)) > 0) - gotview++; - return; - } + } else if (isview(s) && sscanview(&ourview, s) > 0) + gotview++; + return(0); } @@ -252,6 +246,7 @@ char *err; } +void eputs(s) char *s; { @@ -259,6 +254,7 @@ char *s; } +void quit(code) int code; { @@ -365,7 +361,7 @@ XKeyEvent *ekey; return(0); switch (*cp) { /* interpret command */ case 'q': - case CTRL(D): /* quit */ + case CTRL('D'): /* quit */ quit(0); case '\n': case '\r': @@ -435,8 +431,8 @@ XKeyEvent *ekey; free_raster(ourras); getras(); /* fall through */ - case CTRL(R): /* redraw */ - case CTRL(L): + case CTRL('R'): /* redraw */ + case CTRL('L'): unmap_rcolors(ourras); XClear(wind); return(redraw(0, 0, width, height)); @@ -548,7 +544,7 @@ getmono() /* get monochrome data */ { register unsigned short *dp; register int x, err; - int y; + int y, errp; rgbpixel *inl; short *cerr; @@ -562,16 +558,18 @@ getmono() /* get monochrome data */ for (x = 0; x < xmax; x++) { if (!(x&0xf)) *++dp = 0; + errp = err; err += rgb_bright(&inl[x]) + cerr[x]; if (err > 127) err -= 255; else *dp |= 1<<(x&0xf); - cerr[x] = err >>= 1; + err /= 3; + cerr[x] = err + errp; } } - free((char *)inl); - free((char *)cerr); + free((void *)inl); + free((void *)cerr); } @@ -599,7 +597,7 @@ colormap cmap; xr->cdefs[xr->ncolors].pixel = *p; xr->pmap[*p] = xr->ncolors++; } - xr->cdefs = (Color *)realloc((char *)xr->cdefs, xr->ncolors*sizeof(Color)); + xr->cdefs = (Color *)realloc((void *)xr->cdefs, xr->ncolors*sizeof(Color)); if (xr->cdefs == NULL) return(0); return(1); @@ -643,7 +641,7 @@ int y; if (fseek(fin, scanpos[y], 0) == -1) quiterr("fseek error"); cury = y; - } else if (scanpos != NULL) + } else if (scanpos != NULL && scanpos[y] == -1) scanpos[y] = ftell(fin); if (freadcolrs(scanline, xmax, fin) < 0)