svn path=/trunk/kdenlive/; revision=5489
QSize size(QVariant(tResX->text()).toInt(), QVariant(tResY->text()).toInt());
switch (cbColorspace->itemData(cbColorspace->currentIndex()).toInt()) {
case CPE_YUV:
QSize size(QVariant(tResX->text()).toInt(), QVariant(tResY->text()).toInt());
switch (cbColorspace->itemData(cbColorspace->currentIndex()).toInt()) {
case CPE_YUV:
img = m_colorTools->hsvHueShiftPlane(size, sliderColor->value(), sliderScaling->value(), -180, 180);
break;
case CPE_HSV_SATURATION:
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);
+ col.setHsv(0, 0, sliderColor->value());
+ img = m_colorTools->hsvCurvePlane(size, col, ColorTools::COM_H, ColorTools::COM_S);
break;
default:
Q_ASSERT(false);
break;
default:
Q_ASSERT(false);
-QImage ColorTools::hsvSaturationPlane(const QSize &size, const uint &V, const int &MIN, const int &MAX)
+QImage ColorTools::hsvCurvePlane(const QSize &size, const QColor &baseColor, const ComponentsHSV &xVariant, const ComponentsHSV &yVariant)
{
Q_ASSERT(size.width() > 0);
Q_ASSERT(size.height() > 0);
{
Q_ASSERT(size.width() > 0);
Q_ASSERT(size.height() > 0);
- Q_ASSERT(MAX > MIN);
- Q_ASSERT(MIN >= 0);
+
+ int xMax, yMax;
+
+ switch(xVariant) {
+ case COM_H:
+ xMax = 360;
+ break;
+ case COM_S:
+ case COM_V:
+ xMax = 256;
+ break;
+ }
+
+ switch (yVariant) {
+ case COM_H:
+ yMax = 360;
+ break;
+ case COM_S:
+ case COM_V:
+ yMax = 256;
+ break;
+ }
+
QImage plane(size, QImage::Format_ARGB32);
QColor col(0, 0, 0);
QImage plane(size, QImage::Format_ARGB32);
QColor col(0, 0, 0);
+ float hue, sat, val;
+ hue = baseColor.hueF();
+ sat = baseColor.saturationF();
+ val = baseColor.valueF();
for (int x = 0; x < size.width(); x++) {
for (int x = 0; x < size.width(); x++) {
- hue = 359 * x / (size.width()-1.0);
+ switch (xVariant) {
+ case COM_H:
+ hue = x / (size.width()-1.0);
+ break;
+ case COM_S:
+ sat = x / (size.width()-1.0);
+ break;
+ case COM_V:
+ val = x / (size.width()-1.0);
+ break;
+ }
for (int y = 0; y < size.height(); y++) {
for (int y = 0; y < size.height(); y++) {
- sat = (1 - y/(size.height()-1.0)) * (MAX-MIN) + MIN;
+ switch (yVariant) {
+ case COM_H:
+ hue = 1.0 - y / (size.height()-1.0);
+ break;
+ case COM_S:
+ sat = 1.0 - y / (size.height()-1.0);
+ break;
+ case COM_V:
+ val = 1.0 - y / (size.height()-1.0);
+ break;
+ }
- col.setHsv(hue, sat, V);
+ col.setHsvF(hue, sat, val);
plane.setPixel(x, y, col.rgba());
}
}
return plane;
plane.setPixel(x, y, col.rgba());
}
}
return plane;
enum ColorsRGB { COL_R, COL_G, COL_B, COL_A, COL_Luma, COL_RGB };
enum ColorsRGB { COL_R, COL_G, COL_B, COL_A, COL_Luma, COL_RGB };
+ enum ComponentsHSV { COM_H, COM_S, COM_V };
+
/**
@brief Draws a UV plane with given Y value.
scaling defines how far to zoom in (or out). Lower value = zoom in.
/**
@brief Draws a UV plane with given Y value.
scaling defines how far to zoom in (or out). Lower value = zoom in.
static QImage hsvHueShiftPlane(const QSize &size, const uint &S, const uint &V, const int &MIN, const int &MAX);
/**
static QImage hsvHueShiftPlane(const QSize &size, const uint &S, const uint &V, const int &MIN, const int &MAX);
/**
- Basic HSV saturation plane.
+ Basic HSV plane with two components varying on the x and y axis.
+ If both components are the same, then the y axis will be considered.
MIN/MAX give the minimum/maximum saturation, usually 0..255.
*/
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);
+ static QImage hsvCurvePlane(const QSize &size, const QColor &baseColor, const ComponentsHSV &xVariant, const ComponentsHSV &yVariant);
signals:
void signalYuvWheelCalculationFinished();
signals:
void signalYuvWheelCalculationFinished();