ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ra_bmp.c
(Generate patch)

Comparing ray/src/px/ra_bmp.c (file contents):
Revision 2.9 by greg, Thu Sep 23 18:00:54 2004 UTC vs.
Revision 2.17 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   *  program to convert between RADIANCE and Windows BMP file
6   */
7  
8 #include  <stdio.h>
8   #include  <math.h>
10 #include  <string.h>
9  
10 + #include  "rtio.h"
11   #include  "platform.h"
12   #include  "color.h"
13   #include  "tonemap.h"
# Line 19 | Line 18 | int            bradj = 0;              /* brightness adjustment */
18  
19   double          gamcor = 2.2;           /* gamma correction value */
20  
22 char            *progname;
23
21   static void quiterr(const char *err);
22   static void tmap2bmp(char *fnin, char *fnout, char *expec,
23                                  RGBPRIMP monpri, double gamval);
# Line 44 | Line 41 | main(int argc, char *argv[])
41          RESOLU          rs;
42          int             i;
43          
44 <        progname = argv[0];
44 >        fixargv0(argv[0]);              /* assigns progname */
45  
46          for (i = 1; i < argc; i++)
47                  if (argv[i][0] == '-' && argv[i][1])
# Line 160 | Line 157 | main(int argc, char *argv[])
157                  if (rgbp == NULL) {
158                          hdr = BMPmappedHeader(scanlen(&rs),
159                                                  numscans(&rs), 0, 256);
160 +                        /*
161                          if (outfile != NULL)
162                                  hdr->compr = BI_RLE8;
163 +                        */
164                  } else
165                          hdr = BMPtruecolorHeader(scanlen(&rs),
166                                                  numscans(&rs), 0);
# Line 209 | Line 208 | quiterr(const char *err)
208   static int
209   headline(char *s, void *p)
210   {
211 <        char    fmt[32];
211 >        char    fmt[MAXFMTLEN];
212  
213          if (formatval(fmt, s)) {        /* check if format string */
214                  if (!strcmp(fmt,COLRFMT))
# Line 218 | Line 217 | headline(char *s, void *p)
217                          rgbinp = TM_XYZPRIM;
218                          return(0);
219                  }
220 +                if (!strcmp(fmt,SPECFMT))
221 +                        return(0);
222                  return(-1);
223          }
224          if (isprims(s)) {               /* get input primaries */
# Line 225 | Line 226 | headline(char *s, void *p)
226                  rgbinp = myinprims;
227                  return(0);
228          }
229 +        if (isncomp(s)) {
230 +                NCSAMP = ncompval(s);
231 +                return(0);
232 +        }
233 +        if (iswlsplit(s)) {
234 +                wlsplitval(WLPART, s);
235 +                return(0);
236 +        }
237                                          /* should I grok colcorr also? */
238          return(0);
239   }
# Line 248 | Line 257 | rad2bmp(FILE *rfp, BMPWriter *bwr, int inv, RGBPRIMP m
257          usexfm = (monpri != NULL ? rgbinp != monpri :
258                          rgbinp != TM_XYZPRIM && rgbinp != stdprims);
259          if (usexfm) {
260 <                double  expcomp = pow(2.0, (double)bradj);
260 >                RGBPRIMP        destpri = monpri != NULL ? monpri : stdprims;
261 >                double          expcomp = pow(2.0, (double)bradj);
262                  if (rgbinp == TM_XYZPRIM)
263 <                        compxyz2rgbWBmat(xfm, monpri);
263 >                        compxyz2rgbWBmat(xfm, destpri);
264                  else
265 <                        comprgb2rgbWBmat(xfm, rgbinp, monpri);
265 >                        comprgb2rgbWBmat(xfm, rgbinp, destpri);
266                  for (y = 0; y < 3; y++)
267                          for (x = 0; x < 3; x++)
268                                  xfm[y][x] *= expcomp;
# Line 267 | Line 277 | rad2bmp(FILE *rfp, BMPWriter *bwr, int inv, RGBPRIMP m
277          }
278                                                  /* convert each scanline */
279          for ( ; y != yend; y += ystp) {
280 <                if (freadcolrs(scanin, bwr->hdr->width, rfp) < 0)
280 >                if (fread2colrs(scanin, bwr->hdr->width, rfp, NCSAMP, WLPART) < 0)
281                          quiterr("error reading Radiance picture");
282                  if (usexfm)
283                          for (x = bwr->hdr->width; x--; ) {
# Line 350 | Line 360 | tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM
360          BMPWriter       *wtr;
361          FILE            *fp;
362          int             xr, yr;
363 <        BYTE            *pa;
363 >        uby8            *pa;
364          int             i;
365                                          /* check tone-mapping spec */
366          i = strlen(expec);
# Line 395 | Line 405 | tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM
405                  quiterr("cannot allocate writer structure");
406                                          /* write to BMP file */
407          while (wtr->yscan < yr) {
408 <                BYTE    *scn = pa + xr*((tmflags & TM_F_BW) ? 1 : 3)*
408 >                uby8    *scn = pa + xr*((tmflags & TM_F_BW) ? 1 : 3)*
409                                                  (yr-1 - wtr->yscan);
410                  if (tmflags & TM_F_BW)
411                          memcpy((void *)wtr->scanline, (void *)scn, xr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines