2
* File: multirender_test.cpp
3
* Copyright 2008-2011 LibRaw LLC (info@libraw.org)
4
* Created: Jul 10, 2011
6
* LibRaw simple C++ API: creates 8 different renderings from 1 source file. The 1st and 4th one should be identical
8
LibRaw is free software; you can redistribute it and/or modify
9
it under the terms of the one of three licenses as you choose:
11
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
12
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
14
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
15
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
17
3. LibRaw Software License 27032010
18
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
34
#include "libraw/libraw.h"
37
#define snprintf _snprintf
40
int process_once(LibRaw& RawProcessor, int half_mode, int camera_wb, int auto_wb, int suffix, int user_flip,char *fname)
43
RawProcessor.imgdata.params.half_size = half_mode;
44
RawProcessor.imgdata.params.use_camera_wb = camera_wb;
45
RawProcessor.imgdata.params.use_auto_wb = auto_wb;
46
RawProcessor.imgdata.params.user_flip = user_flip;
48
int ret = RawProcessor.dcraw_process();
50
if(LIBRAW_SUCCESS !=ret)
52
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",
53
fname,libraw_strerror(ret));
56
snprintf(outfn,sizeof(outfn),"%s.%d.%s", fname, suffix, (RawProcessor.imgdata.idata.colors>1?"ppm":"pgm"));
58
printf("Writing file %s\n",outfn);
60
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
61
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
67
int main(int ac, char *av[])
75
"multirender_test - LibRaw %s sample. Performs 4 different renderings of one file\n"
76
" %d cameras supported\n"
77
"Usage: %s raw-files....\n"
78
,LibRaw::version(), LibRaw::cameraCount(),
86
printf("Processing file %s\n",av[i]);
88
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
90
fprintf(stderr,"Cannot open_file %s: %s\n",av[i],libraw_strerror(ret));
91
continue; // no recycle b/c open file will recycle itself
94
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
96
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
99
process_once(RawProcessor,0,0,0,1,-1,av[i]); // default flip
100
process_once(RawProcessor,1,0,1,2,-1,av[i]);
101
process_once(RawProcessor,1,1,0,3,-1,av[i]); // default flip
102
process_once(RawProcessor,1,1,0,4,1,av[i]); // flip 1
103
process_once(RawProcessor,1,1,0,5,3,av[i]); // flip 3
104
process_once(RawProcessor,1,1,0,6,1,av[i]); // 1 again same as 4
105
process_once(RawProcessor,1,1,0,7,-1,av[i]); // default again, same as 3
106
process_once(RawProcessor,0,0,0,8,-1,av[i]); // same as 1
108
RawProcessor.recycle(); // just for show this call