| 10 |
|
#include <time.h> |
| 11 |
|
#include <string.h> |
| 12 |
|
|
| 13 |
+ |
#include "platform.h" |
| 14 |
|
#include "tiffio.h" |
| 15 |
|
#include "color.h" |
| 16 |
|
#include "tonemap.h" |
| 44 |
|
RESOLU rs; /* picture resolution */ |
| 45 |
|
} PICTURE; |
| 46 |
|
|
| 47 |
< |
//extern PICTURE *openpicture(); |
| 47 |
> |
uint16 comp = COMPRESSION_NONE; /* TIFF compression mode */ |
| 48 |
|
|
| 49 |
|
#define closepicture(p) (fclose((p)->fp),free((void *)(p))) |
| 50 |
|
|
| 51 |
|
static gethfunc headline; |
| 52 |
|
|
| 53 |
< |
static int headline(char *s, void *pp); |
| 54 |
< |
static PICTURE * openpicture(char *fname); |
| 55 |
< |
static int tmap_picture(char *fname, PICTURE *pp); |
| 56 |
< |
static int tmap_tiff(char *fname, TIFF *tp); |
| 57 |
< |
static int putimage(uint16 or, uint32 xs, uint32 ys, float xr, float yr, |
| 53 |
> |
static int headline(char *s, void *pp); |
| 54 |
> |
static PICTURE *openpicture(char *fname); |
| 55 |
> |
static int tmap_picture(char *fname, PICTURE *pp); |
| 56 |
> |
static int tmap_tiff(char *fname, TIFF *tp); |
| 57 |
> |
static int putimage(uint16 or, uint32 xs, uint32 ys, float xr, float yr, |
| 58 |
|
uint16 ru, BYTE *pd); |
| 59 |
|
|
| 60 |
|
|
| 97 |
|
if (argc-i < 2) goto userr; |
| 98 |
|
lddyn = atof(argv[++i]); |
| 99 |
|
break; |
| 100 |
+ |
case 'z': /* LZW compression */ |
| 101 |
+ |
comp = COMPRESSION_LZW; |
| 102 |
+ |
break; |
| 103 |
|
case 'p': /* set display primaries */ |
| 104 |
|
if (argc-i < 9) goto userr; |
| 105 |
|
myprims[RED][CIEX] = atof(argv[++i]); |
| 138 |
|
exit(rval==0 ? 0 : 1); |
| 139 |
|
userr: |
| 140 |
|
fprintf(stderr, |
| 141 |
< |
"Usage: %s [-h][-s][-c][-l][-b][-g gv][-d ld][-u lm][-p xr yr xg yg xb yb xw yw] input.{tif|pic} output.tif\n", |
| 141 |
> |
"Usage: %s [-h][-s][-c][-l][-b][-g gv][-d ld][-u lm][-z][-p xr yr xg yg xb yb xw yw] input.{tif|hdr} output.tif\n", |
| 142 |
|
argv[0]); |
| 143 |
|
exit(1); |
| 144 |
|
} |
| 185 |
|
/* else try opening it */ |
| 186 |
|
if ((fp = fopen(fname, "r")) == NULL) |
| 187 |
|
return(NULL); |
| 188 |
+ |
SET_FILE_BINARY(fp); |
| 189 |
|
/* allocate struct */ |
| 190 |
|
if ((pp = (PICTURE *)malloc(sizeof(PICTURE))) == NULL) |
| 191 |
|
return(NULL); /* serious error -- should exit? */ |
| 213 |
|
) |
| 214 |
|
{ |
| 215 |
|
uint16 orient; |
| 216 |
+ |
double paspect = (pp->rs.rt & YMAJOR) ? pp->pa : 1./pp->pa; |
| 217 |
|
int xsiz, ysiz; |
| 218 |
|
BYTE *pix; |
| 219 |
|
/* read and tone map picture */ |
| 227 |
|
orient++; |
| 228 |
|
/* put out our image */ |
| 229 |
|
if (putimage(orient, (uint32)xsiz, (uint32)ysiz, |
| 230 |
< |
72., 72./pp->pa, 2, pix) != 0) |
| 230 |
> |
72., 72./paspect, 2, pix) != 0) |
| 231 |
|
return(-1); |
| 232 |
|
/* free data and we're done */ |
| 233 |
|
free((void *)pix); |
| 275 |
|
uint32 ys, |
| 276 |
|
float xr, |
| 277 |
|
float yr, |
| 278 |
< |
uint16 ru, |
| 278 |
> |
uint16 ru, |
| 279 |
|
BYTE *pd |
| 280 |
|
) |
| 281 |
|
{ |
| 300 |
|
TIFFSetField(tifout, TIFFTAG_IMAGEWIDTH, xs); |
| 301 |
|
TIFFSetField(tifout, TIFFTAG_IMAGELENGTH, ys); |
| 302 |
|
TIFFSetField(tifout, TIFFTAG_RESOLUTIONUNIT, ru); |
| 303 |
+ |
TIFFSetField(tifout, TIFFTAG_COMPRESSION, comp); |
| 304 |
|
TIFFSetField(tifout, TIFFTAG_XRESOLUTION, xr); |
| 305 |
|
TIFFSetField(tifout, TIFFTAG_YRESOLUTION, yr); |
| 306 |
|
TIFFSetField(tifout, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); |