}
-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);
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) {
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));
}