--- ray/src/px/ra_pr24.c 1990/10/20 11:41:29 1.3 +++ ray/src/px/ra_pr24.c 1991/04/18 14:35:40 1.5 @@ -75,16 +75,16 @@ char *argv[]; quiterr("incompatible format"); /* put header */ printargs(i, argv, stdout); + fputformat(COLRFMT, stdout); putchar('\n'); fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); /* convert file */ pr2ra(); } else { - /* discard input header */ - getheader(stdin, NULL); - /* get resolution */ - if (fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR)) - quiterr("bad picture size"); + /* get header info. */ + if (checkheader(stdin, COLRFMT, NULL) < 0 || + fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR)) + quiterr("bad picture format"); /* write rasterfile header */ head.ras_magic = RAS_MAGIC; head.ras_width = xmax; @@ -129,9 +129,9 @@ pr2ra() /* convert 24-bit scanlines to Radiance pict /* convert image */ for (y = ymax-1; y >= 0; y--) { for (x = 0; x < xmax; x++) { - scanout[x][RED] = getc(stdin); - scanout[x][GRN] = getc(stdin); scanout[x][BLU] = getc(stdin); + scanout[x][GRN] = getc(stdin); + scanout[x][RED] = getc(stdin); } if (feof(stdin) || ferror(stdin)) quiterr("error reading rasterfile"); @@ -159,9 +159,9 @@ ra2pr() /* convert Radiance scanlines to 24-bit rast quiterr("error reading Radiance picture"); colrs_gambs(scanin, xmax); for (x = 0; x < xmax; x++) { - putc(scanin[x][RED], stdout); - putc(scanin[x][GRN], stdout); putc(scanin[x][BLU], stdout); + putc(scanin[x][GRN], stdout); + putc(scanin[x][RED], stdout); } if (ferror(stdout)) quiterr("error writing rasterfile");