Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Office
Calligra
Commits
12737c6b
Commit
12737c6b
authored
Dec 01, 2012
by
Halla Rempt
Browse files
Extend the HSV filter to include HSL and make that default
BUG:310947
parent
fc4b0051
Changes
7
Hide whitespace changes
Inline
Side-by-side
krita/image/brushengine/kis_paintop_preset.cpp
View file @
12737c6b
...
...
@@ -118,6 +118,7 @@ bool KisPaintOpPreset::load()
{
dbgImage
<<
"Load preset "
<<
filename
();
setValid
(
false
);
if
(
filename
().
isEmpty
())
{
return
false
;
}
...
...
krita/plugins/colorspaces/extensions/CMakeLists.txt
View file @
12737c6b
set
(
extensions_plugin_PART_SRCS extensions_plugin.cc kis_hsv_adjustment.cc
)
set
(
extensions_plugin_PART_SRCS
extensions_plugin.cc
kis_hsv_adjustment.cc
)
kde4_add_plugin
(
krita_colorspaces_extensions
${
extensions_plugin_PART_SRCS
}
)
...
...
krita/plugins/colorspaces/extensions/kis_hsv_adjustment.cc
View file @
12737c6b
...
...
@@ -75,28 +75,60 @@ void clamp<float>(float* r, float* g, float* b)
Q_UNUSED
(
b
);
}
template
<
typename
_channel_type_
>
class
KisHSVAdjustment
:
public
KoColorTransformation
{
typedef
KoBgrTraits
<
_channel_type_
>
RGBTrait
;
typedef
typename
RGBTrait
::
Pixel
RGBPixel
;
public:
KisHSVAdjustment
()
{
KisHSVAdjustment
()
{
}
public:
void
transform
(
const
quint8
*
srcU8
,
quint8
*
dstU8
,
qint32
nPixels
)
const
{
void
transform
(
const
quint8
*
srcU8
,
quint8
*
dstU8
,
qint32
nPixels
)
const
{
const
RGBPixel
*
src
=
reinterpret_cast
<
const
RGBPixel
*>
(
srcU8
);
RGBPixel
*
dst
=
reinterpret_cast
<
RGBPixel
*>
(
dstU8
);
float
h
,
s
,
v
,
r
,
g
,
b
;
while
(
nPixels
>
0
)
{
RGBToHSV
(
SCALE_TO_FLOAT
(
src
->
red
),
SCALE_TO_FLOAT
(
src
->
green
),
SCALE_TO_FLOAT
(
src
->
blue
),
&
h
,
&
s
,
&
v
);
h
+=
m_adj_h
;
if
(
h
>
360
)
h
-=
360
;
if
(
h
<
0
)
h
+=
360
;
s
+=
m_adj_s
;
v
+=
m_adj_v
;
HSVToRGB
(
h
,
s
,
v
,
&
r
,
&
g
,
&
b
);
if
(
m_type
==
0
)
{
RGBToHSV
(
SCALE_TO_FLOAT
(
src
->
red
),
SCALE_TO_FLOAT
(
src
->
green
),
SCALE_TO_FLOAT
(
src
->
blue
),
&
h
,
&
s
,
&
v
);
h
+=
m_adj_h
;
if
(
h
>
360
)
h
-=
360
;
if
(
h
<
0
)
h
+=
360
;
s
+=
m_adj_s
;
v
+=
m_adj_v
;
HSVToRGB
(
h
,
s
,
v
,
&
r
,
&
g
,
&
b
);
}
else
{
RGBToHSL
(
SCALE_TO_FLOAT
(
src
->
red
),
SCALE_TO_FLOAT
(
src
->
green
),
SCALE_TO_FLOAT
(
src
->
blue
),
&
h
,
&
s
,
&
v
);
h
+=
m_adj_h
;
if
(
h
<
0
)
h
+=
1.0
;
else
if
(
h
>
1.0
)
h
-=
1.0
;
s
*=
(
m_adj_s
+
1.0
);
if
(
s
<
0.0
)
s
=
0.0
;
if
(
s
>
1.0
)
s
=
1.0
;
if
(
m_adj_v
<
0
)
v
*=
(
m_adj_v
+
1.0
);
else
v
+=
(
m_adj_v
*
(
1.0
-
v
));
HSLToRGB
(
h
,
s
,
v
,
&
r
,
&
g
,
&
b
);
}
clamp
<
_channel_type_
>
(
&
r
,
&
g
,
&
b
);
dst
->
red
=
SCALE_FROM_FLOAT
(
r
);
dst
->
green
=
SCALE_FROM_FLOAT
(
g
);
...
...
@@ -108,10 +140,11 @@ public:
++
dst
;
}
}
virtual
QList
<
QString
>
parameters
()
const
{
QList
<
QString
>
list
;
list
<<
"h"
<<
"s"
<<
"v"
;
list
<<
"h"
<<
"s"
<<
"v"
<<
"type"
;
return
list
;
}
...
...
@@ -123,6 +156,8 @@ public:
return
1
;
}
else
if
(
name
==
"v"
)
{
return
2
;
}
else
if
(
name
==
"type"
)
{
return
3
;
}
return
-
1
;
}
...
...
@@ -133,7 +168,8 @@ public:
* (s)aturation in range <-1.0, 1.0> ( for user, show -100, 100)
* (v)alue in range <-1.0, 1.0> (for user, show -100, 100)
*/
virtual
void
setParameter
(
int
id
,
const
QVariant
&
parameter
)
{
virtual
void
setParameter
(
int
id
,
const
QVariant
&
parameter
)
{
switch
(
id
)
{
case
0
:
...
...
@@ -145,19 +181,24 @@ public:
case
2
:
m_adj_v
=
parameter
.
toDouble
();
break
;
case
3
:
m_type
=
parameter
.
toDouble
();
break
;
default:
qFatal
(
"Unknown parameter id %i"
,
id
);
}
}
private:
double
m_adj_h
,
m_adj_s
,
m_adj_v
;
int
m_type
;
};
KisHSVAdjustmentFactory
::
KisHSVAdjustmentFactory
()
:
KoColorTransformationFactory
(
"hsv_adjustment"
,
i18n
(
"HSV Adjustment"
))
KisHSVAdjustmentFactory
::
KisHSVAdjustmentFactory
()
:
KoColorTransformationFactory
(
"hsv_adjustment"
,
i18n
(
"HSV Adjustment"
))
{
}
QList
<
QPair
<
KoID
,
KoID
>
>
KisHSVAdjustmentFactory
::
supportedModels
()
const
...
...
krita/plugins/filters/colorsfilters/kis_hsv_adjustment_filter.cpp
View file @
12737c6b
...
...
@@ -48,6 +48,7 @@ KoColorTransformation* KisHSVAdjustmentFilter::createTransformation(const KoColo
params
[
"h"
]
=
config
->
getInt
(
"h"
,
0
)
/
180.0
;
params
[
"s"
]
=
config
->
getInt
(
"s"
,
0
)
*
0.01
;
params
[
"v"
]
=
config
->
getInt
(
"v"
,
0
)
*
0.01
;
params
[
"type"
]
=
config
->
getInt
(
"type"
,
1
);
}
return
cs
->
createColorTransformation
(
"hsv_adjustment"
,
params
);
}
...
...
@@ -58,6 +59,7 @@ KisFilterConfiguration* KisHSVAdjustmentFilter::factoryConfiguration(const KisPa
config
->
setProperty
(
"h"
,
0
);
config
->
setProperty
(
"s"
,
0
);
config
->
setProperty
(
"v"
,
0
);
config
->
setProperty
(
"type"
,
1
);
return
config
;
}
...
...
@@ -65,6 +67,8 @@ KisHSVConfigWidget::KisHSVConfigWidget(QWidget * parent, Qt::WFlags f) : KisConf
{
m_page
=
new
Ui_WdgHSVAdjustment
();
m_page
->
setupUi
(
this
);
connect
(
m_page
->
cmbType
,
SIGNAL
(
activated
(
int
)),
SLOT
(
switchType
(
int
)));
connect
(
m_page
->
hue
,
SIGNAL
(
valueChanged
(
int
)),
SIGNAL
(
sigConfigurationItemChanged
()));
connect
(
m_page
->
value
,
SIGNAL
(
valueChanged
(
int
)),
SIGNAL
(
sigConfigurationItemChanged
()));
connect
(
m_page
->
saturation
,
SIGNAL
(
valueChanged
(
int
)),
SIGNAL
(
sigConfigurationItemChanged
()));
...
...
@@ -81,12 +85,30 @@ KisPropertiesConfiguration * KisHSVConfigWidget::configuration() const
c
->
setProperty
(
"h"
,
m_page
->
hue
->
value
());
c
->
setProperty
(
"s"
,
m_page
->
saturation
->
value
());
c
->
setProperty
(
"v"
,
m_page
->
value
->
value
());
c
->
setProperty
(
"type"
,
m_page
->
cmbType
->
currentIndex
());
return
c
;
}
void
KisHSVConfigWidget
::
setConfiguration
(
const
KisPropertiesConfiguration
*
config
)
{
m_page
->
cmbType
->
setCurrentIndex
(
config
->
getInt
(
"type"
,
1
));
m_page
->
hue
->
setValue
(
config
->
getInt
(
"h"
,
0
));
m_page
->
saturation
->
setValue
(
config
->
getInt
(
"s"
,
0
));
m_page
->
value
->
setValue
(
config
->
getInt
(
"v"
,
0
));
switchType
(
m_page
->
cmbType
->
currentIndex
());
}
void
KisHSVConfigWidget
::
switchType
(
int
index
)
{
emit
sigConfigurationItemChanged
();
switch
(
index
)
{
case
0
:
m_page
->
label_3
->
setText
(
i18n
(
"Value"
));
return
;
case
1
:
default:
m_page
->
label_3
->
setText
(
i18n
(
"Lightness"
));
}
}
krita/plugins/filters/colorsfilters/kis_hsv_adjustment_filter.h
View file @
12737c6b
...
...
@@ -50,8 +50,9 @@ public:
virtual
KoColorTransformation
*
createTransformation
(
const
KoColorSpace
*
cs
,
const
KisFilterConfiguration
*
config
)
const
;
static
inline
KoID
id
()
{
return
KoID
(
"hsvadjustment"
,
i18n
(
"HSV Adjustment"
));
return
KoID
(
"hsvadjustment"
,
i18n
(
"HSV
/HSL
Adjustment"
));
}
virtual
KisFilterConfiguration
*
factoryConfiguration
(
const
KisPaintDeviceSP
)
const
;
};
...
...
@@ -60,6 +61,8 @@ public:
class
KisHSVConfigWidget
:
public
KisConfigWidget
{
Q_OBJECT
public:
KisHSVConfigWidget
(
QWidget
*
parent
,
Qt
::
WFlags
f
=
0
);
virtual
~
KisHSVConfigWidget
();
...
...
@@ -67,6 +70,10 @@ public:
virtual
KisPropertiesConfiguration
*
configuration
()
const
;
virtual
void
setConfiguration
(
const
KisPropertiesConfiguration
*
config
);
Ui_WdgHSVAdjustment
*
m_page
;
private
slots
:
void
switchType
(
int
index
);
};
#endif
krita/plugins/filters/colorsfilters/wdg_hsv_adjustment.ui
View file @
12737c6b
...
...
@@ -11,7 +11,7 @@
</rect>
</property>
<layout
class=
"QGridLayout"
>
<item
row=
"
0
"
column=
"0"
>
<item
row=
"
1
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
...
...
@@ -27,7 +27,7 @@
</property>
</widget>
</item>
<item
row=
"
0
"
column=
"1"
>
<item
row=
"
1
"
column=
"1"
>
<widget
class=
"KIntNumInput"
name=
"hue"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"MinimumExpanding"
vsizetype=
"Fixed"
>
...
...
@@ -46,7 +46,7 @@
</property>
</widget>
</item>
<item
row=
"
1
"
column=
"0"
>
<item
row=
"
2
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
...
...
@@ -65,7 +65,7 @@
</property>
</widget>
</item>
<item
row=
"
1
"
column=
"1"
>
<item
row=
"
2
"
column=
"1"
>
<widget
class=
"KIntNumInput"
name=
"saturation"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"MinimumExpanding"
vsizetype=
"Fixed"
>
...
...
@@ -84,7 +84,7 @@
</property>
</widget>
</item>
<item
row=
"
2
"
column=
"1"
>
<item
row=
"
3
"
column=
"1"
>
<widget
class=
"KIntNumInput"
name=
"value"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"MinimumExpanding"
vsizetype=
"Fixed"
>
...
...
@@ -103,7 +103,7 @@
</property>
</widget>
</item>
<item
row=
"
3
"
column=
"0"
colspan=
"2"
>
<item
row=
"
4
"
column=
"0"
colspan=
"2"
>
<spacer>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -116,7 +116,7 @@
</property>
</spacer>
</item>
<item
row=
"
2
"
column=
"0"
>
<item
row=
"
3
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Value:
</string>
...
...
@@ -126,6 +126,33 @@
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"cmbType"
>
<property
name=
"currentIndex"
>
<number>
1
</number>
</property>
<item>
<property
name=
"text"
>
<string>
Hue/Saturation/Value
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Hue/Saturation/Lightness
</string>
</property>
</item>
</widget>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"lblType"
>
<property
name=
"text"
>
<string>
Type:
</string>
</property>
<property
name=
"buddy"
>
<cstring>
cmbType
</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
...
...
libs/pigment/KoColorTransformation.cpp
View file @
12737c6b
...
...
@@ -18,6 +18,7 @@
*/
#include
"KoColorTransformation.h"
#include
<QDebug>
KoColorTransformation
::~
KoColorTransformation
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment