14#include <klocalizedstring.h>
25#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< _channel_type_, float>::scaleToA( v )
26#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, _channel_type_>::scaleToA( v )
29template<
typename _channel_type_,
typename traits>
38void transform(
const quint8 *srcU8, quint8 *dstU8, qint32 nPixels)
const override
43 float value_red, value_green, value_blue, hue, saturation, lightness;
50 RGBToHSL(red, green, blue, &hue, &saturation, &lightness);
59 RGBToHSL(value_red, value_green, value_blue, &h2, &
s2, &l2);
60 HSLToRGB(h2,
s2, lightness, &value_red, &value_green, &value_blue);
65 dst->alpha = src->alpha;
77 list <<
"cyan_red_midtones" <<
"magenta_green_midtones" <<
"yellow_blue_midtones"
78 <<
"cyan_red_shadows" <<
"magenta_green_shadows" <<
"yellow_blue_shadows"
79 <<
"cyan_red_highlights" <<
"magenta_green_highlights" <<
"yellow_blue_highlights" <<
"preserve_luminosity";
85 if (name ==
"cyan_red_midtones")
87 else if(name ==
"magenta_green_midtones")
89 else if(name ==
"yellow_blue_midtones")
91 else if (name ==
"cyan_red_shadows")
93 else if(name ==
"magenta_green_shadows")
95 else if(name ==
"yellow_blue_shadows")
97 else if (name ==
"cyan_red_highlights")
99 else if(name ==
"magenta_green_highlights")
101 else if(name ==
"yellow_blue_highlights")
103 else if(name ==
"preserve_luminosity")
180 dbgKrita <<
"Unsupported color space " << colorSpace->
id() <<
" in KisColorBalanceAdjustment::createTransformation";
196 dbgKrita <<
"Unsupported color space " << colorSpace->
id() <<
" in KisColorBalanceAdjustment::createTransformation";
209 static const float a = 0.25, b = 0.333, scale = 0.7;
211 shadows *=
CLAMP ((lightness - b) / -a + 0.5, 0, 1) * scale;
212 midtones *=
CLAMP ((lightness - b) / a + 0.5, 0, 1) *
CLAMP ((lightness + b - 1) / -a + 0.5, 0, 1) * scale;
213 highlights *=
CLAMP ((lightness + b - 1) / a + 0.5, 0, 1) * scale;
float value(const T *src, size_t ch)
void RGBToHSL(float r, float g, float b, float *h, float *s, float *l)
void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b)
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
KoColorTransformation * createTransformation(const KoColorSpace *colorSpace, QHash< QString, QVariant > parameters) const override
KisColorBalanceAdjustmentFactory()
QList< QPair< KoID, KoID > > supportedModels() const override
QList< QString > parameters() const override
double m_magenta_midtones
void setParameter(int id, const QVariant ¶meter) override
double m_yellow_highlights
KisColorBalanceAdjustment()
void transform(const quint8 *srcU8, quint8 *dstU8, qint32 nPixels) const override
int parameterId(const QString &name) const override
double m_magenta_highlights
bool m_preserve_luminosity
float colorBalanceTransform(float value, float lightness, float shadows, float midtones, float highlights)
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
#define SCALE_FROM_FLOAT(v)
#define SCALE_TO_FLOAT(v)