--- ray/src/px/ra_bmp.c 2004/04/30 17:56:06 2.6 +++ ray/src/px/ra_bmp.c 2004/07/20 03:08:42 2.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ra_bmp.c,v 2.6 2004/04/30 17:56:06 greg Exp $"; +static const char RCSid[] = "$Id: ra_bmp.c,v 2.8 2004/07/20 03:08:42 greg Exp $"; #endif /* * program to convert between RADIANCE and Windows BMP file @@ -162,8 +162,7 @@ main(int argc, char *argv[]) if (hdr == NULL) quiterr("cannot initialize BMP header"); /* set up output direction */ - hdr->yIsDown = (rs.rt & YDECR) && - ((outfile == NULL) | (hdr->compr == BI_RLE8)); + hdr->yIsDown = ((outfile == NULL) | (hdr->compr == BI_RLE8)); /* open BMP output */ if (outfile != NULL) wtr = BMPopenOutputFile(outfile, hdr); @@ -172,7 +171,7 @@ main(int argc, char *argv[]) if (wtr == NULL) quiterr("cannot allocate writer structure"); /* convert file */ - rad2bmp(stdin, wtr, !hdr->yIsDown && rs.rt&YDECR, rgbp==NULL); + rad2bmp(stdin, wtr, !hdr->yIsDown, rgbp==NULL); /* flush output */ if (fflush((FILE *)wtr->c_data) < 0) quiterr("error writing BMP output"); @@ -293,7 +292,6 @@ tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM int tmflags; BMPHeader *hdr; BMPWriter *wtr; - RESOLU rs; FILE *fp; int xr, yr; BYTE *pa; @@ -319,13 +317,6 @@ tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM fprintf(stderr, "%s: cannot open\n", fnin); exit(1); } - /* get picture orientation */ - if (fnin != NULL) { - if (getheader(fp, NULL, NULL) < 0 || !fgetsresolu(&rs, fp)) - quiterr("bad Radiance picture format"); - rewind(fp); - } else /* assume stdin has normal orient */ - rs.rt = PIXSTANDARD; /* tone-map picture */ if (tmMapPicture(&pa, &xr, &yr, tmflags, monpri, gamval, 0., 0., fnin, fp) != TM_E_OK) @@ -349,9 +340,7 @@ tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM /* write to BMP file */ while (wtr->yscan < yr) { BYTE *scn = pa + xr*((tmflags & TM_F_BW) ? 1 : 3)* - ((rs.rt & YDECR) ? - (yr-1 - wtr->yscan) : - wtr->yscan); + (yr-1 - wtr->yscan); if (tmflags & TM_F_BW) memcpy((void *)wtr->scanline, (void *)scn, xr); else @@ -367,6 +356,8 @@ tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM if (fflush((FILE *)wtr->c_data) < 0) quiterr("error writing BMP output"); /* clean up */ + if (fnin != NULL) + fclose(fp); free((void *)pa); BMPcloseOutput(wtr); }