| 59 |  |  | 
| 60 |  | char  errmsg[128]; | 
| 61 |  |  | 
| 62 | < | COLR    *inline; | 
| 62 | > | COLR    *inl; | 
| 63 |  |  | 
| 64 |  | pixel   *tarData; | 
| 65 |  |  | 
| 125 |  | } | 
| 126 |  | /* put header */ | 
| 127 |  | printargs(i, argv, stdout); | 
| 128 | + | fputformat(COLRFMT, stdout); | 
| 129 |  | putchar('\n'); | 
| 130 |  | fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); | 
| 131 |  | /* convert file */ | 
| 283 |  | p->fp = stdin; | 
| 284 |  | else if ((p->fp = fopen(fname, "r")) == NULL) | 
| 285 |  | return(NULL); | 
| 286 | < | /* discard header */ | 
| 287 | < | getheader(p->fp, NULL); | 
| 288 | < | if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) | 
| 289 | < | quiterr("bad picture size"); | 
| 286 | > | /* get header info. */ | 
| 287 | > | if (checkheader(p->fp, COLRFMT, NULL) < 0 || | 
| 288 | > | fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) | 
| 289 | > | quiterr("bad picture format"); | 
| 290 |  | p->nexty = 0; | 
| 291 |  | p->bytes_line = 0;              /* variable length lines */ | 
| 292 |  | p->pos.y = (long *)ecalloc(ymax, sizeof(long)); | 
| 305 |  | h->dataBits = 8; | 
| 306 |  | h->imType = 0; | 
| 307 |  | /* allocate scanline */ | 
| 308 | < | inline = (COLR *)emalloc(xmax*sizeof(COLR)); | 
| 308 | > | inl = (COLR *)emalloc(xmax*sizeof(COLR)); | 
| 309 |  | /* allocate targa data */ | 
| 310 |  | tarData = taralloc(h); | 
| 311 |  |  | 
| 369 |  | if (inpic->bytes_line == 0) { | 
| 370 |  | if (inpic->pos.y[y] == 0) { | 
| 371 |  | while (inpic->nexty < y) { | 
| 372 | < | if (freadcolrs(inline, xmax, inpic->fp) < 0) | 
| 372 | > | if (freadcolrs(inl, xmax, inpic->fp) < 0) | 
| 373 |  | quiterr("read error in picreadline3"); | 
| 374 |  | inpic->pos.y[++inpic->nexty] = ftell(inpic->fp); | 
| 375 |  | } | 
| 379 |  | quiterr("seek error in picreadline3"); | 
| 380 |  | } else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0) | 
| 381 |  | inpic->pos.y[inpic->nexty] = ftell(inpic->fp); | 
| 382 | < | if (freadcolrs(inline, xmax, inpic->fp) < 0)    /* read scanline */ | 
| 382 | > | if (freadcolrs(inl, xmax, inpic->fp) < 0)       /* read scanline */ | 
| 383 |  | quiterr("read error in picreadline3"); | 
| 384 |  | inpic->nexty = y+1; | 
| 385 |  | /* convert scanline */ | 
| 386 | < | normcolrs(inline, xmax, 0); | 
| 386 | > | normcolrs(inl, xmax, 0); | 
| 387 |  | for (i = 0; i < xmax; i++) { | 
| 388 | < | l3[i].r = inline[i][RED]; | 
| 389 | < | l3[i].g = inline[i][GRN]; | 
| 390 | < | l3[i].b = inline[i][BLU]; | 
| 388 | > | l3[i].r = inl[i][RED]; | 
| 389 | > | l3[i].g = inl[i][GRN]; | 
| 390 | > | l3[i].b = inl[i][BLU]; | 
| 391 |  | } | 
| 392 |  | } | 
| 393 |  |  | 
| 466 |  | register int  i, val; | 
| 467 |  |  | 
| 468 |  | for (i = 0; i < 256; i++) { | 
| 469 | < | val = pow(i/256.0, 1.0/gamma) * 256.0; | 
| 469 | > | val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0; | 
| 470 |  | map[0][i] = map[1][i] = map[2][i] = val; | 
| 471 |  | } | 
| 472 |  | } |