]> git.sesse.net Git - kdenlive/blobdiff - src/colortools.cpp
Fix small display issue in render widget
[kdenlive] / src / colortools.cpp
index c0cd5b73464ebbac73b4e9cf3865a75e575c6e90..6e44a33473f9a5f02759aab215671e2c86debf3a 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!");
@@ -146,19 +148,29 @@ QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorsRGB &color)
     const int h = size.height();
 
     double dcol, dval;
+    double dx, dy;
 
     for (int x = 0; x < w; x++) {
         dval = (double)255*x/(w-1);
 
         for (int y = 0; y < h; y++) {
-            dcol = (double)255*y/(h-1);
+            dy = (double)y/(h-1);
+            dx = (double)x/(w-1);
+
+            if (1-scaling < 0.0001) {
+                dcol = (double)255*dy;
+            } else {
+                dcol = (double)255 * (dy - (dy-dx)*(1-scaling));
+            }
 
             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));
             }
 
         }