~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to libs/libkdcraw/libraw/samples/identify.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- C++ -*-
2
 
 * File: identify.cpp
3
 
 * Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
4
 
 * Created: Sat Mar  8 , 2008
5
 
 *
6
 
 * LibRaw C++ demo (emulates dcraw -i [-v])
7
 
 *
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)
11
 
 * any later version.
12
 
 *
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.
17
 
 *
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
21
 
 * 02111-1307, USA.
22
 
 */
23
 
 
24
 
#include <stdio.h>
25
 
#include <string.h>
26
 
#include <math.h>
27
 
#include <time.h>
28
 
 
29
 
#include "libraw/libraw.h"
30
 
 
31
 
#ifdef WIN32
32
 
#define snprintf _snprintf
33
 
#endif
34
 
 
35
 
 
36
 
int main(int ac, char *av[])
37
 
{
38
 
    int verbose = 0, ret,print_unpack=0,print_frame=0;
39
 
    LibRaw MyCoolRawProcessor;
40
 
 
41
 
    for (int i=1;i<ac;i++) {
42
 
        if(av[i][0]=='-')
43
 
            {
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++;
47
 
                continue;
48
 
            }
49
 
        if( (ret = MyCoolRawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
50
 
            {
51
 
                printf("Cannot decode %s: %s\n",av[i],libraw_strerror(ret));
52
 
                continue; // no recycle, open_file will recycle
53
 
            }
54
 
        if(verbose) {
55
 
 
56
 
#define P1 MyCoolRawProcessor.imgdata.idata
57
 
#define P2 MyCoolRawProcessor.imgdata.other
58
 
 
59
 
#define S MyCoolRawProcessor.imgdata.sizes
60
 
#define O MyCoolRawProcessor.imgdata.params
61
 
#define C MyCoolRawProcessor.imgdata.color
62
 
#define T MyCoolRawProcessor.imgdata.thumbnail
63
 
 
64
 
 
65
 
            if( (ret =  MyCoolRawProcessor.adjust_sizes_info_only()))
66
 
            {
67
 
                printf("Cannot decode %s: %s\n",av[i],libraw_strerror(ret));
68
 
                continue; // no recycle, open_file will recycle
69
 
            }
70
 
            
71
 
            printf ("\nFilename: %s\n", av[i]);
72
 
            printf ("Timestamp: %s", ctime(&(P2.timestamp)));
73
 
            printf ("Camera: %s %s\n", P1.make, P1.model);
74
 
            if (P2.artist[0])
75
 
                printf ("Owner: %s\n", P2.artist);
76
 
            if (P1.dng_version) {
77
 
                printf ("DNG Version: ");
78
 
                for (int i=24; i >= 0; i -= 8)
79
 
                    printf ("%d%c", P1.dng_version >> i & 255, i ? '.':'\n');
80
 
            }
81
 
            printf ("ISO speed: %d\n", (int) P2.iso_speed);
82
 
            printf ("Shutter: ");
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);
88
 
            if(C.profile)
89
 
                printf ("Embedded ICC profile: yes, %d bytes\n", C.profile_length);
90
 
            else
91
 
                printf ("Embedded ICC profile: no\n", C.profile_length);
92
 
                
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);
96
 
            if (T.tlength)
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);
99
 
            
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);
103
 
            if (P1.filters) 
104
 
                {
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)]);
109
 
                }
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) 
113
 
                {
114
 
                    printf ("\nCamera multipliers:");
115
 
                    for(int c=0;c<4;c++) printf (" %f", C.cam_mul[c]);
116
 
                }
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]);
123
 
            putchar ('\n');
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]);
127
 
        }
128
 
        else 
129
 
            {
130
 
                if(print_unpack)
131
 
                    {
132
 
                        char frame[32]="";
133
 
                        if(print_frame)
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", 
136
 
                                av[i],
137
 
                                MyCoolRawProcessor.unpack_function_name(),
138
 
                                frame,
139
 
                                P1.make, P1.model);
140
 
                    }
141
 
                else
142
 
                    printf ("%s is a %s %s image.\n", av[i],P1.make, P1.model);
143
 
            }
144
 
        MyCoolRawProcessor.recycle();
145
 
    }// endfor
146
 
    return 0;
147
 
}