]> git.sesse.net Git - kdenlive/commitdiff
Curves planes:
authorSimon A. Eugster <simon.eu@gmail.com>
Tue, 24 Aug 2010 20:49:28 +0000 (20:49 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Tue, 24 Aug 2010 20:49:28 +0000 (20:49 +0000)
* 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
src/colortools.cpp
src/colortools.h
src/widgets/colorplaneexport_ui.ui

index b37efd76355a2ef2ab25123db953c93e14af977a..5f55e52d390bcb4cd4ba7f22d359489c9f7edc09 100644 (file)
@@ -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();
index c0cd5b73464ebbac73b4e9cf3865a75e575c6e90..9f8b4806b247f7dbb3687effc41b688a9f738eaf 100644 (file)
@@ -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));
             }
 
         }
index 0afabe0bce56c422cac93fdca0b0daa449e2ee8e..0441377c4e8df12bc923dc385ea81444ec772ee9 100644 (file)
@@ -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.
index 624a771141e2e6a323c7e9c2e7d5e6093be72b92..9cc7a8f078ae4ec32a30ceafa11655009617914a 100644 (file)
@@ -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>