229 |
|
} |
230 |
|
|
231 |
|
|
232 |
– |
normcolrs(scan, len, adjust) /* normalize a scanline of colrs */ |
233 |
– |
register COLR *scan; |
234 |
– |
int len; |
235 |
– |
int adjust; |
236 |
– |
{ |
237 |
– |
register int c; |
238 |
– |
register int shift; |
239 |
– |
|
240 |
– |
while (len-- > 0) { |
241 |
– |
shift = scan[0][EXP] + adjust - COLXS; |
242 |
– |
if (shift > 0) { |
243 |
– |
if (shift > 8) { |
244 |
– |
scan[0][RED] = |
245 |
– |
scan[0][GRN] = |
246 |
– |
scan[0][BLU] = 255; |
247 |
– |
} else { |
248 |
– |
shift--; |
249 |
– |
c = (scan[0][RED]<<1 | 1) << shift; |
250 |
– |
scan[0][RED] = c > 255 ? 255 : c; |
251 |
– |
c = (scan[0][GRN]<<1 | 1) << shift; |
252 |
– |
scan[0][GRN] = c > 255 ? 255 : c; |
253 |
– |
c = (scan[0][BLU]<<1 | 1) << shift; |
254 |
– |
scan[0][BLU] = c > 255 ? 255 : c; |
255 |
– |
} |
256 |
– |
} else if (shift < 0) { |
257 |
– |
if (shift < -8) { |
258 |
– |
scan[0][RED] = |
259 |
– |
scan[0][GRN] = |
260 |
– |
scan[0][BLU] = 0; |
261 |
– |
} else { |
262 |
– |
shift = -1-shift; |
263 |
– |
scan[0][RED] = ((scan[0][RED]>>shift)+1)>>1; |
264 |
– |
scan[0][GRN] = ((scan[0][GRN]>>shift)+1)>>1; |
265 |
– |
scan[0][BLU] = ((scan[0][BLU]>>shift)+1)>>1; |
266 |
– |
} |
267 |
– |
} |
268 |
– |
scan[0][EXP] = COLXS - adjust; |
269 |
– |
scan++; |
270 |
– |
} |
271 |
– |
} |
272 |
– |
|
273 |
– |
|
232 |
|
bigdiff(c1, c2, md) /* c1 delta c2 > md? */ |
233 |
|
register COLOR c1, c2; |
234 |
|
double md; |