]> git.sesse.net Git - kdenlive/blobdiff - src/colortools.cpp
Fix compilation with Qt < 4.7
[kdenlive] / src / colortools.cpp
index 9f8b4806b247f7dbb3687effc41b688a9f738eaf..eeb659829a90c325a1f5df7d1d043e617b2a5249 100644 (file)
@@ -134,7 +134,7 @@ QImage ColorTools::yuvVerticalPlane(const QSize &size, const float &angle, const
 
 }
 
-QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling)
+QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling, const QRgb &background)
 {
     Q_ASSERT(scaling > 0 && scaling <= 1);
 
@@ -148,15 +148,19 @@ QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB
     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++) {
+            dy = (double)y/(h-1);
+            dx = (double)x/(w-1);
+
             if (1-scaling < 0.0001) {
-                dcol = (double)255*y/(h-1);
+                dcol = (double)255*dy;
             } else {
-                dcol = (double)255 * (y - (y-x)*(1-scaling))/(h-1);
+                dcol = (double)255 * (dy - (dy-dx)*(1-scaling));
             }
 
             if (color == ColorTools::COL_R) {
@@ -165,6 +169,8 @@ QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB
                 plane.setPixel(x, (h-y-1), qRgb(dval, dcol, dval));
             } else if (color == ColorTools::COL_B){
                 plane.setPixel(x, (h-y-1), qRgb(dval, dval, dcol));
+            } else if (color == ColorTools::COL_A) {
+                plane.setPixel(x, (h-y-1), qRgb(dcol / 255. * qRed(background), dcol / 255. * qGreen(background), dcol / 255. * qBlue(background)));
             } else {
                 plane.setPixel(x, (h-y-1), qRgb(dcol, dcol, dcol));
             }