X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcolortools.cpp;h=eeb659829a90c325a1f5df7d1d043e617b2a5249;hb=5feac3c2f6edfa8639d8e9b9aa5a82c21f3d1776;hp=9f8b4806b247f7dbb3687effc41b688a9f738eaf;hpb=78e7bc0f7be6be004acfc44d92367a302b20e46f;p=kdenlive diff --git a/src/colortools.cpp b/src/colortools.cpp index 9f8b4806..eeb65982 100644 --- a/src/colortools.cpp +++ b/src/colortools.cpp @@ -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)); }