3 * Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
4 * Created: Sat Mar 8 , 2008
6 * LibRaw C++ demo (emulates dcraw -i [-v])
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 #include "libraw/libraw.h"
32 #define snprintf _snprintf
36 int main(int ac
, char *av
[])
38 int verbose
= 0, ret
,print_unpack
=0,print_frame
=0;
39 LibRaw MyCoolRawProcessor
;
41 for (int i
=1;i
<ac
;i
++) {
44 if(av
[i
][1]=='v' && av
[i
][2]==0) verbose
++;
45 if(av
[i
][1]=='u' && av
[i
][2]==0) print_unpack
++;
46 if(av
[i
][1]=='f' && av
[i
][2]==0) print_frame
++;
49 if( (ret
= MyCoolRawProcessor
.open_file(av
[i
])) != LIBRAW_SUCCESS
)
51 printf("Cannot decode %s: %s\n",av
[i
],libraw_strerror(ret
));
52 continue; // no recycle, open_file will recycle
56 #define P1 MyCoolRawProcessor.imgdata.idata
57 #define P2 MyCoolRawProcessor.imgdata.other
59 #define S MyCoolRawProcessor.imgdata.sizes
60 #define O MyCoolRawProcessor.imgdata.params
61 #define C MyCoolRawProcessor.imgdata.color
62 #define T MyCoolRawProcessor.imgdata.thumbnail
65 if( (ret
= MyCoolRawProcessor
.adjust_sizes_info_only()))
67 printf("Cannot decode %s: %s\n",av
[i
],libraw_strerror(ret
));
68 continue; // no recycle, open_file will recycle
71 printf ("\nFilename: %s\n", av
[i
]);
72 printf ("Timestamp: %s", ctime(&(P2
.timestamp
)));
73 printf ("Camera: %s %s\n", P1
.make
, P1
.model
);
75 printf ("Owner: %s\n", P2
.artist
);
77 printf ("DNG Version: ");
78 for (int i
=24; i
>= 0; i
-= 8)
79 printf ("%d%c", P1
.dng_version
>> i
& 255, i
? '.':'\n');
81 printf ("ISO speed: %d\n", (int) P2
.iso_speed
);
83 if (P2
.shutter
> 0 && P2
.shutter
< 1)
84 P2
.shutter
= (printf ("1/"), 1 / P2
.shutter
);
85 printf ("%0.1f sec\n", P2
.shutter
);
86 printf ("Aperture: f/%0.1f\n", P2
.aperture
);
87 printf ("Focal length: %0.1f mm\n", P2
.focal_len
);
89 printf ("Embedded ICC profile: yes, %d bytes\n", C
.profile_length
);
91 printf ("Embedded ICC profile: no\n", C
.profile_length
);
93 printf ("Number of raw images: %d\n", P1
.raw_count
);
94 if (S
.pixel_aspect
!= 1)
95 printf ("Pixel Aspect Ratio: %0.6f\n", S
.pixel_aspect
);
97 printf ("Thumb size: %4d x %d\n", T
.twidth
, T
.theight
);
98 printf ("Full size: %4d x %d\n", S
.raw_width
, S
.raw_height
);
100 printf ("Image size: %4d x %d\n", S
.width
, S
.height
);
101 printf ("Output size: %4d x %d\n", S
.iwidth
, S
.iheight
);
102 printf ("Raw colors: %d", P1
.colors
);
105 printf ("\nFilter pattern: ");
106 if (!P1
.cdesc
[3]) P1
.cdesc
[3] = 'G';
107 for (int i
=0; i
< 16; i
++)
108 putchar (P1
.cdesc
[MyCoolRawProcessor
.fc(i
>> 1,i
& 1)]);
110 printf ("\nDaylight multipliers:");
111 for(int c
=0;c
<P1
.colors
;c
++) printf (" %f", C
.pre_mul
[c
]);
112 if (C
.cam_mul
[0] > 0)
114 printf ("\nCamera multipliers:");
115 for(int c
=0;c
<4;c
++) printf (" %f", C
.cam_mul
[c
]);
117 char *csl
[] = {"U","I","CO","L","CA"};
118 printf("\nColor sources /Legend: (U)nknown, (I)nit, (CO)nstant, (L)oaded, (CA)lculated/:\n");
119 printf("\tcurve=%s; rgb_cam=%s; cmatrix=%s, pre_mul=%s, cam_mul=%s",
120 csl
[C
.color_flags
.curve_state
],csl
[C
.color_flags
.rgb_cam_state
],
121 csl
[C
.color_flags
.cmatrix_state
],csl
[C
.color_flags
.pre_mul_state
],
122 csl
[C
.color_flags
.cam_mul_state
]);
124 printf("Cam->XYZ matrix:\n");
125 for(int i
=0; i
< 4; i
++)
126 printf("%6.4f\t%6.4f\t%6.4f\n",C
.cam_xyz
[i
][0],C
.cam_xyz
[i
][1],C
.cam_xyz
[i
][2]);
134 snprintf(frame
,32,"%dx%dx%dx%d",S
.left_margin
,S
.top_margin
,S
.right_margin
,S
.bottom_margin
);
135 printf ("%s\t%s\t%s\t%s/%s\n",
137 MyCoolRawProcessor
.unpack_function_name(),
142 printf ("%s is a %s %s image.\n", av
[i
],P1
.make
, P1
.model
);
144 MyCoolRawProcessor
.recycle();