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

Comparing ray/src/common/tmaptiff.c (file contents):
Revision 3.5 by greg, Fri Jan 7 20:33:02 2005 UTC vs.
Revision 3.12 by greg, Sat Jan 15 16:57:46 2022 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #include "copyright.h"
11  
12   #include <stdio.h>
13 + #include <stdlib.h>
14   #include "tiffio.h"
15   #include "tmprivat.h"
16   #include "tmaptiff.h"
# Line 78 | Line 79 | getTIFFtype(TIFF *tif)
79  
80   /* load and convert TIFF */
81   int
82 < tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp,
82 > tmLoadTIFF(TMstruct *tms, TMbright **lpp, uby8 **cpp,
83                  int *xp, int *yp, char *fname, TIFF *tp)
84   {
85          char    *funcName = fname==NULL ? "tmLoadTIFF" : fname;
# Line 87 | Line 88 | tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp,
88          float   *fa;
89          TIFF    *tif;
90          int     err;
91 <        union {uint16 *w; uint32 *l; float *f; MEM_PTR p;} sl;
91 >        union {uint16 *w; uint32 *l; float *f; void *p;} sl;
92          uint32  width, height;
93          int     tcase;
94          double  stonits;
# Line 133 | Line 134 | tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp,
134          case TC_LOGLUV24:
135                  TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_RAW);
136                  sl.l = (uint32 *)malloc(width*sizeof(uint32));
137 <                tmSetSpace(tms, TM_XYZPRIM, stonits);
137 >                tmSetSpace(tms, TM_XYZPRIM, stonits, NULL);
138                  break;
139          case TC_LOGL16:
140                  TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_16BIT);
141                  sl.w = (uint16 *)malloc(width*sizeof(uint16));
142 <                tmSetSpace(tms, tms->monpri, stonits);
142 >                tmSetSpace(tms, tms->monpri, stonits, NULL);
143                  break;
144          case TC_RGBFLOAT:
145                  sl.f = (float *)malloc(width*3*sizeof(float));
146 <                tmSetSpace(tms, inppri, stonits);
146 >                tmSetSpace(tms, inppri, stonits, NULL);
147                  break;
148          case TC_GRYFLOAT:
149                  sl.f = (float *)malloc(width*sizeof(float));
150 <                tmSetSpace(tms, tms->monpri, stonits);
150 >                tmSetSpace(tms, tms->monpri, stonits, NULL);
151                  break;
152          case TC_RGBSHORT:
153                  sl.w = (uint16 *)malloc(width*3*sizeof(uint16));
154 <                tmSetSpace(tms, inppri, stonits);
154 >                tmSetSpace(tms, inppri, stonits, NULL);
155                  break;
156          case TC_GRYSHORT:
157                  sl.w = (uint16 *)malloc(width*sizeof(uint16));
158 <                tmSetSpace(tms, tms->monpri, stonits);
158 >                tmSetSpace(tms, tms->monpri, stonits, NULL);
159                  break;
160          default:
161                  err = TM_E_CODERR1;
# Line 172 | Line 173 | tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp,
173          case TC_RGBSHORT:
174                  if (cpp == TM_NOCHROMP)
175                          break;
176 <                *cpp = (BYTE *)malloc(width*height*3*sizeof(BYTE));
176 >                *cpp = (uby8 *)malloc(width*height*3*sizeof(uby8));
177                  if (*cpp == NULL) {
178                          err = TM_E_NOMEM;
179                          goto done;
# Line 230 | Line 231 | done:                                  /* clean up */
231                  free(sl.p);
232          if (err != TM_E_OK) {           /* free buffers on error */
233                  if (*lpp != NULL)
234 <                        free((MEM_PTR)*lpp);
234 >                        free(*lpp);
235                  *lpp = NULL;
236                  if (cpp != TM_NOCHROMP) {
237                          if (*cpp != TM_NOCHROM)
238 <                                free((MEM_PTR)*cpp);
238 >                                free(*cpp);
239                          *cpp = NULL;
240                  }
241                  *xp = *yp = 0;
# Line 251 | Line 252 | done:                                  /* clean up */
252   * As in tmMapPicture(), grey values are also returned if flags&TM_F_BW.
253   */
254   int
255 < tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGBPRIMP monpri,
255 > tmMapTIFF(uby8 **psp, int *xp, int *yp, int flags, RGBPRIMP monpri,
256          double gamval, double Lddyn, double Ldmax, char *fname, TIFF *tp)
257   {
258          char    *funcName = fname==NULL ? "tmMapTIFF" : fname;
259 <        TMstruct        *tms;
259 >        TMstruct        *tms = NULL;
260          TMbright        *lp;
261 <        BYTE    *cp;
261 >        uby8    *cp;
262          int     err;
263                                          /* check arguments */
264          if ((psp == NULL) | (xp == NULL) | (yp == NULL) | (monpri == NULL) |
# Line 279 | Line 280 | tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGB
280                  return(err);
281          }
282          if (cp == TM_NOCHROM) {
283 <                *psp = (BYTE *)malloc(*xp * *yp * sizeof(BYTE));
283 >                *psp = (uby8 *)malloc(*xp * *yp * sizeof(uby8));
284                  if (*psp == NULL) {
285 <                        free((MEM_PTR)lp);
285 >                        free(lp);
286                          tmDone(tms);
287                          returnErr(TM_E_NOMEM);
288                  }
# Line 298 | Line 299 | tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGB
299          err = tmMapPixels(tms, *psp, lp, cp, *xp * *yp);
300  
301   done:                                   /* clean up */
302 <        free((MEM_PTR)lp);
302 >        free(lp);
303          tmDone(tms);
304          if (err != TM_E_OK) {           /* free memory on error */
305 <                free((MEM_PTR)*psp);
305 >                free(*psp);
306                  *psp = NULL;
307                  *xp = *yp = 0;
308                  returnErr(err);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines