From 25bfb2d2fcfed8f74eec1333cfe8304314de8418 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 12 Jun 2012 17:21:02 +0200 Subject: [PATCH] Color values in MLT should always contain alpha (0xRRGGBBAA): http://kdenlive.org/mantis/view.php?id=2644 --- effects/chroma.xml | 2 +- effects/chroma_hold.xml | 2 +- effects/frei0r_balanc0r.xml | 4 ++-- effects/frei0r_colordistance.xml | 2 +- effects/frei0r_keyspillm0pup.xml | 4 ++-- effects/frei0r_select0r.xml | 4 ++-- effects/frei0r_three_point_balance.xml | 6 +++--- effects/frei0r_timeout.xml | 2 +- effects/frei0r_tint0r.xml | 4 ++-- effects/pan_zoom.xml | 2 +- effects/rotation.xml | 2 +- effects/rotation_keyframable.xml | 2 +- src/choosecolorwidget.cpp | 17 +++++++++-------- src/choosecolorwidget.h | 8 +++----- src/effectstack/parametercontainer.cpp | 3 +-- 15 files changed, 31 insertions(+), 33 deletions(-) diff --git a/effects/chroma.xml b/effects/chroma.xml index 91478d2c..128a4cb0 100644 --- a/effects/chroma.xml +++ b/effects/chroma.xml @@ -3,7 +3,7 @@ Blue Screen Make selected color transparent Charles Yates - + Color key diff --git a/effects/chroma_hold.xml b/effects/chroma_hold.xml index b31a5890..ce6feffb 100644 --- a/effects/chroma_hold.xml +++ b/effects/chroma_hold.xml @@ -3,7 +3,7 @@ Chroma Hold Make image greyscale except for chosen color Charles Yates - + Color key diff --git a/effects/frei0r_balanc0r.xml b/effects/frei0r_balanc0r.xml index 6a532160..f7c55dc9 100644 --- a/effects/frei0r_balanc0r.xml +++ b/effects/frei0r_balanc0r.xml @@ -4,7 +4,7 @@ White Balance Adjust the white balance / color temperature Dan Dennedy - + Neutral Color @@ -15,7 +15,7 @@ White Balance Adjust the white balance / color temperature Dan Dennedy - + Neutral Color diff --git a/effects/frei0r_colordistance.xml b/effects/frei0r_colordistance.xml index 9f1836a8..d407589b 100644 --- a/effects/frei0r_colordistance.xml +++ b/effects/frei0r_colordistance.xml @@ -3,7 +3,7 @@ Color Distance Calculates the distance between the selected color and the current pixel and uses that value as new pixel value Richard Spindler - + Source Color diff --git a/effects/frei0r_keyspillm0pup.xml b/effects/frei0r_keyspillm0pup.xml index f6eb1b68..3ca32b30 100644 --- a/effects/frei0r_keyspillm0pup.xml +++ b/effects/frei0r_keyspillm0pup.xml @@ -4,11 +4,11 @@ Reduces the visibility of key color spill in chroma keying Marko Cebokli - + Key color - + Target color diff --git a/effects/frei0r_select0r.xml b/effects/frei0r_select0r.xml index 021f21ce..dba7c10a 100644 --- a/effects/frei0r_select0r.xml +++ b/effects/frei0r_select0r.xml @@ -5,7 +5,7 @@ Color based alpha selection Marko Cebokli - + Color to select @@ -52,7 +52,7 @@ Color based alpha selection Marko Cebokli - + Color to select diff --git a/effects/frei0r_three_point_balance.xml b/effects/frei0r_three_point_balance.xml index becee081..03b042cc 100644 --- a/effects/frei0r_three_point_balance.xml +++ b/effects/frei0r_three_point_balance.xml @@ -3,13 +3,13 @@ 3 point balance Balances colors along with 3 points Maksim Golovkin - + Black color - + Gray color - + White color diff --git a/effects/frei0r_timeout.xml b/effects/frei0r_timeout.xml index 27edfcfd..3b168337 100644 --- a/effects/frei0r_timeout.xml +++ b/effects/frei0r_timeout.xml @@ -3,7 +3,7 @@ Timeout indicator Simon A. Eugster (Granjow) - + Indicator color diff --git a/effects/frei0r_tint0r.xml b/effects/frei0r_tint0r.xml index d79cd5e8..102a3cc7 100644 --- a/effects/frei0r_tint0r.xml +++ b/effects/frei0r_tint0r.xml @@ -3,10 +3,10 @@ Tint Maps source image luminance between two colors specified Maksim Golovkin - + Map black to - + Map white to diff --git a/effects/pan_zoom.xml b/effects/pan_zoom.xml index 89ccf767..3f5544a0 100644 --- a/effects/pan_zoom.xml +++ b/effects/pan_zoom.xml @@ -9,7 +9,7 @@ Distort - + Background Color diff --git a/effects/rotation.xml b/effects/rotation.xml index 0130102b..1a8a8ec2 100644 --- a/effects/rotation.xml +++ b/effects/rotation.xml @@ -36,7 +36,7 @@ Pan and Zoom - + Background Color diff --git a/effects/rotation_keyframable.xml b/effects/rotation_keyframable.xml index d78b14f9..e4a88395 100644 --- a/effects/rotation_keyframable.xml +++ b/effects/rotation_keyframable.xml @@ -18,7 +18,7 @@ Offset Y - + Background Color diff --git a/src/choosecolorwidget.cpp b/src/choosecolorwidget.cpp index 26c18743..8543d79e 100644 --- a/src/choosecolorwidget.cpp +++ b/src/choosecolorwidget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include static QColor stringToColor(QString strColor) { @@ -81,10 +82,14 @@ static QString colorToString(QColor color, bool alpha) { stream << color.alpha(); } + else { + // MLT always wants 0xRRGGBBAA format + stream << "ff"; + } return colorStr; } -ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *parent) : +ChooseColorWidget::ChooseColorWidget(QString text, QString color, bool alphaEnabled, QWidget *parent) : QWidget(parent) { QHBoxLayout *layout = new QHBoxLayout(this); @@ -99,6 +104,9 @@ ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *paren rightSideLayout->setSpacing(0); m_button = new KColorButton(stringToColor(color), rightSide); +#if KDE_IS_VERSION(4,5,0) + if (alphaEnabled) m_button->setAlphaChannelEnabled(alphaEnabled); +#endif // m_button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); ColorPickerWidget *picker = new ColorPickerWidget(rightSide); @@ -121,13 +129,6 @@ QString ChooseColorWidget::getColor() return colorToString(m_button->color(), alphaChannel); } -void ChooseColorWidget::setAlphaChannelEnabled(bool enabled) -{ -#if KDE_IS_VERSION(4,5,0) - m_button->setAlphaChannelEnabled(enabled); -#endif -} - void ChooseColorWidget::setColor(QColor color) { m_button->setColor(color); diff --git a/src/choosecolorwidget.h b/src/choosecolorwidget.h index 4c2c2ff2..3f417948 100644 --- a/src/choosecolorwidget.h +++ b/src/choosecolorwidget.h @@ -38,14 +38,12 @@ class ChooseColorWidget : public QWidget public: /** @brief Sets up the widget. * @param text (optional) What the color will be used for - * @param color (optional) initial color */ - ChooseColorWidget(QString text = QString(), QString color = "0xffffffff", QWidget* parent = 0); + * @param color (optional) initial color + * @param alphaEnabled (optional) Should transparent colors be enabled */ + ChooseColorWidget(QString text = QString(), QString color = "0xffffffff", bool alphaEnabled = false, QWidget* parent = 0); /** @brief Gets the choosen color. */ QString getColor(); - /** @brief Enable the use of alpha channel. - * @param enabled (required) whether alpha is enabled or disabled */ - void setAlphaChannelEnabled(bool enabled); private: KColorButton *m_button; diff --git a/src/effectstack/parametercontainer.cpp b/src/effectstack/parametercontainer.cpp index 0fd2da73..9e5ecbdc 100644 --- a/src/effectstack/parametercontainer.cpp +++ b/src/effectstack/parametercontainer.cpp @@ -269,8 +269,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size()); if (value.startsWith('#')) value = value.replace('#', "0x"); - ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent); - choosecolor->setAlphaChannelEnabled(true); + ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, pa.hasAttribute("alpha"), parent); m_vbox->addWidget(choosecolor); m_valueItems[paramName] = choosecolor; connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); -- 2.39.2