21 |
|
* to tristimulus should use scolor_rgb() or scolor_cie(). |
22 |
|
* |
23 |
|
* A new Radiance format is provided for spectral pictures, |
24 |
< |
* and spectral colors must be converted by caller using |
25 |
< |
* convertscolor() if the sampling doesn't match. |
24 |
> |
* and spectral colors must be converted by caller if the |
25 |
> |
* sampling doesn't match. |
26 |
|
*/ |
27 |
|
#ifndef _RAD_COLOR_H_ |
28 |
|
#define _RAD_COLOR_H_ |
107 |
|
|
108 |
|
#define scolrblack(c) memset(c,0,LSCOLR) |
109 |
|
|
110 |
< |
#define scolorblack(c) memset(c,0,sizeof(COLORV)*MAXCSAMP) |
110 |
> |
#define scolorblack(c) memset(c,0,sizeof(COLORV)*NCSAMP) |
111 |
|
|
112 |
|
#define scolor_color(col,scol) scolor2color(col,scol,NCSAMP,WLPART) |
113 |
|
#define scolor_colr(clr,scol) scolor2colr(clr,scol,NCSAMP,WLPART) |
116 |
|
#define scolr_color(col,sclr) scolr2color(col,sclr,NCSAMP,WLPART) |
117 |
|
|
118 |
|
#define sopcolor(sc1,op,c2) {SCOLOR _sct;\ |
119 |
< |
setscolor(_sct,c2[RED],c2[GRN],c2[BLU]);\ |
119 |
> |
setscolor(_sct,(c2)[RED],(c2)[GRN],(c2)[BLU]);\ |
120 |
|
sopscolor(sc1,op,_sct);} |
121 |
|
|
122 |
|
#define saddcolor(sc1,c2) sopcolor(sc1,+=,c2) |
239 |
|
#define COLRFMT "32-bit_rle_rgbe" |
240 |
|
#define CIEFMT "32-bit_rle_xyze" |
241 |
|
#define PICFMT "32-bit_rle_???e" /* matches either */ |
242 |
< |
#define SPECFMT "Radiance_rle_spectra" /* spectral data w/ exponent */ |
243 |
< |
#define LPICFMT 21 /* max format id len */ |
242 |
> |
#define SPECFMT "Radiance_spectra" /* spectral data w/ exponent */ |
243 |
|
|
244 |
|
/* Number of spectral components */ |
245 |
|
#define NCOMPSTR "NCOMP=" |
246 |
|
#define LNCOMPSTR 6 |
247 |
< |
#define isncomp(hl) (!strncmp(hl,NCOMPSTR,LNCOMPSTR)) |
247 |
> |
#define isncomp(hl) !strncmp(hl,NCOMPSTR,LNCOMPSTR) |
248 |
|
#define ncompval(hl) atoi((hl)+LNCOMPSTR) |
249 |
|
#define fputncomp(nc,fp) fprintf(fp,"%s%d\n",NCOMPSTR,nc) |
250 |
|
|
251 |
|
/* 4 wavelength partitions for (IR+)R,G,B(+UV) */ |
252 |
|
#define WLSPLTSTR "WAVELENGTH_SPLITS=" |
253 |
|
#define LWLSPLTSTR 18 |
254 |
< |
#define iswlsplit(hl) (!strncmp(hl,WLSPLTSTR,LWLSPLTSTR)) |
254 |
> |
#define iswlsplit(hl) !strncmp(hl,WLSPLTSTR,LWLSPLTSTR) |
255 |
|
#define wlsplitval(w,hl) (sscanf((hl)+LWLSPLTSTR,"%f %f %f %f",\ |
256 |
|
&(w)[0],&(w)[1],&(w)[2],&(w)[3]) == 4) |
257 |
|
#define fputwlsplit(w,fp) fprintf(fp,"%s %g %g %g %g\n",WLSPLTSTR,\ |
260 |
|
/* macros for exposures */ |
261 |
|
#define EXPOSSTR "EXPOSURE=" |
262 |
|
#define LEXPOSSTR 9 |
263 |
< |
#define isexpos(hl) (!strncmp(hl,EXPOSSTR,LEXPOSSTR)) |
263 |
> |
#define isexpos(hl) !strncmp(hl,EXPOSSTR,LEXPOSSTR) |
264 |
|
#define exposval(hl) atof((hl)+LEXPOSSTR) |
265 |
|
#define fputexpos(ex,fp) fprintf(fp,"%s%.4e\n",EXPOSSTR,ex) |
266 |
|
|
267 |
|
/* macros for pixel aspect ratios */ |
268 |
|
#define ASPECTSTR "PIXASPECT=" |
269 |
|
#define LASPECTSTR 10 |
270 |
< |
#define isaspect(hl) (!strncmp(hl,ASPECTSTR,LASPECTSTR)) |
270 |
> |
#define isaspect(hl) !strncmp(hl,ASPECTSTR,LASPECTSTR) |
271 |
|
#define aspectval(hl) atof((hl)+LASPECTSTR) |
272 |
|
#define fputaspect(pa,fp) fprintf(fp,"%s%f\n",ASPECTSTR,pa) |
273 |
|
|
274 |
|
/* macros for primary specifications */ |
275 |
|
#define PRIMARYSTR "PRIMARIES=" |
276 |
|
#define LPRIMARYSTR 10 |
277 |
< |
#define isprims(hl) (!strncmp(hl,PRIMARYSTR,LPRIMARYSTR)) |
277 |
> |
#define isprims(hl) !strncmp(hl,PRIMARYSTR,LPRIMARYSTR) |
278 |
|
#define primsval(p,hl) (sscanf((hl)+LPRIMARYSTR, \ |
279 |
|
"%f %f %f %f %f %f %f %f", \ |
280 |
|
&(p)[RED][CIEX],&(p)[RED][CIEY], \ |
292 |
|
/* macros for color correction */ |
293 |
|
#define COLCORSTR "COLORCORR=" |
294 |
|
#define LCOLCORSTR 10 |
295 |
< |
#define iscolcor(hl) (!strncmp(hl,COLCORSTR,LCOLCORSTR)) |
295 |
> |
#define iscolcor(hl) !strncmp(hl,COLCORSTR,LCOLCORSTR) |
296 |
|
#define colcorval(cc,hl) sscanf((hl)+LCOLCORSTR,"%f %f %f", \ |
297 |
|
&(cc)[RED],&(cc)[GRN],&(cc)[BLU]) |
298 |
|
#define fputcolcor(cc,fp) fprintf(fp,"%s %f %f %f\n",COLCORSTR, \ |
326 |
|
extern int setspectrsamp(int cn[4], float wlpt[4]); |
327 |
|
extern int fwritecolrs(COLR *scanline, int len, FILE *fp); |
328 |
|
extern int fwritescan(COLOR *scanline, int len, FILE *fp); |
329 |
< |
extern int fwritescolrs(uby8 *sscanline, int len, FILE *fp); |
330 |
< |
extern int fwritesscan(COLORV *sscanline, int len, FILE *fp); |
329 |
> |
extern int fwritescolrs(uby8 *sscanline, int nc, int len, FILE *fp); |
330 |
> |
extern int fwritesscan(COLORV *sscanline, int nc, int len, FILE *fp); |
331 |
|
extern int freadcolrs(COLR *scanline, int len, FILE *fp); |
332 |
|
extern int freadscan(COLOR *scanline, int len, FILE *fp); |
333 |
|
extern int freadscolrs(uby8 *scanline, int nc, int len, FILE *fp); |
339 |
|
/* compare scolor_rgb() and scolor_cie() */ |
340 |
|
/* also, pcolor_color() and pcolor_colr() */ |
341 |
|
extern void setscolor(SCOLOR scol, double r, double g, double b); |
342 |
< |
extern void scolor2color(COLOR col, SCOLOR scol, int ncs, float wlpt[4]); |
343 |
< |
extern void scolor2colr(COLR clr, SCOLOR scol, int ncs, float wlpt[4]); |
342 |
> |
extern void scolor2color(COLOR col, SCOLOR scol, int ncs, const float wlpt[4]); |
343 |
> |
extern void scolor2colr(COLR clr, SCOLOR scol, int ncs, const float wlpt[4]); |
344 |
|
extern void scolor2scolr(SCOLR sclr, SCOLOR scol, int ncs); |
345 |
|
extern void colr_color(COLOR col, COLR clr); |
346 |
|
extern void scolr2scolor(SCOLOR scol, SCOLR sclr, int ncs); |
347 |
< |
extern void scolr2color(COLOR col, SCOLR sclr, int ncs, float wlpt[4]); |
347 |
> |
extern void scolr2color(COLOR col, SCOLR sclr, int ncs, const float wlpt[4]); |
348 |
|
extern void colr_scolor(SCOLOR scol, COLR clr); |
349 |
|
extern void setcolr(COLR clr, double r, double g, double b); |
350 |
|
extern void setscolr(SCOLR sclr, double r, double g, double b); |
370 |
|
extern int compxyz2rgbWBmat(COLORMAT mat, RGBPRIMS pr); |
371 |
|
extern int comprgb2xyzWBmat(COLORMAT mat, RGBPRIMS pr); |
372 |
|
extern int comprgb2rgbWBmat(COLORMAT mat, RGBPRIMS pr1, RGBPRIMS pr2); |
373 |
+ |
/* any uniform spectrum to working */ |
374 |
+ |
extern void convertscolorcol(SCOLOR rcol, const COLORV src[], int snc, |
375 |
+ |
double swl0, double swl1); |
376 |
|
/* most accurate spectral->tristim */ |
377 |
< |
extern void scolor2cie(COLOR col, SCOLOR scol, int ncs, float wlpt[4]); |
378 |
< |
extern void scolor2rgb(COLOR col, SCOLOR scol, int ncs, float wlpt[4]); |
377 |
> |
extern void scolor2cie(COLOR col, SCOLOR scol, int ncs, const float wlpt[4]); |
378 |
> |
extern void scolor2rgb(COLOR col, SCOLOR scol, int ncs, const float wlpt[4]); |
379 |
> |
extern double scolor2photopic(SCOLOR scol, int ncs, const float wlpt[4]); |
380 |
> |
extern double scolor2scotopic(SCOLOR scol, int ncs, const float wlpt[4]); |
381 |
> |
extern double scolor2melanopic(SCOLOR scol, int ncs, const float wlpt[4]); |
382 |
|
extern double scolor_photopic(SCOLOR scol); |
383 |
|
extern double scolor_scotopic(SCOLOR scol); |
384 |
|
extern double scolor_melanopic(SCOLOR scol); |