[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [krita/krita-testing-wolthera] libs/ui/widgets: Fix HSV mode
From: Wolthera van Hovell tot Westerflier <griffinvalley () gmail ! com>
Date: 2016-08-17 14:07:56
Message-ID: E1ba1Vc-0007DK-CH () code ! kde ! org
[Download RAW message or body]
Git commit d09605cbaefe1d65b92ba843ae75eefc7f76daa0 by Wolthera van Hovell tot \
Westerflier. Committed on 17/08/2016 at 14:07.
Pushed by woltherav into branch 'krita-testing-wolthera'.
Fix HSV mode
Turns out there was an 'undefined' value...
Ref T2438
M +20 -3 libs/ui/widgets/kis_visual_color_selector.cpp
http://commits.kde.org/krita/d09605cbaefe1d65b92ba843ae75eefc7f76daa0
diff --git a/libs/ui/widgets/kis_visual_color_selector.cpp \
b/libs/ui/widgets/kis_visual_color_selector.cpp index 245baf0..300c9b4 100644
--- a/libs/ui/widgets/kis_visual_color_selector.cpp
+++ b/libs/ui/widgets/kis_visual_color_selector.cpp
@@ -88,11 +88,11 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace \
*cs) } else if (m_d->currentCS->colorChannelCount() == 3) {
KisVisualRectangleSelectorShape *bar = new \
KisVisualRectangleSelectorShape(this,
\
KisVisualRectangleSelectorShape::onedimensional,
- \
KisVisualColorSelectorShape::HSL, + \
KisVisualColorSelectorShape::HSV,
\
cs, 0, 0,
\
m_d->displayRenderer);
KisVisualRectangleSelectorShape *block = new \
KisVisualRectangleSelectorShape(this, \
KisVisualRectangleSelectorShape::twodimensional,
- \
KisVisualColorSelectorShape::HSL, + \
KisVisualColorSelectorShape::HSV,
\
cs, 1, 2,
\
m_d->displayRenderer); bar->setMaximumWidth(width()*0.1);
@@ -346,14 +346,23 @@ KoColor \
KisVisualColorSelectorShape::convertShapeCoordinateToKoColor(QPointF \
coo
if (m_d->model != ColorModel::Channel && c.colorSpace()->colorModelId().id() == \
"RGBA") { if (c.colorSpace()->colorModelId().id() == "RGBA") {
if (m_d->model == ColorModel::HSV){
+ /*
+ * RGBToHSV has a undefined hue possibility. This means that hue \
will be -1. + * This can be annoying for dealing with a selector, but \
I understand it is being + * used for the KoColorSelector... For now \
implement a qMax here. + */
QVector <float> inbetween(3);
RGBToHSV(channelValues[2],channelValues[1], channelValues[0], \
&inbetween[0], &inbetween[1], &inbetween[2]); inbetween[m_d->channel1] = \
coordinates.x()*huedivider; if (m_d->dimension == Dimensions::twodimensional) {
inbetween[m_d->channel2] = coordinates.y()*huedivider2;
}
- HSVToRGB(inbetween[0], inbetween[1], inbetween[2], \
&channelValues[2], &channelValues[1], &channelValues[0]); + \
HSVToRGB(qMax(inbetween[0],(float)0.0), inbetween[1], inbetween[2], \
&channelValues[2], &channelValues[1], &channelValues[0]); } else if (m_d->model == \
ColorModel::HSL) { + /*
+ * HSLToRGB can give negative values on the grey. I fixed the \
fromNormalisedChannel function to clamp, + * but you might want to \
manually clamp for floating point values. + */
QVector <float> inbetween(3);
RGBToHSL(channelValues[2],channelValues[1], channelValues[0], \
&inbetween[0], &inbetween[1], &inbetween[2]); inbetween[m_d->channel1] = \
coordinates.x()*huedivider; @@ -362,6 +371,9 @@ KoColor \
KisVisualColorSelectorShape::convertShapeCoordinateToKoColor(QPointF coo }
HSLToRGB(inbetween[0], inbetween[1], \
inbetween[2],&channelValues[2],&channelValues[1], &channelValues[0]); } else if \
(m_d->model == ColorModel::HSI) { + /*
+ * HSI is a modified HSY function.
+ */
QVector <qreal> chan2 = convertvectorfloatToqreal(channelValues);
QVector <qreal> inbetween(3);
RGBToHSI(chan2[2],chan2[1], chan2[0], &inbetween[0], &inbetween[1], \
&inbetween[2]); @@ -372,6 +384,11 @@ KoColor \
KisVisualColorSelectorShape::convertShapeCoordinateToKoColor(QPointF \
coo
HSIToRGB(inbetween[0], inbetween[1], \
inbetween[2],&chan2[2],&chan2[1], &chan2[0]); channelValues = \
convertvectorqrealTofloat(chan2); } else /*if (m_d->model == ColorModel::HSY)*/ {
+ /*
+ * HSY is pretty slow to render due being a pretty over-the-top \
function. + * Might be worth investigating whether HCY can be used \
instead, but I have had + * some weird results with that.
+ */
QVector <qreal> luma= m_d->cs->lumaCoefficients();
QVector <qreal> chan2 = convertvectorfloatToqreal(channelValues);
QVector <qreal> inbetween(3);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic