Commit 78e7bc0f authored by Simon Eugster's avatar Simon Eugster
Browse files

Curves planes:

* Luma plane can be exported as well
* Scale factor defines the maximum variance (255 = full range by default) of the selected component

svn path=/trunk/kdenlive/; revision=4755
parent 42af581e
......@@ -96,7 +96,14 @@ void ColorPlaneExport::slotUpdateDisplays()
{
m_scaling = 1 - (float)sliderScaling->value()/100;
lblScaleNr->setText("0..." + QString::number(m_scaling, 'f', 2));
switch(cbColorspace->itemData(cbColorspace->currentIndex()).toInt()){
case CPE_RGB_CURVE:
lblScaleNr->setText(QChar(0xb1) + QString::number(sliderScaling->value(), 'f', 2));;
break;
default:
lblScaleNr->setText("0..." + QString::number(m_scaling, 'f', 2));
break;
}
switch (cbColorspace->itemData(cbColorspace->currentIndex()).toInt()) {
case CPE_YUV_Y:
......@@ -158,7 +165,8 @@ void ColorPlaneExport::slotExportPlane()
img = m_colorTools->yuvColorWheel(size, sliderColor->value(), m_scaling, true, false);
break;
case CPE_RGB_CURVE:
img = m_colorTools->rgbCurvePlane(size, (ColorTools::ColorsRGB) (cbVariant->itemData(cbVariant->currentIndex()).toInt()));
img = m_colorTools->rgbCurvePlane(size, (ColorTools::ColorsRGB) (cbVariant->itemData(cbVariant->currentIndex()).toInt()),
(double)sliderScaling->value()/255);
break;
case CPE_YPbPr:
img = m_colorTools->yPbPrColorWheel(size, sliderColor->value(), m_scaling, false);
......@@ -194,7 +202,16 @@ void ColorPlaneExport::slotColormodeChanged()
lblSliderName->setToolTip(i18n("Angle through the UV plane, with all possible Y values."));
break;
case CPE_RGB_CURVE:
// deliberately fall through
enableSliderScaling(true);
enableSliderColor(false);
enableCbVariant(true);
sliderScaling->setRange(1,255);
sliderScaling->setValue(255);
cbVariant->addItem(i18n("Red"), QVariant(ColorTools::COL_R));
cbVariant->addItem(i18n("Green"), QVariant(ColorTools::COL_G));
cbVariant->addItem(i18n("Blue"), QVariant(ColorTools::COL_B));
cbVariant->addItem(i18n("Luma"), QVariant(ColorTools::COL_Luma));
break;
default:
enableSliderScaling(false);
enableSliderColor(false);
......@@ -202,6 +219,7 @@ void ColorPlaneExport::slotColormodeChanged()
cbVariant->addItem(i18n("Red"), QVariant(ColorTools::COL_R));
cbVariant->addItem(i18n("Green"), QVariant(ColorTools::COL_G));
cbVariant->addItem(i18n("Blue"), QVariant(ColorTools::COL_B));
cbVariant->addItem(i18n("Luma"), QVariant(ColorTools::COL_Luma));
break;
}
this->update();
......
......@@ -134,8 +134,10 @@ QImage ColorTools::yuvVerticalPlane(const QSize &size, const float &angle, const
}
QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorsRGB &color)
QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling)
{
Q_ASSERT(scaling > 0 && scaling <= 1);
QImage plane(size, QImage::Format_ARGB32);
if (size.width() == 0 || size.height() == 0) {
qCritical("ERROR: Size of the color plane must not be 0!");
......@@ -151,14 +153,20 @@ QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorsRGB &color)
dval = (double)255*x/(w-1);
for (int y = 0; y < h; y++) {
dcol = (double)255*y/(h-1);
if (1-scaling < 0.0001) {
dcol = (double)255*y/(h-1);
} else {
dcol = (double)255 * (y - (y-x)*(1-scaling))/(h-1);
}
if (color == ColorTools::COL_R) {
plane.setPixel(x, (h-y-1), qRgb(dcol, dval, dval));
} else if (color == ColorTools::COL_G) {
plane.setPixel(x, (h-y-1), qRgb(dval, dcol, dval));
} else {
} else if (color == ColorTools::COL_B){
plane.setPixel(x, (h-y-1), qRgb(dval, dval, dcol));
} else {
plane.setPixel(x, (h-y-1), qRgb(dcol, dcol, dcol));
}
}
......
......@@ -26,7 +26,7 @@ class ColorTools : public QObject
public:
ColorTools();
enum ColorsRGB { COL_R, COL_G, COL_B };
enum ColorsRGB { COL_R, COL_G, COL_B, COL_Luma };
/**
@brief Draws a UV plane with given Y value.
......@@ -50,8 +50,11 @@ public:
are neutral colors. The colors on the y axis show what the neutral color will look like when modifying the curve.
color defines the color to modify on the y axis. The other two components will be increased
in equal terms (linear as well) on the x axis.
scaling \in ]0,1] defines the maximum variance of the selected component; Chosing a value lower than 1
simulates the case that the curves can adjust only +- scaling*255. This mainly delivers a more constant look
when also using the Luma component for the curves display but might not represent the actual color change!
*/
static QImage rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color);
static QImage rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling = 1);
/**
@brief Draws a YPbPr plane with Pb on the x axis and Pr on the y axis.
Y is the Y value to use.
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>553</width>
<height>241</height>
<width>551</width>
<height>239</height>
</rect>
</property>
<property name="windowTitle">
......@@ -47,7 +47,7 @@
<item row="2" column="0">
<widget class="QLabel" name="lblSliderName">
<property name="text">
<string notr="true">(notr.ansl.)</string>
<string notr="true">(notransl.)</string>
</property>
</widget>
</item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment