109 |
|
COLOR col, |
110 |
|
SCOLOR scol, /* uses average over bands */ |
111 |
|
int ncs, |
112 |
< |
float wlpt[4] |
112 |
> |
const float wlpt[4] |
113 |
|
) |
114 |
|
{ |
115 |
|
const double step = (wlpt[3] - wlpt[0])/(double)ncs; |
136 |
|
COLR clr, |
137 |
|
SCOLOR scol, /* uses average over bands */ |
138 |
|
int ncs, |
139 |
< |
float wlpt[4] |
139 |
> |
const float wlpt[4] |
140 |
|
) |
141 |
|
{ |
142 |
|
COLOR col; |
262 |
|
di = (wl - dwl0)*rdstp; |
263 |
|
} else { |
264 |
|
wl = dwl0; |
265 |
< |
si = (wl - (sdir>0 ? swl0 : swl1))/sstp; |
266 |
< |
ssi = sdir > 0 ? si : snc-1 - si; |
265 |
> |
if (sdir > 0) { |
266 |
> |
ssi = si = (wl - swl0)/sstp; |
267 |
> |
} else { |
268 |
> |
si = (wl - swl1)/sstp; |
269 |
> |
ssi = snc-1 - si; |
270 |
> |
} |
271 |
|
di = 0; |
272 |
|
} |
273 |
|
swl0 += (sdir < 0)*sstp; |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
+ |
/* read an nc-component common-exponent color scanline */ |
492 |
|
int |
493 |
< |
fwritescan( /* write out a scanline */ |
493 |
> |
freadscolrs(uby8 *scanline, int nc, int len, FILE *fp) |
494 |
> |
{ |
495 |
> |
if (nc < 3) |
496 |
> |
return(-1); |
497 |
> |
if (nc == 3) |
498 |
> |
return(freadcolrs((COLR *)scanline, len, fp)); |
499 |
> |
|
500 |
> |
if (fread(scanline, nc+1, len, fp) != len) |
501 |
> |
return(-1); |
502 |
> |
return(0); |
503 |
> |
} |
504 |
> |
|
505 |
> |
|
506 |
> |
/* write an common-exponent spectral color scanline */ |
507 |
> |
int |
508 |
> |
fwritescolrs(uby8 *sscanline, int nc, int len, FILE *fp) |
509 |
> |
{ |
510 |
> |
if (nc < 3) |
511 |
> |
return(-1); |
512 |
> |
if (nc == 3) |
513 |
> |
return(fwritecolrs((COLR *)sscanline, len, fp)); |
514 |
> |
|
515 |
> |
if (fwrite(sscanline, nc+1, len, fp) != len) |
516 |
> |
return(-1); |
517 |
> |
return(0); |
518 |
> |
} |
519 |
> |
|
520 |
> |
|
521 |
> |
int |
522 |
> |
fwritescan( /* write out an RGB or XYZ scanline */ |
523 |
|
COLOR *scanline, |
524 |
|
int len, |
525 |
|
FILE *fp |
546 |
|
|
547 |
|
|
548 |
|
int |
549 |
< |
freadscan( /* read in a scanline */ |
549 |
> |
freadscan( /* read in an RGB or XYZ scanline */ |
550 |
|
COLOR *scanline, |
551 |
|
int len, |
552 |
|
FILE *fp |
571 |
|
colr_color(scanline[0], clrscan[0]); |
572 |
|
} |
573 |
|
return(0); |
574 |
+ |
} |
575 |
+ |
|
576 |
+ |
|
577 |
+ |
/* read an nc-component color scanline */ |
578 |
+ |
int |
579 |
+ |
freadsscan(COLORV *sscanline, int nc, int len, FILE *fp) |
580 |
+ |
{ |
581 |
+ |
uby8 *tscn = (uby8 *)tempbuffer((nc+1)*len); |
582 |
+ |
int i; |
583 |
+ |
|
584 |
+ |
if (tscn == NULL || freadscolrs(tscn, nc, len, fp) < 0) |
585 |
+ |
return(-1); |
586 |
+ |
for (i = len; i-- > 0; ) { |
587 |
+ |
scolr2scolor(sscanline, tscn, nc); |
588 |
+ |
sscanline += nc; |
589 |
+ |
tscn += nc+1; |
590 |
+ |
} |
591 |
+ |
return(0); |
592 |
+ |
} |
593 |
+ |
|
594 |
+ |
|
595 |
+ |
/* write an nc-component spectral color scanline */ |
596 |
+ |
int |
597 |
+ |
fwritesscan(COLORV *sscanline, int nc, int len, FILE *fp) |
598 |
+ |
{ |
599 |
+ |
uby8 *tscn = (uby8 *)tempbuffer((nc+1)*len); |
600 |
+ |
int i; |
601 |
+ |
|
602 |
+ |
if (tscn == NULL) |
603 |
+ |
return(-1); |
604 |
+ |
for (i = 0; i < len; i++) { |
605 |
+ |
scolor2scolr(tscn+i*(nc+1), sscanline, nc); |
606 |
+ |
sscanline += nc; |
607 |
+ |
} |
608 |
+ |
return(fwritescolrs(tscn, nc, len, fp)); |
609 |
|
} |
610 |
|
|
611 |
|
|