X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcolorplaneexport.cpp;h=b4daaa54ccbc13557a15a6fe204481f521e86a80;hb=6c62a4d8f799379bfb7a11d25521cf829248587c;hp=5f55e52d390bcb4cd4ba7f22d359489c9f7edc09;hpb=78e7bc0f7be6be004acfc44d92367a302b20e46f;p=kdenlive diff --git a/src/colorplaneexport.cpp b/src/colorplaneexport.cpp index 5f55e52d..b4daaa54 100644 --- a/src/colorplaneexport.cpp +++ b/src/colorplaneexport.cpp @@ -9,9 +9,13 @@ ***************************************************************************/ #include "colorplaneexport.h" -#include #include +//#define DEBUG_CTE +#ifdef DEBUG_CTE +#include +#endif + const QString EXTENSION_PNG = ".png"; const int SCALE_RANGE = 80; @@ -30,6 +34,8 @@ ColorPlaneExport::ColorPlaneExport(QWidget *parent) : cbColorspace->addItem(i18n("Modified YUV (Chroma)"), QVariant(ColorPlaneExport::CPE_YUV_MOD)); 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); @@ -63,21 +69,21 @@ ColorPlaneExport::~ColorPlaneExport() ///// Helper functions ///// -void ColorPlaneExport::enableSliderScaling(const bool &enable) +void ColorPlaneExport::enableSliderScaling(bool enable) { sliderScaling->setEnabled(enable); lblScaling->setEnabled(enable); lblScaleNr->setEnabled(enable); } -void ColorPlaneExport::enableSliderColor(const bool &enable) +void ColorPlaneExport::enableSliderColor(bool enable) { sliderColor->setEnabled(enable); lblSliderName->setEnabled(enable); lblColNr->setEnabled(enable); } -void ColorPlaneExport::enableCbVariant(const bool &enable) +void ColorPlaneExport::enableCbVariant(bool enable) { cbVariant->setEnabled(enable); lblVariant->setEnabled(enable); @@ -100,6 +106,9 @@ void ColorPlaneExport::slotUpdateDisplays() case CPE_RGB_CURVE: lblScaleNr->setText(QChar(0xb1) + QString::number(sliderScaling->value(), 'f', 2));; break; + case CPE_HSV_HUESHIFT: + lblScaleNr->setText(QString::number(sliderScaling->value())); + break; default: lblScaleNr->setText("0..." + QString::number(m_scaling, 'f', 2)); break; @@ -114,7 +123,7 @@ void ColorPlaneExport::slotUpdateDisplays() break; } - lblSize->setText(i18n("%1 px", QVariant(tResX->text()).toInt()*QVariant(tResY->text()).toInt())); + lblSize->setText(i18n("%1 px", tResX->text().toInt()*tResY->text().toInt())); } void ColorPlaneExport::slotValidate() @@ -130,7 +139,9 @@ void ColorPlaneExport::slotValidate() } if (ok) { ok = kurlrequester->text().trimmed().length() > 0; +#ifdef DEBUG_CPE qDebug() << "File given: " << ok; +#endif } if (ok) { @@ -144,15 +155,20 @@ void ColorPlaneExport::slotValidate() void ColorPlaneExport::slotExportPlane() { +#ifdef DEBUG_CPE qDebug() << "Exporting plane now to " << kurlrequester->text(); +#endif QString lower = kurlrequester->text().toLower(); +#ifdef DEBUG_CPE qDebug() << "Lower: " << lower; +#endif if (!lower.endsWith(".png") && !lower.endsWith(".jpg") && !lower.endsWith(".tif") && !lower.endsWith(".tiff")) { if (KMessageBox::questionYesNo(this, i18n("File has no extension. Add extension (%1)?", EXTENSION_PNG)) == KMessageBox::Yes) { kurlrequester->setUrl(KUrl(kurlrequester->text() + ".png")); } } QImage img; + QColor col; QSize size(QVariant(tResX->text()).toInt(), QVariant(tResY->text()).toInt()); switch (cbColorspace->itemData(cbColorspace->currentIndex()).toInt()) { case CPE_YUV: @@ -171,13 +187,26 @@ void ColorPlaneExport::slotExportPlane() case CPE_YPbPr: img = m_colorTools->yPbPrColorWheel(size, sliderColor->value(), m_scaling, false); break; + case CPE_HSV_HUESHIFT: + img = m_colorTools->hsvHueShiftPlane(size, sliderColor->value(), sliderScaling->value(), -180, 180); + break; + case CPE_HSV_SATURATION: + col.setHsv(0, 0, sliderColor->value()); + img = m_colorTools->hsvCurvePlane(size, col, ColorTools::COM_H, ColorTools::COM_S); + break; + default: + Q_ASSERT(false); } img.save(kurlrequester->text()); } void ColorPlaneExport::slotColormodeChanged() { +#ifdef DEBUG_CPE qDebug() << "Color mode changed to " << cbColorspace->itemData(cbColorspace->currentIndex()).toInt(); +#endif + lblScaling->setText(i18n("Scaling")); + sliderScaling->setInvertedAppearance(true); switch (cbColorspace->itemData(cbColorspace->currentIndex()).toInt()) { case CPE_YUV: case CPE_YUV_MOD: @@ -191,7 +220,9 @@ void ColorPlaneExport::slotColormodeChanged() lblSliderName->setToolTip(i18n("The Y value describes the brightness of the colors.")); break; case CPE_YUV_Y: +#ifdef DEBUG_CPE qDebug() << "Changing slider range."; +#endif enableSliderScaling(true); enableSliderColor(true); enableCbVariant(false); @@ -212,6 +243,25 @@ void ColorPlaneExport::slotColormodeChanged() cbVariant->addItem(i18n("Blue"), QVariant(ColorTools::COL_B)); cbVariant->addItem(i18n("Luma"), QVariant(ColorTools::COL_Luma)); break; + case CPE_HSV_HUESHIFT: + enableSliderScaling(true); + enableSliderColor(true); + enableCbVariant(false); + sliderScaling->setRange(0,255); + sliderScaling->setValue(200); + sliderScaling->setInvertedAppearance(false); + sliderColor->setRange(0,255); + sliderColor->setValue(200); + 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); @@ -225,3 +275,5 @@ void ColorPlaneExport::slotColormodeChanged() this->update(); slotUpdateDisplays(); } + +#include "colorplaneexport.moc"