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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines