~ubuntu-branches/ubuntu/saucy/libraw/saucy

« back to all changes in this revision

Viewing changes to samples/multirender_test.cpp

  • Committer: Package Import Robot
  • Author(s): Luca Falavigna
  • Date: 2011-09-24 15:32:39 UTC
  • mfrom: (1.4.2) (0.1.6 experimental)
  • Revision ID: package-import@ubuntu.com-20110924153239-3s5echwj1dx3ti8l
Tags: 0.14.0-1
* Team upload.
* New upstream release.
* debian/control:
  - Replace libraw2 with libraw5, SONAME changed.
  - libraw-dev depends on libraw5 accordingly.
  - Build-depend on pkg-config, libjasper-dev and liblcms2-dev.
* debian/libraw5.install:
  - Renamed from libraw2.install to match new binary.
* debian/libraw5.symbols.amd64:
  - Renamed from libraw2.symbols.amd64 to match new binary.
* debian/rules:
  - Update dh_makeshlibs call to match new binary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- C++ -*-
 
2
 * File: multirender_test.cpp
 
3
 * Copyright 2008-2011 LibRaw LLC (info@libraw.org)
 
4
 * Created: Jul 10, 2011
 
5
 *
 
6
 * LibRaw simple C++ API:  creates 8 different renderings from 1 source file. The 1st and 4th one should be identical
 
7
 
 
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:
 
10
 
 
11
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
 
12
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
 
13
 
 
14
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
 
15
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
 
16
 
 
17
3. LibRaw Software License 27032010
 
18
   (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
 
19
 
 
20
 
 
21
 
 
22
 */
 
23
#include <stdio.h>
 
24
#include <string.h>
 
25
#include <math.h>
 
26
 
 
27
#ifndef WIN32
 
28
#include <unistd.h>
 
29
#include <fcntl.h>
 
30
#include <sys/stat.h>
 
31
#include <sys/mman.h>
 
32
#endif
 
33
 
 
34
#include "libraw/libraw.h"
 
35
 
 
36
#ifdef WIN32
 
37
#define snprintf _snprintf
 
38
#endif
 
39
 
 
40
int process_once(LibRaw& RawProcessor, int half_mode, int camera_wb, int auto_wb, int suffix, int user_flip,char *fname)
 
41
{
 
42
    char outfn[1024];
 
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;
 
47
 
 
48
    int ret = RawProcessor.dcraw_process();
 
49
                
 
50
    if(LIBRAW_SUCCESS !=ret)
 
51
        {
 
52
            fprintf(stderr,"Cannot do postpocessing on %s: %s\n",
 
53
                    fname,libraw_strerror(ret));
 
54
            return ret; 
 
55
        }
 
56
    snprintf(outfn,sizeof(outfn),"%s.%d.%s", fname, suffix, (RawProcessor.imgdata.idata.colors>1?"ppm":"pgm"));
 
57
 
 
58
    printf("Writing file %s\n",outfn);
 
59
 
 
60
    if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
 
61
        fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
 
62
    return ret;
 
63
}
 
64
 
 
65
 
 
66
 
 
67
int main(int ac, char *av[])
 
68
{
 
69
    int  i, ret;
 
70
 
 
71
    LibRaw RawProcessor;
 
72
    if(ac<2) 
 
73
        {
 
74
            printf(
 
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(),
 
79
                av[0]);
 
80
            return 0;
 
81
        }
 
82
    
 
83
    for (i=1;i<ac;i++)
 
84
        {
 
85
 
 
86
            printf("Processing file %s\n",av[i]);
 
87
 
 
88
            if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
 
89
                {
 
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
 
92
                }
 
93
            
 
94
            if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
 
95
                {
 
96
                    fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
 
97
                    continue;
 
98
                }
 
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
 
107
 
 
108
            RawProcessor.recycle(); // just for show this call
 
109
        }
 
110
    return 0;
 
111
}