cbColorspace->addItem(i18n("YCbCr CbCr plane"), QVariant(ColorPlaneExport::CPE_YPbPr));
cbColorspace->addItem(i18n("RGB plane, one component varying"), QVariant(ColorPlaneExport::CPE_RGB_CURVE));
cbColorspace->addItem(i18n("HSV Hue Shift"), QVariant(ColorPlaneExport::CPE_HSV_HUESHIFT));
+ cbColorspace->addItem(i18n("HSV Saturation"), QVariant(ColorPlaneExport::CPE_HSV_SATURATION));
sliderColor->setSliderPosition(128);
case CPE_HSV_HUESHIFT:
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);
+ break;
+ default:
+ Q_ASSERT(false);
}
img.save(kurlrequester->text());
}
lblSliderName->setText(i18n("HSV Saturation"));
lblScaling->setText(i18n("HSV Value"));
break;
+ case CPE_HSV_SATURATION:
+ enableSliderScaling(false);
+ enableSliderColor(true);
+ sliderColor->setRange(0, 255);
+ sliderColor->setValue(200);
+ lblSliderName->setText(i18n("HSV Value"));
+ break;
default:
enableSliderScaling(false);
enableSliderColor(false);
ColorPlaneExport(QWidget *parent = 0);
~ColorPlaneExport();
- enum COLOR_EXPORT_MODE { CPE_YUV, CPE_YUV_Y, CPE_YUV_MOD, CPE_RGB_CURVE, CPE_YPbPr, CPE_HSV_HUESHIFT };
+ enum COLOR_EXPORT_MODE { CPE_YUV, CPE_YUV_Y, CPE_YUV_MOD, CPE_RGB_CURVE, CPE_YPbPr, CPE_HSV_HUESHIFT, CPE_HSV_SATURATION };
private:
ColorTools *m_colorTools;
float hue, huediff;
int newhue;
for (int x = 0; x < size.width(); x++) {
+ hue = x/(size.width() - 1.0) * 359;
for (int y = 0; y < size.height(); y++) {
- hue = x/(size.width() - 1.0) * 359;
huediff = (1.0f - y/(size.height() - 1.0)) * hueValues + MIN;
// qDebug() << "hue: " << hue << ", huediff: " << huediff;
}
+QImage ColorTools::hsvSaturationPlane(const QSize &size, const uint &V, const int &MIN, const int &MAX)
+{
+ Q_ASSERT(size.width() > 0);
+ Q_ASSERT(size.height() > 0);
+ Q_ASSERT(MAX > MIN);
+ Q_ASSERT(MIN >= 0);
+
+ QImage plane(size, QImage::Format_ARGB32);
+
+ QColor col(0, 0, 0);
+
+ float hue, sat;
+
+ for (int x = 0; x < size.width(); x++) {
+ hue = 359 * x / (size.width()-1.0);
+ for (int y = 0; y < size.height(); y++) {
+ sat = (1 - y/(size.height()-1.0)) * (MAX-MIN) + MIN;
+
+ col.setHsv(hue, sat, V);
+
+ plane.setPixel(x, y, col.rgba());
+ }
+ }
+
+ return plane;
+}
+
/**
@brief Draws a HSV plane with Hue on the x axis and hue difference on the y axis.
This is for the Bézier Curves widget which allows to change the hue (y) of a certain hue.
+ MIN/MAX give the minimum/maximum hue difference, e.g. -128,+128.
For the value ranges see:
http://doc.qt.nokia.com/latest/qcolor.html#the-hsv-color-model
*/
static QImage hsvHueShiftPlane(const QSize &size, const uint &S, const uint &V, const int &MIN, const int &MAX);
+ /**
+ Basic HSV saturation plane.
+ 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);
+
signals:
void signalYuvWheelCalculationFinished();
};