]> git.sesse.net Git - kdenlive/commitdiff
HSV Saturation plane added
authorSimon A. Eugster <simon.eu@gmail.com>
Tue, 22 Feb 2011 14:19:03 +0000 (14:19 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Tue, 22 Feb 2011 14:19:03 +0000 (14:19 +0000)
svn path=/trunk/kdenlive/; revision=5452

src/colorplaneexport.cpp
src/colorplaneexport.h
src/colortools.cpp
src/colortools.h

index 37c1ee4f267feeb0bfba3fc29704b505b4ffcfbe..107cd4e7b1ca77d86c0b75f54757d90046b589e0 100644 (file)
@@ -35,6 +35,7 @@ ColorPlaneExport::ColorPlaneExport(QWidget *parent) :
     cbColorspace->addItem(i18n("YCbCr CbCr plane"), QVariant(ColorPlaneExport::CPE_YPbPr));
     cbColorspace->addItem(i18n("RGB plane, one component varying"), QVariant(ColorPlaneExport::CPE_RGB_CURVE));
     cbColorspace->addItem(i18n("HSV Hue Shift"), QVariant(ColorPlaneExport::CPE_HSV_HUESHIFT));
+    cbColorspace->addItem(i18n("HSV Saturation"), QVariant(ColorPlaneExport::CPE_HSV_SATURATION));
 
     sliderColor->setSliderPosition(128);
 
@@ -188,6 +189,11 @@ void ColorPlaneExport::slotExportPlane()
     case CPE_HSV_HUESHIFT:
         img = m_colorTools->hsvHueShiftPlane(size, sliderColor->value(), sliderScaling->value(), -180, 180);
         break;
+    case CPE_HSV_SATURATION:
+        img = m_colorTools->hsvSaturationPlane(size, sliderColor->value(), 0, 255);
+        break;
+    default:
+        Q_ASSERT(false);
     }
     img.save(kurlrequester->text());
 }
@@ -247,6 +253,13 @@ void ColorPlaneExport::slotColormodeChanged()
         lblSliderName->setText(i18n("HSV Saturation"));
         lblScaling->setText(i18n("HSV Value"));
         break;
+    case CPE_HSV_SATURATION:
+        enableSliderScaling(false);
+        enableSliderColor(true);
+        sliderColor->setRange(0, 255);
+        sliderColor->setValue(200);
+        lblSliderName->setText(i18n("HSV Value"));
+        break;
     default:
         enableSliderScaling(false);
         enableSliderColor(false);
index f4eeebdc1891083d232160ddaada02feac344c7c..36816c247cd205ce38b027c0258e97ba25c0740c 100644 (file)
@@ -28,7 +28,7 @@ public:
     ColorPlaneExport(QWidget *parent = 0);
     ~ColorPlaneExport();
 
-    enum COLOR_EXPORT_MODE { CPE_YUV, CPE_YUV_Y, CPE_YUV_MOD, CPE_RGB_CURVE, CPE_YPbPr, CPE_HSV_HUESHIFT };
+    enum COLOR_EXPORT_MODE { CPE_YUV, CPE_YUV_Y, CPE_YUV_MOD, CPE_RGB_CURVE, CPE_YPbPr, CPE_HSV_HUESHIFT, CPE_HSV_SATURATION };
 
 private:
     ColorTools *m_colorTools;
index d42d12b3e1cda8a53caa13645beb7d025b249cf5..a1df69ed208a6214d7f9e60358d3da8edf0e07e5 100644 (file)
@@ -268,8 +268,8 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint
     float hue, huediff;
     int newhue;
     for (int x = 0; x < size.width(); x++) {
+        hue = x/(size.width() - 1.0) * 359;
         for (int y = 0; y < size.height(); y++) {
-            hue = x/(size.width() - 1.0) * 359;
             huediff = (1.0f - y/(size.height() - 1.0)) * hueValues + MIN;
 //            qDebug() << "hue: " << hue << ", huediff: " << huediff;
 
@@ -285,6 +285,33 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint
 
 }
 
+QImage ColorTools::hsvSaturationPlane(const QSize &size, const uint &V, const int &MIN, const int &MAX)
+{
+    Q_ASSERT(size.width() > 0);
+    Q_ASSERT(size.height() > 0);
+    Q_ASSERT(MAX > MIN);
+    Q_ASSERT(MIN >= 0);
+
+    QImage plane(size, QImage::Format_ARGB32);
+
+    QColor col(0, 0, 0);
+
+    float hue, sat;
+
+    for (int x = 0; x < size.width(); x++) {
+        hue = 359 * x / (size.width()-1.0);
+        for (int y = 0; y < size.height(); y++) {
+            sat = (1 - y/(size.height()-1.0)) * (MAX-MIN) + MIN;
+
+            col.setHsv(hue, sat, V);
+
+            plane.setPixel(x, y, col.rgba());
+        }
+    }
+
+    return plane;
+}
+
 
 
 
index af79f7fc656308a1571bb53f780cc6acc4d4f4f9..f1e29bd6880b838d18e0a28aca98b42ee7c3029b 100644 (file)
@@ -64,11 +64,18 @@ public:
     /**
      @brief Draws a HSV plane with Hue on the x axis and hue difference on the y axis.
      This is for the Bézier Curves widget which allows to change the hue (y) of a certain hue.
+     MIN/MAX give the minimum/maximum hue difference, e.g. -128,+128.
      For the value ranges see:
      http://doc.qt.nokia.com/latest/qcolor.html#the-hsv-color-model
      */
     static QImage hsvHueShiftPlane(const QSize &size, const uint &S, const uint &V, const int &MIN, const int &MAX);
 
+    /**
+      Basic HSV saturation plane.
+      MIN/MAX give the minimum/maximum saturation, usually 0..255.
+      */
+    static QImage hsvSaturationPlane(const QSize &size, const uint &V, const int &MIN, const int &MAX);
+
 signals:
     void signalYuvWheelCalculationFinished();
 };