1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
10 |
|
* 4/23/86 |
11 |
|
*/ |
12 |
|
|
13 |
< |
#include <stdio.h> |
13 |
> |
#include "standard.h" |
14 |
|
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
< |
#define min(a,b) ((a)<(b)?(a):(b)) |
17 |
> |
#include "resolu.h" |
18 |
|
|
19 |
< |
int xres = 0; /* resolution of input */ |
20 |
< |
int yres = 0; |
19 |
> |
#define min(a,b) ((a)<(b)?(a):(b)) |
20 |
|
|
21 |
< |
int uniq = 0; /* unique values? */ |
21 |
> |
RESOLU picres; /* resolution of picture */ |
22 |
|
|
23 |
< |
int original = 0; /* original values? */ |
23 |
> |
int uniq = 0; /* print only unique values? */ |
24 |
|
|
25 |
+ |
int original = 0; /* convert back to original values? */ |
26 |
+ |
|
27 |
|
int dataonly = 0; /* data only format? */ |
28 |
|
|
29 |
|
int brightonly = 0; /* only brightness values? */ |
31 |
|
int reverse = 0; /* reverse conversion? */ |
32 |
|
|
33 |
|
int format = 'a'; /* input/output format */ |
34 |
+ |
char *fmtid = "ascii"; /* format identifier for header */ |
35 |
|
|
36 |
< |
int header = 1; /* do header */ |
36 |
> |
int header = 1; /* do header? */ |
37 |
|
|
38 |
< |
double exposure = 1.0; |
38 |
> |
int resolution = 1; /* put/get resolution string? */ |
39 |
|
|
40 |
+ |
int wrongformat = 0; /* wrong input format? */ |
41 |
+ |
|
42 |
+ |
double gamcor = 1.0; /* gamma correction */ |
43 |
+ |
|
44 |
+ |
int ord[3] = {RED, GRN, BLU}; /* RGB ordering */ |
45 |
+ |
int rord[4]; /* reverse ordering */ |
46 |
+ |
|
47 |
+ |
COLOR exposure = WHTCOLOR; |
48 |
+ |
|
49 |
|
char *progname; |
50 |
|
|
51 |
|
FILE *fin; |
57 |
|
int argc; |
58 |
|
char **argv; |
59 |
|
{ |
49 |
– |
extern double atof(); |
60 |
|
extern int checkhead(); |
61 |
|
int i; |
62 |
|
|
63 |
|
progname = argv[0]; |
64 |
|
|
65 |
|
for (i = 1; i < argc; i++) |
66 |
< |
if (argv[i][0] == '-') |
66 |
> |
if (argv[i][0] == '-' || argv[i][0] == '+') |
67 |
|
switch (argv[i][1]) { |
68 |
< |
case 'h': /* no header */ |
69 |
< |
header = 0; |
68 |
> |
case 'h': /* header */ |
69 |
> |
header = argv[i][0] == '+'; |
70 |
|
break; |
71 |
+ |
case 'H': /* resolution string */ |
72 |
+ |
resolution = argv[i][0] == '+'; |
73 |
+ |
break; |
74 |
|
case 'u': /* unique values */ |
75 |
< |
uniq = 1; |
75 |
> |
uniq = argv[i][0] == '-'; |
76 |
|
break; |
77 |
|
case 'o': /* original values */ |
78 |
< |
original = 1; |
78 |
> |
original = argv[i][0] == '-'; |
79 |
|
break; |
80 |
+ |
case 'g': /* gamma correction */ |
81 |
+ |
gamcor = atof(argv[++i]); |
82 |
+ |
if (argv[i][0] == '+') |
83 |
+ |
gamcor = 1.0/gamcor; |
84 |
+ |
break; |
85 |
+ |
case 'R': /* reverse byte sequence */ |
86 |
+ |
if (argv[i][0] == '-') { |
87 |
+ |
ord[0]=BLU; ord[1]=GRN; ord[2]=RED; |
88 |
+ |
} else { |
89 |
+ |
ord[0]=RED; ord[1]=GRN; ord[2]=BLU; |
90 |
+ |
} |
91 |
+ |
break; |
92 |
|
case 'r': /* reverse conversion */ |
93 |
< |
reverse = 1; |
93 |
> |
reverse = argv[i][0] == '-'; |
94 |
|
break; |
95 |
|
case 'b': /* brightness values */ |
96 |
< |
brightonly = 1; |
96 |
> |
brightonly = argv[i][0] == '-'; |
97 |
|
break; |
98 |
|
case 'd': /* data only (no indices) */ |
99 |
< |
dataonly = 1; |
99 |
> |
dataonly = argv[i][0] == '-'; |
100 |
|
switch (argv[i][2]) { |
101 |
|
case '\0': |
102 |
|
case 'a': /* ascii */ |
103 |
|
format = 'a'; |
104 |
+ |
fmtid = "ascii"; |
105 |
|
break; |
106 |
|
case 'i': /* integer */ |
107 |
+ |
format = 'i'; |
108 |
+ |
fmtid = "ascii"; |
109 |
+ |
break; |
110 |
|
case 'b': /* byte */ |
111 |
+ |
dataonly = 1; |
112 |
+ |
format = 'b'; |
113 |
+ |
fmtid = "byte"; |
114 |
+ |
break; |
115 |
|
case 'f': /* float */ |
116 |
+ |
dataonly = 1; |
117 |
+ |
format = 'f'; |
118 |
+ |
fmtid = "float"; |
119 |
+ |
break; |
120 |
|
case 'd': /* double */ |
121 |
< |
format = argv[i][2]; |
121 |
> |
dataonly = 1; |
122 |
> |
format = 'd'; |
123 |
> |
fmtid = "double"; |
124 |
|
break; |
125 |
|
default: |
126 |
|
goto unkopt; |
127 |
|
} |
128 |
|
break; |
129 |
|
case 'x': /* x resolution */ |
130 |
< |
xres = atoi(argv[++i]); |
130 |
> |
resolution = 0; |
131 |
> |
if (argv[i][0] == '-') |
132 |
> |
picres.or |= XDECR; |
133 |
> |
picres.xr = atoi(argv[++i]); |
134 |
|
break; |
135 |
|
case 'y': /* y resolution */ |
136 |
< |
yres = atoi(argv[++i]); |
136 |
> |
resolution = 0; |
137 |
> |
if (argv[i][0] == '-') |
138 |
> |
picres.or |= YDECR; |
139 |
> |
if (picres.xr == 0) |
140 |
> |
picres.or |= YMAJOR; |
141 |
> |
picres.yr = atoi(argv[++i]); |
142 |
|
break; |
143 |
|
default: |
144 |
|
unkopt: |
149 |
|
} |
150 |
|
else |
151 |
|
break; |
152 |
< |
|
152 |
> |
/* recognize special formats */ |
153 |
> |
if (dataonly && format == 'b') |
154 |
> |
if (brightonly) |
155 |
> |
fmtid = "8-bit_grey"; |
156 |
> |
else |
157 |
> |
fmtid = "24-bit_rgb"; |
158 |
> |
/* assign reverse ordering */ |
159 |
> |
rord[ord[0]] = 0; |
160 |
> |
rord[ord[1]] = 1; |
161 |
> |
rord[ord[2]] = 2; |
162 |
> |
/* get input */ |
163 |
|
if (i == argc) { |
164 |
|
fin = stdin; |
165 |
|
} else if (i == argc-1) { |
176 |
|
set_io(); |
177 |
|
|
178 |
|
if (reverse) { |
179 |
< |
if (header) /* get header */ |
180 |
< |
copyheader(fin, stdout); |
181 |
< |
/* add to header */ |
182 |
< |
printargs(i, argv, stdout); |
183 |
< |
printf("\n"); |
184 |
< |
if (yres <= 0 || xres <= 0) { |
185 |
< |
fprintf(stderr, "%s: missing x and y resolution\n", |
186 |
< |
progname); |
179 |
> |
#ifdef MSDOS |
180 |
> |
setmode(fileno(stdout), O_BINARY); |
181 |
> |
if (format != 'a' && format != 'i') |
182 |
> |
setmode(fileno(fin), O_BINARY); |
183 |
> |
#endif |
184 |
> |
/* get header */ |
185 |
> |
if (header && checkheader(fin, fmtid, stdout) < 0) { |
186 |
> |
fprintf(stderr, "%s: wrong input format\n", progname); |
187 |
|
quit(1); |
188 |
|
} |
189 |
< |
printf("-Y %d +X %d\n", yres, xres); /* resolution */ |
189 |
> |
/* get resolution */ |
190 |
> |
if ((resolution && !fgetsresolu(&picres, fin)) || |
191 |
> |
picres.xr <= 0 || picres.yr <= 0) { |
192 |
> |
fprintf(stderr, "%s: missing resolution\n", progname); |
193 |
> |
quit(1); |
194 |
> |
} |
195 |
> |
/* add to header */ |
196 |
> |
printargs(i, argv, stdout); |
197 |
> |
fputformat(COLRFMT, stdout); |
198 |
> |
putchar('\n'); |
199 |
> |
fputsresolu(&picres, stdout); /* always put resolution */ |
200 |
|
valtopix(); |
201 |
|
} else { |
202 |
+ |
#ifdef MSDOS |
203 |
+ |
setmode(fileno(fin), O_BINARY); |
204 |
+ |
if (format != 'a' && format != 'i') |
205 |
+ |
setmode(fileno(stdout), O_BINARY); |
206 |
+ |
#endif |
207 |
|
/* get header */ |
208 |
< |
getheader(fin, checkhead); |
209 |
< |
|
210 |
< |
if (xres <= 0 || yres <= 0) /* get picture size */ |
211 |
< |
if (fscanf(fin, "-Y %d +X %d\n", &yres, &xres) != 2) { |
212 |
< |
fprintf(stderr, |
213 |
< |
"%s: missing x and y resolution\n", |
214 |
< |
progname); |
215 |
< |
quit(1); |
216 |
< |
} |
208 |
> |
getheader(fin, checkhead, NULL); |
209 |
> |
if (wrongformat) { |
210 |
> |
fprintf(stderr, "%s: input not a Radiance picture\n", |
211 |
> |
progname); |
212 |
> |
quit(1); |
213 |
> |
} |
214 |
> |
if (!fgetsresolu(&picres, fin)) { |
215 |
> |
fprintf(stderr, "%s: missing resolution\n", progname); |
216 |
> |
quit(1); |
217 |
> |
} |
218 |
|
if (header) { |
219 |
|
printargs(i, argv, stdout); |
220 |
< |
printf("\n"); |
220 |
> |
fputformat(fmtid, stdout); |
221 |
> |
putchar('\n'); |
222 |
|
} |
223 |
+ |
if (resolution) /* put resolution */ |
224 |
+ |
fputsresolu(&picres, stdout); |
225 |
|
pixtoval(); |
226 |
|
} |
227 |
|
|
232 |
|
checkhead(line) /* deal with line from header */ |
233 |
|
char *line; |
234 |
|
{ |
235 |
< |
if (header) |
235 |
> |
char fmt[32]; |
236 |
> |
double d; |
237 |
> |
COLOR ctmp; |
238 |
> |
|
239 |
> |
if (isformat(line)) { |
240 |
> |
formatval(fmt, line); |
241 |
> |
wrongformat = strcmp(fmt, COLRFMT); |
242 |
> |
} else if (original && isexpos(line)) { |
243 |
> |
d = 1.0/exposval(line); |
244 |
> |
scalecolor(exposure, d); |
245 |
> |
} else if (original && iscolcor(line)) { |
246 |
> |
colcorval(ctmp, line); |
247 |
> |
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
248 |
> |
colval(exposure,GRN)/colval(ctmp,GRN), |
249 |
> |
colval(exposure,BLU)/colval(ctmp,BLU)); |
250 |
> |
} else if (header) |
251 |
|
fputs(line, stdout); |
161 |
– |
if (!strncmp(line, "EXPOSURE=", 9)) |
162 |
– |
exposure *= atof(line+9); |
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
|
pixtoval() /* convert picture to values */ |
256 |
|
{ |
257 |
< |
COLOR *scanln; |
257 |
> |
register COLOR *scanln; |
258 |
> |
int dogamma; |
259 |
|
COLOR lastc; |
260 |
+ |
FLOAT hv[2]; |
261 |
|
int y; |
262 |
|
register int x; |
263 |
|
|
264 |
< |
scanln = (COLOR *)malloc(xres*sizeof(COLOR)); |
264 |
> |
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
265 |
|
if (scanln == NULL) { |
266 |
|
fprintf(stderr, "%s: out of memory\n", progname); |
267 |
|
quit(1); |
268 |
|
} |
269 |
+ |
dogamma = gamcor < .95 || gamcor > 1.05; |
270 |
|
setcolor(lastc, 0.0, 0.0, 0.0); |
271 |
< |
for (y = yres-1; y >= 0; y--) { |
272 |
< |
if (freadscan(scanln, xres, fin) < 0) { |
271 |
> |
for (y = 0; y < numscans(&picres); y++) { |
272 |
> |
if (freadscan(scanln, scanlen(&picres), fin) < 0) { |
273 |
|
fprintf(stderr, "%s: read error\n", progname); |
274 |
|
quit(1); |
275 |
|
} |
276 |
< |
for (x = 0; x < xres; x++) { |
276 |
> |
for (x = 0; x < scanlen(&picres); x++) { |
277 |
|
if (uniq) |
278 |
< |
if ( scanln[x][RED] == lastc[RED] && |
279 |
< |
scanln[x][GRN] == lastc[GRN] && |
280 |
< |
scanln[x][BLU] == lastc[BLU] ) |
278 |
> |
if ( colval(scanln[x],RED) == |
279 |
> |
colval(lastc,RED) && |
280 |
> |
colval(scanln[x],GRN) == |
281 |
> |
colval(lastc,GRN) && |
282 |
> |
colval(scanln[x],BLU) == |
283 |
> |
colval(lastc,BLU) ) |
284 |
|
continue; |
285 |
|
else |
286 |
|
copycolor(lastc, scanln[x]); |
287 |
|
if (original) |
288 |
< |
scalecolor(scanln[x], 1.0/exposure); |
289 |
< |
if (!dataonly) |
290 |
< |
printf("%7d %7d ", x, y); |
288 |
> |
multcolor(scanln[x], exposure); |
289 |
> |
if (dogamma) |
290 |
> |
setcolor(scanln[x], |
291 |
> |
pow(colval(scanln[x],RED), 1.0/gamcor), |
292 |
> |
pow(colval(scanln[x],GRN), 1.0/gamcor), |
293 |
> |
pow(colval(scanln[x],BLU), 1.0/gamcor)); |
294 |
> |
if (!dataonly) { |
295 |
> |
pix2loc(hv, &picres, x, y); |
296 |
> |
printf("%7d %7d ", (int)(hv[0]*picres.xr), |
297 |
> |
(int)(hv[1]*picres.yr)); |
298 |
> |
} |
299 |
|
if ((*putval)(scanln[x], stdout) < 0) { |
300 |
|
fprintf(stderr, "%s: write error\n", progname); |
301 |
|
quit(1); |
308 |
|
|
309 |
|
valtopix() /* convert values to a pixel file */ |
310 |
|
{ |
311 |
< |
COLOR *scanln; |
311 |
> |
int dogamma; |
312 |
> |
register COLOR *scanln; |
313 |
|
int y; |
314 |
|
register int x; |
315 |
|
|
316 |
< |
scanln = (COLOR *)malloc(xres*sizeof(COLOR)); |
316 |
> |
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
317 |
|
if (scanln == NULL) { |
318 |
|
fprintf(stderr, "%s: out of memory\n", progname); |
319 |
|
quit(1); |
320 |
|
} |
321 |
< |
for (y = yres-1; y >= 0; y--) { |
322 |
< |
for (x = 0; x < xres; x++) { |
321 |
> |
dogamma = gamcor < .95 || gamcor > 1.05; |
322 |
> |
for (y = 0; y < numscans(&picres); y++) { |
323 |
> |
for (x = 0; x < scanlen(&picres); x++) { |
324 |
|
if (!dataonly) |
325 |
|
fscanf(fin, "%*d %*d"); |
326 |
|
if ((*getval)(scanln[x], fin) < 0) { |
327 |
|
fprintf(stderr, "%s: read error\n", progname); |
328 |
|
quit(1); |
329 |
|
} |
330 |
+ |
if (dogamma) |
331 |
+ |
setcolor(scanln[x], |
332 |
+ |
pow(colval(scanln[x],RED), gamcor), |
333 |
+ |
pow(colval(scanln[x],GRN), gamcor), |
334 |
+ |
pow(colval(scanln[x],BLU), gamcor)); |
335 |
|
} |
336 |
< |
if (fwritescan(scanln, xres, stdout) < 0 |
227 |
< |
|| fflush(stdout) < 0) { |
336 |
> |
if (fwritescan(scanln, scanlen(&picres), stdout) < 0) { |
337 |
|
fprintf(stderr, "%s: write error\n", progname); |
338 |
|
quit(1); |
339 |
|
} |
353 |
|
COLOR col; |
354 |
|
FILE *fp; |
355 |
|
{ |
356 |
< |
double vd[3]; |
356 |
> |
double vd[3]; |
357 |
|
|
358 |
|
if (fscanf(fp, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3) |
359 |
|
return(-1); |
360 |
< |
setcolor(col, vd[0], vd[1], vd[2]); |
360 |
> |
setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]); |
361 |
|
return(0); |
362 |
|
} |
363 |
|
|
366 |
|
COLOR col; |
367 |
|
FILE *fp; |
368 |
|
{ |
369 |
< |
double vd[3]; |
369 |
> |
double vd[3]; |
370 |
|
|
371 |
< |
if (fread(vd, sizeof(double), 3, fp) != 3) |
371 |
> |
if (fread((char *)vd, sizeof(double), 3, fp) != 3) |
372 |
|
return(-1); |
373 |
< |
setcolor(col, vd[0], vd[1], vd[2]); |
373 |
> |
setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]); |
374 |
|
return(0); |
375 |
|
} |
376 |
|
|
381 |
|
{ |
382 |
|
float vf[3]; |
383 |
|
|
384 |
< |
if (fread(vf, sizeof(float), 3, fp) != 3) |
384 |
> |
if (fread((char *)vf, sizeof(float), 3, fp) != 3) |
385 |
|
return(-1); |
386 |
< |
setcolor(col, vf[0], vf[1], vf[2]); |
386 |
> |
setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]); |
387 |
|
return(0); |
388 |
|
} |
389 |
|
|
396 |
|
|
397 |
|
if (fscanf(fp, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3) |
398 |
|
return(-1); |
399 |
< |
setcolor(col,(vi[0]+.5)/256.,(vi[1]+.5)/256.,(vi[2]+.5)/256.); |
399 |
> |
setcolor(col, (vi[rord[RED]]+.5)/256., |
400 |
> |
(vi[rord[GRN]]+.5)/256., (vi[rord[BLU]]+.5)/256.); |
401 |
|
return(0); |
402 |
|
} |
403 |
|
|
408 |
|
{ |
409 |
|
BYTE vb[3]; |
410 |
|
|
411 |
< |
if (fread(vb, sizeof(BYTE), 3, fp) != 3) |
411 |
> |
if (fread((char *)vb, sizeof(BYTE), 3, fp) != 3) |
412 |
|
return(-1); |
413 |
< |
setcolor(col,(vb[0]+.5)/256.,(vb[1]+.5)/256.,(vb[2]+.5)/256.); |
413 |
> |
setcolor(col, (vb[rord[RED]]+.5)/256., |
414 |
> |
(vb[rord[GRN]]+.5)/256., (vb[rord[BLU]]+.5)/256.); |
415 |
|
return(0); |
416 |
|
} |
417 |
|
|
420 |
|
COLOR col; |
421 |
|
FILE *fp; |
422 |
|
{ |
423 |
< |
double vd; |
423 |
> |
double vd; |
424 |
|
|
425 |
|
if (fscanf(fp, "%lf", &vd) != 1) |
426 |
|
return(-1); |
433 |
|
COLOR col; |
434 |
|
FILE *fp; |
435 |
|
{ |
436 |
< |
double vd; |
436 |
> |
double vd; |
437 |
|
|
438 |
< |
if (fread(&vd, sizeof(double), 1, fp) != 1) |
438 |
> |
if (fread((char *)&vd, sizeof(double), 1, fp) != 1) |
439 |
|
return(-1); |
440 |
|
setcolor(col, vd, vd, vd); |
441 |
|
return(0); |
448 |
|
{ |
449 |
|
float vf; |
450 |
|
|
451 |
< |
if (fread(&vf, sizeof(float), 1, fp) != 1) |
451 |
> |
if (fread((char *)&vf, sizeof(float), 1, fp) != 1) |
452 |
|
return(-1); |
453 |
|
setcolor(col, vf, vf, vf); |
454 |
|
return(0); |
460 |
|
FILE *fp; |
461 |
|
{ |
462 |
|
int vi; |
463 |
< |
double d; |
463 |
> |
double d; |
464 |
|
|
465 |
|
if (fscanf(fp, "%d", &vi) != 1) |
466 |
|
return(-1); |
475 |
|
FILE *fp; |
476 |
|
{ |
477 |
|
BYTE vb; |
478 |
< |
double d; |
478 |
> |
double d; |
479 |
|
|
480 |
< |
if (fread(&vb, sizeof(BYTE), 1, fp) != 1) |
480 |
> |
if (fread((char *)&vb, sizeof(BYTE), 1, fp) != 1) |
481 |
|
return(-1); |
482 |
|
d = (vb+.5)/256.; |
483 |
|
setcolor(col, d, d, d); |
490 |
|
FILE *fp; |
491 |
|
{ |
492 |
|
fprintf(fp, "%15.3e %15.3e %15.3e\n", |
493 |
< |
colval(col,RED), |
494 |
< |
colval(col,GRN), |
495 |
< |
colval(col,BLU)); |
493 |
> |
colval(col,ord[0]), |
494 |
> |
colval(col,ord[1]), |
495 |
> |
colval(col,ord[2])); |
496 |
|
|
497 |
|
return(ferror(fp) ? -1 : 0); |
498 |
|
} |
504 |
|
{ |
505 |
|
float vf[3]; |
506 |
|
|
507 |
< |
vf[0] = colval(col,RED); |
508 |
< |
vf[1] = colval(col,GRN); |
509 |
< |
vf[2] = colval(col,BLU); |
510 |
< |
fwrite(vf, sizeof(float), 3, fp); |
507 |
> |
vf[0] = colval(col,ord[0]); |
508 |
> |
vf[1] = colval(col,ord[1]); |
509 |
> |
vf[2] = colval(col,ord[2]); |
510 |
> |
fwrite((char *)vf, sizeof(float), 3, fp); |
511 |
|
|
512 |
|
return(ferror(fp) ? -1 : 0); |
513 |
|
} |
517 |
|
COLOR col; |
518 |
|
FILE *fp; |
519 |
|
{ |
520 |
< |
double vd[3]; |
520 |
> |
double vd[3]; |
521 |
|
|
522 |
< |
vd[0] = colval(col,RED); |
523 |
< |
vd[1] = colval(col,GRN); |
524 |
< |
vd[2] = colval(col,BLU); |
525 |
< |
fwrite(vd, sizeof(double), 3, fp); |
522 |
> |
vd[0] = colval(col,ord[0]); |
523 |
> |
vd[1] = colval(col,ord[1]); |
524 |
> |
vd[2] = colval(col,ord[2]); |
525 |
> |
fwrite((char *)vd, sizeof(double), 3, fp); |
526 |
|
|
527 |
|
return(ferror(fp) ? -1 : 0); |
528 |
|
} |
533 |
|
FILE *fp; |
534 |
|
{ |
535 |
|
fprintf(fp, "%d %d %d\n", |
536 |
< |
(int)(colval(col,RED)*256.), |
537 |
< |
(int)(colval(col,GRN)*256.), |
538 |
< |
(int)(colval(col,BLU)*256.)); |
536 |
> |
(int)(colval(col,ord[0])*256.), |
537 |
> |
(int)(colval(col,ord[1])*256.), |
538 |
> |
(int)(colval(col,ord[2])*256.)); |
539 |
|
|
540 |
|
return(ferror(fp) ? -1 : 0); |
541 |
|
} |
548 |
|
register int i; |
549 |
|
BYTE vb[3]; |
550 |
|
|
551 |
< |
i = colval(col,RED)*256.; |
551 |
> |
i = colval(col,ord[0])*256.; |
552 |
|
vb[0] = min(i,255); |
553 |
< |
i = colval(col,GRN)*256.; |
553 |
> |
i = colval(col,ord[1])*256.; |
554 |
|
vb[1] = min(i,255); |
555 |
< |
i = colval(col,BLU)*256.; |
555 |
> |
i = colval(col,ord[2])*256.; |
556 |
|
vb[2] = min(i,255); |
557 |
< |
fwrite(vb, sizeof(BYTE), 3, fp); |
557 |
> |
fwrite((char *)vb, sizeof(BYTE), 3, fp); |
558 |
|
|
559 |
|
return(ferror(fp) ? -1 : 0); |
560 |
|
} |
577 |
|
float vf; |
578 |
|
|
579 |
|
vf = bright(col); |
580 |
< |
fwrite(&vf, sizeof(float), 1, fp); |
580 |
> |
fwrite((char *)&vf, sizeof(float), 1, fp); |
581 |
|
|
582 |
|
return(ferror(fp) ? -1 : 0); |
583 |
|
} |
587 |
|
COLOR col; |
588 |
|
FILE *fp; |
589 |
|
{ |
590 |
< |
double vd; |
590 |
> |
double vd; |
591 |
|
|
592 |
|
vd = bright(col); |
593 |
< |
fwrite(&vd, sizeof(double), 1, fp); |
593 |
> |
fwrite((char *)&vd, sizeof(double), 1, fp); |
594 |
|
|
595 |
|
return(ferror(fp) ? -1 : 0); |
596 |
|
} |
615 |
|
|
616 |
|
i = bright(col)*256.; |
617 |
|
vb = min(i,255); |
618 |
< |
fwrite(&vb, sizeof(BYTE), 1, fp); |
618 |
> |
fwrite((char *)&vb, sizeof(BYTE), 1, fp); |
619 |
|
|
620 |
|
return(ferror(fp) ? -1 : 0); |
621 |
|
} |