1 |
< |
/* Copyright (c) 1990 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
30 |
|
#include "pic.h" |
31 |
|
#include "x11raster.h" |
32 |
|
#include "random.h" |
33 |
+ |
#include "resolu.h" |
34 |
|
|
35 |
|
#define FONTNAME "8x13" /* text font we'll use */ |
36 |
|
|
37 |
< |
#define CTRL(c) ('c'-'@') |
37 |
> |
#define CTRL(c) ((c)-'@') |
38 |
|
|
39 |
|
#define BORWIDTH 5 /* border width */ |
40 |
|
|
41 |
|
#define ICONSIZ (8*10) /* maximum icon dimension (even 8) */ |
42 |
|
|
43 |
|
#define ourscreen DefaultScreen(thedisplay) |
43 |
– |
#define ourblack BlackPixel(thedisplay,ourscreen) |
44 |
– |
#define ourwhite WhitePixel(thedisplay,ourscreen) |
44 |
|
#define ourroot RootWindow(thedisplay,ourscreen) |
46 |
– |
#define ourgc DefaultGC(thedisplay,ourscreen) |
45 |
|
|
46 |
|
#define revline(x0,y0,x1,y1) XDrawLine(thedisplay,wind,revgc,x0,y0,x1,y1) |
47 |
|
|
52 |
|
int dither = 1; /* dither colors? */ |
53 |
|
int fast = 0; /* keep picture in Pixmap? */ |
54 |
|
|
55 |
+ |
char *dispname = NULL; /* our display name */ |
56 |
+ |
|
57 |
|
Window wind = 0; /* our output window */ |
58 |
+ |
unsigned long ourblack=0, ourwhite=1; /* black and white for this visual */ |
59 |
|
Font fontid; /* our font */ |
60 |
|
|
61 |
|
int maxcolors = 0; /* maximum colors */ |
71 |
|
|
72 |
|
COLR *scanline; /* scan line buffer */ |
73 |
|
|
74 |
< |
int xmax, ymax; /* picture resolution */ |
74 |
> |
RESOLU inpres; /* input resolution and ordering */ |
75 |
> |
int xmax, ymax; /* picture dimensions */ |
76 |
|
int width, height; /* window size */ |
77 |
|
char *fname = NULL; /* input file name */ |
78 |
|
FILE *fin = stdin; /* input file */ |
83 |
|
|
84 |
|
int wrongformat = 0; /* input in another format? */ |
85 |
|
|
86 |
+ |
GC ourgc; /* standard graphics context */ |
87 |
|
GC revgc; /* graphics context with GXinvert */ |
88 |
|
|
89 |
< |
XRASTER *ourras; /* our stored image */ |
89 |
> |
int *ourrank; /* our visual class ranking */ |
90 |
> |
XVisualInfo ourvis; /* our visual */ |
91 |
> |
XRASTER *ourras; /* our stored image */ |
92 |
|
unsigned char *ourdata; /* our image data */ |
93 |
|
|
94 |
|
struct { |
108 |
|
|
109 |
|
extern char *malloc(), *calloc(); |
110 |
|
|
111 |
< |
extern double atof(), pow(), log(); |
111 |
> |
extern double pow(), log(); |
112 |
|
|
113 |
|
Display *thedisplay; |
114 |
|
|
134 |
|
maxcolors = 2; |
135 |
|
break; |
136 |
|
case 'd': |
137 |
< |
dither = !dither; |
137 |
> |
if (argv[i][2] == 'i') |
138 |
> |
dispname = argv[++i]; |
139 |
> |
else |
140 |
> |
dither = !dither; |
141 |
|
break; |
142 |
|
case 'f': |
143 |
|
fast = !fast; |
148 |
|
scale = atoi(argv[++i]); |
149 |
|
break; |
150 |
|
case 'g': |
151 |
< |
if (!strcmp(argv[i], "-geometry")) |
151 |
> |
if (argv[i][2] == 'e') |
152 |
|
geometry = argv[++i]; |
153 |
|
else |
154 |
|
gamcor = atof(argv[++i]); |
165 |
|
fname = argv[i]; |
166 |
|
fin = fopen(fname, "r"); |
167 |
|
if (fin == NULL) { |
168 |
< |
sprintf(errmsg, "can't open file \"%s\"", fname); |
168 |
> |
sprintf(errmsg, "cannot open file \"%s\"", fname); |
169 |
|
quiterr(errmsg); |
170 |
|
} |
171 |
|
} else if (i != argc) |
173 |
|
/* get header */ |
174 |
|
getheader(fin, headline, NULL); |
175 |
|
/* get picture dimensions */ |
176 |
< |
if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
176 |
> |
if (wrongformat || !fgetsresolu(&inpres, fin)) |
177 |
|
quiterr("bad picture format"); |
178 |
+ |
xmax = scanlen(&inpres); |
179 |
+ |
ymax = numscans(&inpres); |
180 |
|
/* set view parameters */ |
181 |
|
if (gotview && setview(&ourview) != NULL) |
182 |
|
gotview = 0; |
189 |
|
getevent(); /* main loop */ |
190 |
|
userr: |
191 |
|
fprintf(stderr, |
192 |
< |
"Usage: %s [-geometry spec][-b][-m][-d][-f][-c ncolors][-e +/-stops] file\n", |
192 |
> |
"Usage: %s [-display disp][-geometry spec][-b][-m][-d][-f][-c ncolors][-e +/-stops] file\n", |
193 |
|
progname); |
194 |
|
quit(1); |
195 |
|
} |
198 |
|
headline(s) /* get relevant info from header */ |
199 |
|
char *s; |
200 |
|
{ |
191 |
– |
static char *altname[] = {"rview","rpict","pinterp",VIEWSTR,NULL}; |
192 |
– |
register char **an; |
201 |
|
char fmt[32]; |
202 |
|
|
203 |
|
if (isexpos(s)) |
205 |
|
else if (isformat(s)) { |
206 |
|
formatval(fmt, s); |
207 |
|
wrongformat = strcmp(fmt, COLRFMT); |
208 |
< |
} else |
209 |
< |
for (an = altname; *an != NULL; an++) |
202 |
< |
if (!strncmp(*an, s, strlen(*an))) { |
203 |
< |
if (sscanview(&ourview, s+strlen(*an)) > 0) |
204 |
< |
gotview++; |
205 |
< |
return; |
206 |
< |
} |
208 |
> |
} else if (isview(s) && sscanview(&ourview, s) > 0) |
209 |
> |
gotview++; |
210 |
|
} |
211 |
|
|
212 |
|
|
214 |
|
{ |
215 |
|
XWMHints ourxwmhints; |
216 |
|
XSetWindowAttributes ourwinattr; |
217 |
< |
XSizeHints oursizhints; |
218 |
< |
register int i; |
217 |
> |
XSizeHints oursizhints; |
218 |
> |
register int i; |
219 |
|
|
220 |
|
if (fname != NULL) { |
221 |
|
scanpos = (long *)malloc(ymax*sizeof(long)); |
224 |
|
for (i = 0; i < ymax; i++) |
225 |
|
scanpos[i] = -1; |
226 |
|
} |
227 |
< |
if ((thedisplay = XOpenDisplay(NULL)) == NULL) |
228 |
< |
quiterr("can't open display; DISPLAY variable set?"); |
229 |
< |
if (maxcolors == 0) { /* get number of available colors */ |
230 |
< |
i = DisplayPlanes(thedisplay,ourscreen); |
228 |
< |
maxcolors = i > 8 ? 256 : 1<<i; |
229 |
< |
if (maxcolors > 4) maxcolors -= 2; |
230 |
< |
} |
227 |
> |
if ((thedisplay = XOpenDisplay(dispname)) == NULL) |
228 |
> |
quiterr("cannot open display"); |
229 |
> |
/* get best visual for default screen */ |
230 |
> |
getbestvis(); |
231 |
|
/* store image */ |
232 |
|
getras(); |
233 |
|
/* open window */ |
234 |
|
ourwinattr.border_pixel = ourblack; |
235 |
|
ourwinattr.background_pixel = ourwhite; |
236 |
+ |
ourwinattr.colormap = XCreateColormap(thedisplay, ourroot, |
237 |
+ |
ourvis.visual, AllocNone); |
238 |
|
wind = XCreateWindow(thedisplay, ourroot, 0, 0, xmax, ymax, BORWIDTH, |
239 |
< |
0, InputOutput, ourras->visual, |
240 |
< |
CWBackPixel|CWBorderPixel, &ourwinattr); |
239 |
> |
ourvis.depth, InputOutput, ourvis.visual, |
240 |
> |
CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr); |
241 |
|
if (wind == 0) |
242 |
< |
quiterr("can't create window"); |
242 |
> |
quiterr("cannot create window"); |
243 |
> |
XFreeColormap(thedisplay, ourwinattr.colormap); |
244 |
|
width = xmax; |
245 |
|
height = ymax; |
246 |
+ |
ourgc = XCreateGC(thedisplay, wind, 0, 0); |
247 |
+ |
XSetState(thedisplay, ourgc, ourblack, ourwhite, GXcopy, AllPlanes); |
248 |
+ |
revgc = XCreateGC(thedisplay, wind, 0, 0); |
249 |
+ |
XSetFunction(thedisplay, revgc, GXinvert); |
250 |
|
fontid = XLoadFont(thedisplay, FONTNAME); |
251 |
|
if (fontid == 0) |
252 |
< |
quiterr("can't get font"); |
252 |
> |
quiterr("cannot get font"); |
253 |
|
XSetFont(thedisplay, ourgc, fontid); |
247 |
– |
revgc = XCreateGC(thedisplay, wind, 0, 0); |
248 |
– |
XSetFunction(thedisplay, revgc, GXinvert); |
254 |
|
XDefineCursor(thedisplay, wind, XCreateFontCursor(thedisplay, |
255 |
|
XC_diamond_cross)); |
256 |
|
XStoreName(thedisplay, wind, fname == NULL ? progname : fname); |
317 |
|
} |
318 |
|
|
319 |
|
|
320 |
+ |
static int |
321 |
+ |
viscmp(v1,v2) /* compare visual to see which is better, descending */ |
322 |
+ |
register XVisualInfo *v1, *v2; |
323 |
+ |
{ |
324 |
+ |
int bad1 = 0, bad2 = 0; |
325 |
+ |
register int *rp; |
326 |
+ |
|
327 |
+ |
if (v1->class == v2->class) { |
328 |
+ |
if (v1->class == TrueColor || v1->class == DirectColor) { |
329 |
+ |
/* prefer 24-bit to 32-bit */ |
330 |
+ |
if (v1->depth == 24 && v2->depth == 32) |
331 |
+ |
return(-1); |
332 |
+ |
if (v1->depth == 32 && v2->depth == 24) |
333 |
+ |
return(1); |
334 |
+ |
return(0); |
335 |
+ |
} |
336 |
+ |
/* don't be too greedy */ |
337 |
+ |
if (maxcolors <= 1<<v1->depth && maxcolors <= 1<<v2->depth) |
338 |
+ |
return(v1->depth - v2->depth); |
339 |
+ |
return(v2->depth - v1->depth); |
340 |
+ |
} |
341 |
+ |
/* prefer Pseudo when < 24-bit */ |
342 |
+ |
if ((v1->class == TrueColor || v1->class == DirectColor) && |
343 |
+ |
v1->depth < 24) |
344 |
+ |
bad1 = 1; |
345 |
+ |
if ((v2->class == TrueColor || v2->class == DirectColor) && |
346 |
+ |
v2->depth < 24) |
347 |
+ |
bad2 = -1; |
348 |
+ |
if (bad1 | bad2) |
349 |
+ |
return(bad1+bad2); |
350 |
+ |
/* otherwise, use class ranking */ |
351 |
+ |
for (rp = ourrank; *rp != -1; rp++) { |
352 |
+ |
if (v1->class == *rp) |
353 |
+ |
return(-1); |
354 |
+ |
if (v2->class == *rp) |
355 |
+ |
return(1); |
356 |
+ |
} |
357 |
+ |
return(0); |
358 |
+ |
} |
359 |
+ |
|
360 |
+ |
|
361 |
+ |
getbestvis() /* get the best visual for this screen */ |
362 |
+ |
{ |
363 |
+ |
#ifdef DEBUG |
364 |
+ |
static char vistype[][12] = { |
365 |
+ |
"StaticGray", |
366 |
+ |
"GrayScale", |
367 |
+ |
"StaticColor", |
368 |
+ |
"PseudoColor", |
369 |
+ |
"TrueColor", |
370 |
+ |
"DirectColor" |
371 |
+ |
}; |
372 |
+ |
#endif |
373 |
+ |
static int rankings[3][6] = { |
374 |
+ |
{TrueColor,DirectColor,PseudoColor,GrayScale,StaticGray,-1}, |
375 |
+ |
{PseudoColor,GrayScale,StaticGray,-1}, |
376 |
+ |
{PseudoColor,GrayScale,StaticGray,-1} |
377 |
+ |
}; |
378 |
+ |
XVisualInfo *xvi; |
379 |
+ |
int vismatched; |
380 |
+ |
register int i, j; |
381 |
+ |
|
382 |
+ |
if (greyscale) { |
383 |
+ |
ourrank = rankings[2]; |
384 |
+ |
if (maxcolors < 2) maxcolors = 256; |
385 |
+ |
} else if (maxcolors >= 2 && maxcolors <= 256) |
386 |
+ |
ourrank = rankings[1]; |
387 |
+ |
else { |
388 |
+ |
ourrank = rankings[0]; |
389 |
+ |
maxcolors = 256; |
390 |
+ |
} |
391 |
+ |
/* find best visual */ |
392 |
+ |
ourvis.screen = ourscreen; |
393 |
+ |
xvi = XGetVisualInfo(thedisplay,VisualScreenMask,&ourvis,&vismatched); |
394 |
+ |
if (xvi == NULL) |
395 |
+ |
quiterr("no visuals for this screen!"); |
396 |
+ |
#ifdef DEBUG |
397 |
+ |
fprintf(stderr, "Supported visuals:\n"); |
398 |
+ |
for (i = 0; i < vismatched; i++) |
399 |
+ |
fprintf(stderr, "\ttype %s, depth %d\n", |
400 |
+ |
vistype[xvi[i].class], xvi[i].depth); |
401 |
+ |
#endif |
402 |
+ |
for (i = 0, j = 1; j < vismatched; j++) |
403 |
+ |
if (viscmp(&xvi[i],&xvi[j]) > 0) |
404 |
+ |
i = j; |
405 |
+ |
/* compare to least acceptable */ |
406 |
+ |
for (j = 0; ourrank[j++] != -1; ) |
407 |
+ |
; |
408 |
+ |
ourvis.class = ourrank[--j]; |
409 |
+ |
ourvis.depth = 1; |
410 |
+ |
if (viscmp(&xvi[i],&ourvis) > 0) |
411 |
+ |
quiterr("inadequate visuals on this screen"); |
412 |
+ |
/* OK, we'll use it */ |
413 |
+ |
copystruct(&ourvis, &xvi[i]); |
414 |
+ |
#ifdef DEBUG |
415 |
+ |
fprintf(stderr, "Selected visual type %s, depth %d\n", |
416 |
+ |
vistype[ourvis.class], ourvis.depth); |
417 |
+ |
#endif |
418 |
+ |
/* make appropriate adjustments */ |
419 |
+ |
if (ourvis.class == GrayScale || ourvis.class == StaticGray) |
420 |
+ |
greyscale = 1; |
421 |
+ |
if (ourvis.depth <= 8 && ourvis.colormap_size < maxcolors) |
422 |
+ |
maxcolors = ourvis.colormap_size; |
423 |
+ |
if (maxcolors > 4) |
424 |
+ |
maxcolors -= 2; |
425 |
+ |
if (ourvis.class == StaticGray) { |
426 |
+ |
ourblack = 0; |
427 |
+ |
ourwhite = 255; |
428 |
+ |
} else if (ourvis.class == PseudoColor) { |
429 |
+ |
ourblack = BlackPixel(thedisplay,ourscreen); |
430 |
+ |
ourwhite = WhitePixel(thedisplay,ourscreen); |
431 |
+ |
if ((ourblack|ourwhite) & ~255L) { |
432 |
+ |
ourblack = 0; |
433 |
+ |
ourwhite = 1; |
434 |
+ |
} |
435 |
+ |
} else { |
436 |
+ |
ourblack = 0; |
437 |
+ |
ourwhite = ourvis.red_mask|ourvis.green_mask|ourvis.blue_mask; |
438 |
+ |
} |
439 |
+ |
XFree((char *)xvi); |
440 |
+ |
} |
441 |
+ |
|
442 |
+ |
|
443 |
|
getras() /* get raster file */ |
444 |
|
{ |
445 |
|
colormap ourmap; |
449 |
|
ourdata = (unsigned char *)malloc(ymax*((xmax+7)/8)); |
450 |
|
if (ourdata == NULL) |
451 |
|
goto fail; |
452 |
< |
ourras = make_raster(thedisplay, ourscreen, 1, ourdata, |
452 |
> |
ourras = make_raster(thedisplay, &ourvis, 1, ourdata, |
453 |
|
xmax, ymax, 8); |
454 |
|
if (ourras == NULL) |
455 |
|
goto fail; |
456 |
|
getmono(); |
457 |
< |
} else if (XMatchVisualInfo(thedisplay,ourscreen,24,TrueColor,&vinfo) |
458 |
< |
/* kludge for DirectColor */ |
331 |
< |
|| XMatchVisualInfo(thedisplay,ourscreen,24,DirectColor,&vinfo)) { |
332 |
< |
ourdata = (unsigned char *)malloc(xmax*ymax*3); |
457 |
> |
} else if (ourvis.class == TrueColor || ourvis.class == DirectColor) { |
458 |
> |
ourdata = (unsigned char *)malloc(4*xmax*ymax); |
459 |
|
if (ourdata == NULL) |
460 |
|
goto fail; |
461 |
< |
ourras = make_raster(thedisplay, ourscreen, 24, ourdata, |
462 |
< |
xmax, ymax, 8); |
461 |
> |
ourras = make_raster(thedisplay, &ourvis, 32, |
462 |
> |
ourdata, xmax, ymax, 32); |
463 |
|
if (ourras == NULL) |
464 |
|
goto fail; |
465 |
|
getfull(); |
467 |
|
ourdata = (unsigned char *)malloc(xmax*ymax); |
468 |
|
if (ourdata == NULL) |
469 |
|
goto fail; |
470 |
< |
ourras = make_raster(thedisplay, ourscreen, 8, ourdata, |
470 |
> |
ourras = make_raster(thedisplay, &ourvis, 8, ourdata, |
471 |
|
xmax, ymax, 8); |
472 |
|
if (ourras == NULL) |
473 |
|
goto fail; |
474 |
< |
if (greyscale) |
475 |
< |
biq(dither,maxcolors,1,ourmap); |
476 |
< |
else |
477 |
< |
ciq(dither,maxcolors,1,ourmap); |
478 |
< |
if (init_rcolors(ourras, ourmap[0], ourmap[1], ourmap[2]) == 0) |
479 |
< |
goto fail; |
474 |
> |
if (ourvis.class == StaticGray) |
475 |
> |
getgrey(); |
476 |
> |
else { |
477 |
> |
if (greyscale) |
478 |
> |
biq(dither,maxcolors,1,ourmap); |
479 |
> |
else |
480 |
> |
ciq(dither,maxcolors,1,ourmap); |
481 |
> |
if (init_rcolors(ourras, ourmap[0], |
482 |
> |
ourmap[1], ourmap[2]) == 0) |
483 |
> |
goto fail; |
484 |
> |
} |
485 |
|
} |
486 |
< |
return; |
486 |
> |
return; |
487 |
|
fail: |
488 |
|
quiterr("could not create raster image"); |
489 |
|
} |
511 |
|
case MapNotify: |
512 |
|
map_rcolors(ourras, wind); |
513 |
|
if (fast) |
514 |
< |
make_rpixmap(ourras); |
514 |
> |
make_rpixmap(ourras, wind); |
515 |
|
break; |
516 |
|
case UnmapNotify: |
517 |
< |
unmap_rcolors(ourras); |
517 |
> |
if (!fast) |
518 |
> |
unmap_rcolors(ourras); |
519 |
|
break; |
520 |
|
case Expose: |
521 |
|
redraw(e.e.x, e.e.y, e.e.width, e.e.height); |
538 |
|
XColor cvx; |
539 |
|
int com, n; |
540 |
|
double comp; |
541 |
+ |
FLOAT hv[2]; |
542 |
|
FVECT rorg, rdir; |
543 |
|
|
544 |
|
n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL); |
547 |
|
com = buf[0]; |
548 |
|
switch (com) { /* interpret command */ |
549 |
|
case 'q': |
550 |
< |
case CTRL(D): /* quit */ |
550 |
> |
case CTRL('D'): /* quit */ |
551 |
|
quit(0); |
552 |
|
case '\n': |
553 |
|
case '\r': |
587 |
|
XStoreColor(thedisplay, ourras->cmap, &cvx); |
588 |
|
return(0); |
589 |
|
case 'p': /* position */ |
590 |
< |
sprintf(buf, "(%d,%d)", ekey->x-xoff, ymax-1-ekey->y+yoff); |
590 |
> |
pix2loc(hv, &inpres, ekey->x-xoff, ekey->y-yoff); |
591 |
> |
sprintf(buf, "(%d,%d)", (int)(hv[0]*inpres.xr), |
592 |
> |
(int)(hv[1]*inpres.yr)); |
593 |
|
XDrawImageString(thedisplay, wind, ourgc, ekey->x, ekey->y, |
594 |
|
buf, strlen(buf)); |
595 |
|
return(0); |
598 |
|
XBell(thedisplay, 0); |
599 |
|
return(-1); |
600 |
|
} |
601 |
< |
if (viewray(rorg, rdir, &ourview, |
602 |
< |
(ekey->x-xoff+.5)/xmax, |
468 |
< |
(ymax-1-ekey->y+yoff+.5)/ymax) < 0) |
601 |
> |
pix2loc(hv, &inpres, ekey->x-xoff, ekey->y-yoff); |
602 |
> |
if (viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0) |
603 |
|
return(-1); |
604 |
|
printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); |
605 |
|
printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); |
621 |
|
free_raster(ourras); |
622 |
|
getras(); |
623 |
|
/* fall through */ |
624 |
< |
case CTRL(R): /* redraw */ |
625 |
< |
case CTRL(L): |
624 |
> |
case CTRL('R'): /* redraw */ |
625 |
> |
case CTRL('L'): |
626 |
|
unmap_rcolors(ourras); |
627 |
|
XClearWindow(thedisplay, wind); |
628 |
|
map_rcolors(ourras, wind); |
714 |
|
avgbox(clr) /* average color over current box */ |
715 |
|
COLOR clr; |
716 |
|
{ |
717 |
+ |
static COLOR lc; |
718 |
+ |
static int ll, lr, lt, lb; |
719 |
|
int left, right, top, bottom; |
720 |
|
int y; |
721 |
|
double d; |
739 |
|
bottom = ymax; |
740 |
|
if (top >= bottom) |
741 |
|
return(-1); |
742 |
+ |
if (left == ll && right == lr && top == lt && bottom == lb) { |
743 |
+ |
copycolor(clr, lc); |
744 |
+ |
return; |
745 |
+ |
} |
746 |
|
for (y = top; y < bottom; y++) { |
747 |
|
if (getscan(y) == -1) |
748 |
|
return(-1); |
753 |
|
} |
754 |
|
d = 1.0/((right-left)*(bottom-top)); |
755 |
|
scalecolor(clr, d); |
756 |
+ |
ll = left; lr = right; lt = top; lb = bottom; |
757 |
+ |
copycolor(lc, clr); |
758 |
|
return(0); |
759 |
|
} |
760 |
|
|
844 |
|
getfull() /* get full (24-bit) data */ |
845 |
|
{ |
846 |
|
int y; |
847 |
+ |
register unsigned long *dp; |
848 |
+ |
register int x; |
849 |
+ |
/* set gamma correction */ |
850 |
+ |
setcolrgam(gamcor); |
851 |
+ |
/* read and convert file */ |
852 |
+ |
dp = (unsigned long *)ourdata; |
853 |
+ |
for (y = 0; y < ymax; y++) { |
854 |
+ |
if (getscan(y) < 0) |
855 |
+ |
quiterr("seek error in getfull"); |
856 |
+ |
if (scale) |
857 |
+ |
shiftcolrs(scanline, xmax, scale); |
858 |
+ |
colrs_gambs(scanline, xmax); |
859 |
+ |
add2icon(y, scanline); |
860 |
+ |
if (ourras->image->blue_mask & 1) |
861 |
+ |
for (x = 0; x < xmax; x++) |
862 |
+ |
*dp++ = scanline[x][RED] << 16 | |
863 |
+ |
scanline[x][GRN] << 8 | |
864 |
+ |
scanline[x][BLU] ; |
865 |
+ |
else |
866 |
+ |
for (x = 0; x < xmax; x++) |
867 |
+ |
*dp++ = scanline[x][RED] | |
868 |
+ |
scanline[x][GRN] << 8 | |
869 |
+ |
scanline[x][BLU] << 16 ; |
870 |
+ |
} |
871 |
+ |
} |
872 |
+ |
|
873 |
+ |
|
874 |
+ |
getgrey() /* get greyscale data */ |
875 |
+ |
{ |
876 |
+ |
int y; |
877 |
|
register unsigned char *dp; |
878 |
|
register int x; |
879 |
|
/* set gamma correction */ |
887 |
|
shiftcolrs(scanline, xmax, scale); |
888 |
|
colrs_gambs(scanline, xmax); |
889 |
|
add2icon(y, scanline); |
890 |
< |
for (x = 0; x < xmax; x++) { |
891 |
< |
*dp++ = scanline[x][RED]; |
892 |
< |
*dp++ = scanline[x][GRN]; |
893 |
< |
*dp++ = scanline[x][BLU]; |
894 |
< |
} |
890 |
> |
if (ourvis.colormap_size < 256) |
891 |
> |
for (x = 0; x < xmax; x++) |
892 |
> |
*dp++ = ((long)normbright(scanline[x]) * |
893 |
> |
ourvis.colormap_size + 128) >> 8; |
894 |
> |
else |
895 |
> |
for (x = 0; x < xmax; x++) |
896 |
> |
*dp++ = normbright(scanline[x]); |
897 |
|
} |
898 |
|
} |
899 |
|
|
989 |
|
picwritecm(map) /* handled elsewhere */ |
990 |
|
colormap map; |
991 |
|
{ |
992 |
< |
#ifdef DEBUG |
992 |
> |
#if 0 |
993 |
|
register int i; |
994 |
|
|
995 |
|
for (i = 0; i < 256; i++) |