digiKam
imagecurves.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2004-12-01
7  * Description : image curves manipulation methods.
8  *
9  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_IMAGE_CURVES_H
25 #define DIGIKAM_IMAGE_CURVES_H
26 
27 // Qt includes
28 
29 #include <QSharedDataPointer>
30 #include <QPoint>
31 #include <QPolygon>
32 #include <QUrl>
33 
34 // Local includes
35 
36 #include "digikam_globals.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class CurvesContainer;
43 
44 class DIGIKAM_EXPORT ImageCurves
45 {
46 
47 public:
48 
52  const static int NUM_POINTS = 17;
53 
57  const static int NUM_CHANNELS = 5;
58 
62  const static int MULTIPLIER_16BIT = 255;
63 
64  enum CurveType
65  {
66  CURVE_SMOOTH = 0,
67  CURVE_FREE
68  };
69 
70  typedef double CRMatrix[4][4];
71 
72 public:
73 
74  explicit ImageCurves(bool sixteenBit);
75  explicit ImageCurves(const CurvesContainer& container);
76  ImageCurves(const ImageCurves& other);
77  ~ImageCurves();
78 
79  ImageCurves& operator=(const ImageCurves& other);
80 
87  void fillFromOtherCurves(ImageCurves* const otherCurves);
88 
89 
91 
92  void curvesReset();
93  void curvesChannelReset(int channel);
94  void curvesCalculateCurve(int channel);
95  void curvesCalculateAllCurves();
96  float curvesLutFunc(int n_channels, int channel, float value);
97  void curvesLutSetup(int nchannels);
98  void curvesLutProcess(uchar* const srcPR, uchar* const destPR, int w, int h);
99 
101 
102  void setCurveValue(int channel, int bin, int val);
103  void setCurvePointX(int channel, int point, int x);
104  void setCurvePointY(int channel, int point, int y);
105  void setCurveType(int channel, CurveType type);
106  void setCurveType(CurveType type);
107 
108  void setCurvePoint(int channel, int point, const QPoint& val);
109  void setCurvePoints(int channel, const QPolygon& vals);
110  void setCurveValues(int channel, const QPolygon& vals);
111 
112  void unsetCurvePoint(int channel, int point);
113 
115 
116  bool isDirty() const;
117  bool isSixteenBits() const;
118 
119  int getCurveValue(int channel, int bin) const;
120  int getCurvePointX(int channel, int point) const;
121  int getCurvePointY(int channel, int point) const;
122  CurveType getCurveType(int channel) const;
123 
124  bool isCurvePointEnabled(int channel, int point) const;
125  QPoint getCurvePoint(int channel, int point) const;
126  QPolygon getCurvePoints(int channel) const;
127  QPolygon getCurveValues(int channel) const;
128 
130  void setContainer(const CurvesContainer& container);
131 
135  CurvesContainer getContainer() const;
136 
142  CurvesContainer getContainer(int channel) const;
143 
147  bool isLinear(int channel) const;
148  bool isLinear() const;
149 
155  QByteArray channelToBinary(int channel) const;
156 
163  bool setChannelFromBinary(int channel, const QByteArray& array);
164 
166 
167  bool saveCurvesToGimpCurvesFile(const QUrl& fileUrl) const;
168  bool loadCurvesFromGimpCurvesFile(const QUrl& fileUrl);
169 
170  static QPoint getDisabledValue();
171 
172 private:
173 
174  void curvesPlotCurve(int channel, int p1, int p2, int p3, int p4);
175  void curvesCRCompose(CRMatrix a, CRMatrix b, CRMatrix ab);
176  void freeLutData();
177 
178 private:
179 
180  class Private;
181  QSharedDataPointer<Private> d;
182 };
183 
184 } // namespace Digikam
185 
186 #endif // DIGIKAM_IMAGE_CURVES_H
Definition: curvescontainer.h:44
Definition: imagecurves.h:45
CurveType
Definition: imagecurves.h:65
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43