47 |
|
|
48 |
|
char errmsg[128]; |
49 |
|
|
50 |
< |
COLR *inline; |
50 |
> |
COLR *inl; |
51 |
|
|
52 |
|
int xmax, ymax; |
53 |
|
|
102 |
|
quiterr(errmsg); |
103 |
|
} |
104 |
|
/* get header */ |
105 |
< |
if (fread(&head, sizeof(head), 1, stdin) != 1) |
105 |
> |
if (fread((char *)&head, sizeof(head), 1, stdin) != 1) |
106 |
|
quiterr("missing header"); |
107 |
|
if (head.ras_magic != RAS_MAGIC) |
108 |
|
quiterr("bad raster format"); |
113 |
|
head.ras_depth != 8) |
114 |
|
quiterr("incompatible format"); |
115 |
|
/* put header */ |
116 |
< |
printargs(argc, argv, stdout); |
116 |
> |
printargs(i, argv, stdout); |
117 |
|
putchar('\n'); |
118 |
|
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
119 |
|
/* convert file */ |
203 |
|
h->ras_maptype = RMT_EQUAL_RGB; |
204 |
|
h->ras_maplength = 256*3; |
205 |
|
/* allocate scanline */ |
206 |
< |
inline = (COLR *)emalloc(xmax*sizeof(COLR)); |
206 |
> |
inl = (COLR *)emalloc(xmax*sizeof(COLR)); |
207 |
|
|
208 |
|
return(p); |
209 |
|
} |
223 |
|
else if ((p->fp = fopen(fname, "w")) == NULL) |
224 |
|
return(NULL); |
225 |
|
/* write header */ |
226 |
< |
fwrite(h, sizeof(*h), 1, p->fp); |
226 |
> |
fwrite((char *)h, sizeof(*h), 1, p->fp); |
227 |
|
p->nexty = -1; /* needs color map */ |
228 |
|
p->bytes_line = h->ras_width; |
229 |
|
p->pos.b = 0; |
243 |
|
scanline = (COLR *)emalloc(xmax*sizeof(COLR)); |
244 |
|
/* get color table */ |
245 |
|
for (i = 0; i < 3; i ++) |
246 |
< |
if (fread(cmap[i], h->ras_maplength/3, 1, stdin) != 1) |
246 |
> |
if (fread((char *)cmap[i], h->ras_maplength/3, 1, stdin) != 1) |
247 |
|
quiterr("error reading color table"); |
248 |
|
/* convert table */ |
249 |
|
for (i = 0; i < h->ras_maplength/3; i++) |
277 |
|
if (inpic->bytes_line == 0) { |
278 |
|
if (inpic->pos.y[y] == 0) { |
279 |
|
while (inpic->nexty < y) { |
280 |
< |
if (freadcolrs(inline, xmax, inpic->fp) < 0) |
280 |
> |
if (freadcolrs(inl, xmax, inpic->fp) < 0) |
281 |
|
quiterr("read error in picreadline3"); |
282 |
|
inpic->pos.y[++inpic->nexty] = ftell(inpic->fp); |
283 |
|
} |
287 |
|
quiterr("seek error in picreadline3"); |
288 |
|
} else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0) |
289 |
|
inpic->pos.y[inpic->nexty] = ftell(inpic->fp); |
290 |
< |
if (freadcolrs(inline, xmax, inpic->fp) < 0) /* read scanline */ |
290 |
> |
if (freadcolrs(inl, xmax, inpic->fp) < 0) /* read scanline */ |
291 |
|
quiterr("read error in picreadline3"); |
292 |
|
inpic->nexty = y+1; |
293 |
|
/* convert scanline */ |
294 |
< |
normcolrs(inline, xmax); |
294 |
> |
normcolrs(inl, xmax, 0); |
295 |
|
for (i = 0; i < xmax; i++) { |
296 |
< |
l3[i].r = inline[i][RED]; |
297 |
< |
l3[i].g = inline[i][GRN]; |
298 |
< |
l3[i].b = inline[i][BLU]; |
296 |
> |
l3[i].r = inl[i][RED]; |
297 |
> |
l3[i].g = inl[i][GRN]; |
298 |
> |
l3[i].b = inl[i][BLU]; |
299 |
|
} |
300 |
|
} |
301 |
|
|
314 |
|
quiterr("seek error in picwriteline"); |
315 |
|
} |
316 |
|
/* write scanline */ |
317 |
< |
if (fwrite(l, sizeof(pixel), xmax, outpic->fp) != xmax) |
317 |
> |
if (fwrite((char *)l, sizeof(pixel), xmax, outpic->fp) != xmax) |
318 |
|
quiterr("write error in picwriteline"); |
319 |
|
if (xmax&1) /* on 16-bit boundary */ |
320 |
|
putc(l[xmax-1], outpic->fp); |
349 |
|
register int i, val; |
350 |
|
|
351 |
|
for (i = 0; i < 256; i++) { |
352 |
< |
val = pow(i/256.0, 1.0/gamma) * 256.0; |
352 |
> |
val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0; |
353 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
354 |
|
} |
355 |
|
} |