~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/common/curve_tools.h

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-04-14 23:42:12 UTC
  • Revision ID: james.westby@ubuntu.com-20110414234212-kuffcz5wiu18v6ra
Tags: upstream-0.8
ImportĀ upstreamĀ versionĀ 0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of darktable,
 
3
    copyright (c) 2011 Jochen Schroeder
 
4
 
 
5
    darktable is free software: you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation, either version 3 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    darktable is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with darktable.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
    part of this file is based on nikon_curve.h  from UFraw
 
19
    Copyright 2004-2008 by Shawn Freeman, Udi Fuchs
 
20
*/
 
21
 
 
22
//Curve Types
 
23
#define CUBIC_SPLINE      0
 
24
#define CATMULL_ROM     1
 
25
#define MONOTONE_HERMITE       2
 
26
 
 
27
//Maximum resoltuion allowed due to space considerations.
 
28
#define MAX_RESOLUTION    65536
 
29
#define MAX_ANCHORS 20
 
30
 
 
31
//ERROR CODES
 
32
#define CT_SUCCESS  0
 
33
#define CT_ERROR    100
 
34
#define CT_WARNING  104
 
35
#define CT_SET_ERROR    200
 
36
 
 
37
 
 
38
//////////////////////////////////////////////////////////////////////////////
 
39
//////////////////////////////////////////////////////////////////////////////
 
40
//DATA STRUCTURES
 
41
//////////////////////////////////////////////////////////////////////////////
 
42
//////////////////////////////////////////////////////////////////////////////
 
43
/**********************************************************
 
44
CurveData:
 
45
    Structure for the curve data inside a NTC/NCV file.
 
46
***********************************************************/
 
47
typedef struct
 
48
{
 
49
  float x;
 
50
  float y;
 
51
} CurveAnchorPoint;
 
52
 
 
53
typedef struct
 
54
{
 
55
  //Type for this curve
 
56
  unsigned int m_spline_type;
 
57
 
 
58
  //Box data
 
59
  float m_min_x;
 
60
  float m_max_x;
 
61
  float m_min_y;
 
62
  float m_max_y;
 
63
 
 
64
  //Number of anchor points
 
65
  unsigned char m_numAnchors;
 
66
 
 
67
  //contains a list of anchors, 2 floats per each point, x-y format
 
68
  //max is 20 points
 
69
  CurveAnchorPoint m_anchors[MAX_ANCHORS];
 
70
 
 
71
} CurveData;
 
72
 
 
73
typedef struct
 
74
{
 
75
  //Number of samples to use for the curve.
 
76
  unsigned int m_samplingRes;
 
77
  unsigned int m_outputRes;
 
78
 
 
79
  //Sampling array
 
80
  unsigned short int *m_Samples; // jo: changed to short int to save memory
 
81
 
 
82
} CurveSample;
 
83
 
 
84
/*********************************************
 
85
CurveDataSample:
 
86
    Samples from a spline curve constructed from
 
87
    the curve data.
 
88
 
 
89
    curve   - Pointer to curve struct to hold the data.
 
90
    sample  - Pointer to sample struct to hold the data.
 
91
**********************************************/
 
92
int CurveDataSample(CurveData *curve, CurveSample *sample);
 
93
 
 
94
/***************************************************************
 
95
 * interpolate_set:
 
96
 *
 
97
 * convenience function for calculating the necessary parameters for
 
98
 * interpolation.
 
99
 *
 
100
 * input:
 
101
 *      n    - length of data arrays
 
102
 *      x    - x axis of the data array
 
103
 *      y    - y axis of the data array
 
104
 *      type - type of interpolation currently either CUBIC or HERMITE
 
105
 * output:
 
106
 *      ypp  - pointer to array of parameters
 
107
 *******************************************************************/
 
108
float *interpolate_set( int n, float x[], float y[], unsigned int type);
 
109
 
 
110
/***************************************************************
 
111
 * interpolate_val:
 
112
 *
 
113
 * convenience function for piecewise interpolation
 
114
 *
 
115
 * input:
 
116
 *      n    - length of data arrays
 
117
 *      x    - x axis of the data array
 
118
 *      xval - point where to interpolate
 
119
 *      y    - y axis of the data array
 
120
 *      tangents - parameters calculated with interpolate_set
 
121
 *      type - type of interpolation currently either CUBIC or HERMITE
 
122
 * output:
 
123
 *      yval  - interpolated value at xval
 
124
 *******************************************************************/
 
125
float interpolate_val( int n, float x[], float xval, float y[], float tangents[], unsigned int type);