]> git.sesse.net Git - kdenlive/blob - src/colortools.h
Fix indent
[kdenlive] / src / colortools.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program 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 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10
11 /**
12   Color tools.
13  */
14
15 #ifndef COLORTOOLS_H
16 #define COLORTOOLS_H
17
18 #include <QImage>
19
20
21 class ColorTools : public QObject
22 {
23     Q_OBJECT
24
25 public:
26     ColorTools();
27
28     enum ColorsRGB { COL_R, COL_G, COL_B, COL_A, COL_Luma, COL_RGB };
29
30     enum ComponentsHSV { COM_H, COM_S, COM_V };
31
32     /**
33       @brief Draws a UV plane with given Y value.
34       scaling defines how far to zoom in (or out). Lower value = zoom in.
35       The modified version always scales the RGB values so that at least one of them attains 255.
36       If not the full rect should be filled, set circleOnly to true.
37       See also: http://en.wikipedia.org/wiki/YUV and http://de.wikipedia.org/wiki/Vektorskop
38      */
39     QImage yuvColorWheel(const QSize& size, const unsigned char &Y, const float &scaling, const bool &modifiedVersion, const bool &circleOnly);
40     /**
41       @brief Draws a UV plane with given UV angle (ratio u:v stays constant)
42       scaling defines how far to zoom in (or out). Lower value = zoom in.
43       angle defines the angle in a default U/V plane. A vertical plane, on which Y goes from 0 to 1,
44       is then laid through the UV plane, with the defined angle.
45       @see yuvColorWheel()
46      */
47     QImage yuvVerticalPlane(const QSize &size, const float &angle, const float &scaling);
48     /**
49       @brief Draws a RGB plane with two values on one axis and one on the other.
50       This is e.g. useful as background for a curves dialog. On the line from bottom left to top right
51       are neutral colors. The colors on the y axis show what the neutral color will look like when modifying the curve.
52       color defines the color to modify on the y axis. The other two components will be increased
53       in equal terms (linear as well) on the x axis.
54       scaling \in ]0,1] defines the maximum variance of the selected component; Chosing a value lower than 1
55       simulates the case that the curves can adjust only +- scaling*255. This mainly delivers a more constant look
56       when also using the Luma component for the curves display but might not represent the actual color change!
57      */
58     static QImage rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling = 1, const QRgb &background = QRgb());
59     /**
60       @brief Draws a YPbPr plane with Pb on the x axis and Pr on the y axis.
61       Y is the Y value to use.
62       scaling defines how far to zoom in (or out). Lower value = zoom in.
63       See also: http://de.wikipedia.org/wiki/YPbPr-Farbmodell and http://www.poynton.com/ColorFAQ.html
64      */
65     QImage yPbPrColorWheel(const QSize &size, const unsigned char &Y, const float &scaling, const bool &circleOnly);
66     /**
67      @brief Draws a HSV plane with Hue on the x axis and hue difference on the y axis.
68      This is for the Bézier Curves widget which allows to change the hue (y) of a certain hue.
69      MIN/MAX give the minimum/maximum hue difference, e.g. -128,+128.
70      For the value ranges see:
71      http://doc.qt.nokia.com/latest/qcolor.html#the-hsv-color-model
72      */
73     static QImage hsvHueShiftPlane(const QSize &size, const uint &S, const uint &V, const int &MIN, const int &MAX);
74
75     /**
76       Basic HSV plane with two components varying on the x and y axis.
77       If both components are the same, then the y axis will be considered.
78       MIN/MAX give the minimum/maximum saturation, usually 0..255.
79       Missing colour components will be taken from baseColor.
80       For shear == true, the image will be sheared such that the x axis goes through (0,0) and (1,1). offsetY can additionally
81       shift the whole x axis vertically.
82       */
83     static QImage hsvCurvePlane(const QSize &size, const QColor &baseColor,
84                                 const ComponentsHSV &xVariant, const ComponentsHSV &yVariant, const bool &shear = false, const float offsetY = 0);
85
86 signals:
87     void signalYuvWheelCalculationFinished();
88 };
89
90 #endif // COLORTOOLS_H