From 78e7bc0f7be6be004acfc44d92367a302b20e46f Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Tue, 24 Aug 2010 20:49:28 +0000 Subject: [PATCH] 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 --- src/colorplaneexport.cpp | 24 +++++++++++++++++++++--- src/colortools.cpp | 14 +++++++++++--- src/colortools.h | 7 +++++-- src/widgets/colorplaneexport_ui.ui | 6 +++--- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/colorplaneexport.cpp b/src/colorplaneexport.cpp index b37efd76..5f55e52d 100644 --- a/src/colorplaneexport.cpp +++ b/src/colorplaneexport.cpp @@ -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(); diff --git a/src/colortools.cpp b/src/colortools.cpp index c0cd5b73..9f8b4806 100644 --- a/src/colortools.cpp +++ b/src/colortools.cpp @@ -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)); } } diff --git a/src/colortools.h b/src/colortools.h index 0afabe0b..0441377c 100644 --- a/src/colortools.h +++ b/src/colortools.h @@ -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. diff --git a/src/widgets/colorplaneexport_ui.ui b/src/widgets/colorplaneexport_ui.ui index 624a7711..9cc7a8f0 100644 --- a/src/widgets/colorplaneexport_ui.ui +++ b/src/widgets/colorplaneexport_ui.ui @@ -6,8 +6,8 @@ 0 0 - 553 - 241 + 551 + 239 @@ -47,7 +47,7 @@ - (notr.ansl.) + (notransl.) -- 2.39.2