354 |
|
register COLOR col; |
355 |
|
register COLR clr; |
356 |
|
{ |
357 |
< |
double ldexp(), f; |
357 |
> |
double f; |
358 |
|
|
359 |
|
if (clr[EXP] == 0) |
360 |
|
col[RED] = col[GRN] = col[BLU] = 0.0; |
364 |
|
col[GRN] = (clr[GRN] + 0.5)*f; |
365 |
|
col[BLU] = (clr[BLU] + 0.5)*f; |
366 |
|
} |
367 |
+ |
} |
368 |
+ |
|
369 |
+ |
|
370 |
+ |
normcolrs(scan, len) /* normalize a scanline of colrs */ |
371 |
+ |
register COLR *scan; |
372 |
+ |
int len; |
373 |
+ |
{ |
374 |
+ |
register int c; |
375 |
+ |
register int shift; |
376 |
+ |
|
377 |
+ |
while (len-- > 0) { |
378 |
+ |
shift = scan[0][EXP] - COLXS; |
379 |
+ |
if (shift > 0) { |
380 |
+ |
if (shift >= 8) { |
381 |
+ |
scan[0][RED] = |
382 |
+ |
scan[0][GRN] = |
383 |
+ |
scan[0][BLU] = 255; |
384 |
+ |
} else { |
385 |
+ |
c = scan[0][RED] << shift; |
386 |
+ |
scan[0][RED] = c > 255 ? 255 : c; |
387 |
+ |
c = scan[0][GRN] << shift; |
388 |
+ |
scan[0][GRN] = c > 255 ? 255 : c; |
389 |
+ |
c = scan[0][BLU] << shift; |
390 |
+ |
scan[0][BLU] = c > 255 ? 255 : c; |
391 |
+ |
} |
392 |
+ |
} else if (shift < 0) { |
393 |
+ |
if (shift <= -8) { |
394 |
+ |
scan[0][RED] = |
395 |
+ |
scan[0][GRN] = |
396 |
+ |
scan[0][BLU] = 0; |
397 |
+ |
} else { |
398 |
+ |
scan[0][RED] = scan[0][RED] >> -shift; |
399 |
+ |
scan[0][GRN] = scan[0][GRN] >> -shift; |
400 |
+ |
scan[0][BLU] = scan[0][BLU] >> -shift; |
401 |
+ |
} |
402 |
+ |
} |
403 |
+ |
scan[0][EXP] = COLXS; |
404 |
+ |
scan++; |
405 |
+ |
} |
406 |
+ |
} |
407 |
+ |
|
408 |
+ |
|
409 |
+ |
bigdiff(c1, c2, md) /* c1 delta c2 > md? */ |
410 |
+ |
register COLOR c1, c2; |
411 |
+ |
double md; |
412 |
+ |
{ |
413 |
+ |
register int i; |
414 |
+ |
|
415 |
+ |
for (i = 0; i < 3; i++) |
416 |
+ |
if (colval(c1,i)-colval(c2,i) > md*colval(c2,i) || |
417 |
+ |
colval(c2,i)-colval(c1,i) > md*colval(c1,i)) |
418 |
+ |
return(1); |
419 |
+ |
return(0); |
420 |
|
} |