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"; |
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; |