1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
96 |
|
quiterr("incompatible format"); |
97 |
|
/* put header */ |
98 |
|
printargs(i, argv, stdout); |
99 |
+ |
fputformat(COLRFMT, stdout); |
100 |
|
putchar('\n'); |
101 |
|
fputresolu(YMAJOR|YDECR, head.x, head.y, stdout); |
102 |
|
/* convert file */ |
103 |
|
tg2ra(&head); |
104 |
|
} else { |
105 |
< |
getheader(stdin, NULL); |
106 |
< |
if (fgetresolu(&head.x, &head.y, stdin) != (YMAJOR|YDECR)) |
105 |
> |
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
106 |
> |
fgetresolu(&head.x, &head.y, stdin) != (YMAJOR|YDECR)) |
107 |
|
quiterr("bad picture file"); |
108 |
|
/* assign header */ |
109 |
|
head.textSize = 0; |
291 |
|
colrs_gambs(inl, hp->x); |
292 |
|
if (hp->dataBits == 16) { |
293 |
|
register unsigned short *dp; |
294 |
+ |
register int v; |
295 |
|
dp = (unsigned short *)tarData + j*hp->x; |
296 |
|
for (i = 0; i < hp->x; i++) { |
297 |
< |
*dp = ((inl[i][RED]+(random()&7)) & 0xf8)<<7; |
298 |
< |
*dp |= ((inl[i][GRN]+(random()&7)) & 0xf8)<<2; |
299 |
< |
*dp++ |= (inl[i][BLU]+(random()&7))>>3; |
297 |
> |
v = inl[i][RED] + (random()&7); |
298 |
> |
if (v > 255) v = 255; |
299 |
> |
*dp = (v&0xf8)<<7; |
300 |
> |
v = inl[i][GRN] + (random()&7); |
301 |
> |
if (v > 255) v = 255; |
302 |
> |
*dp |= (v&0xf8)<<2; |
303 |
> |
v = inl[i][BLU] + (random()&7); |
304 |
> |
if (v > 255) v = 255; |
305 |
> |
*dp++ |= v>>3; |
306 |
|
} |
307 |
|
} else { /* hp->dataBits == 24 */ |
308 |
|
register unsigned char *dp; |
309 |
|
dp = (unsigned char *)tarData + j*3*hp->x; |
310 |
|
for (i = 0; i < hp->x; i++) { |
303 |
– |
*dp++ = inl[i][RED]; |
304 |
– |
*dp++ = inl[i][GRN]; |
311 |
|
*dp++ = inl[i][BLU]; |
312 |
+ |
*dp++ = inl[i][GRN]; |
313 |
+ |
*dp++ = inl[i][RED]; |
314 |
|
} |
315 |
|
} |
316 |
|
} |