21#include <kpluginfactory.h>
22#include <klocalizedstring.h>
26#include "ui_kistonegamutmapwidget.h"
43K_PLUGIN_FACTORY_WITH_JSON(KisToneGamutMapFilterFactory,
"kritatonegamutmapfilter.json", registerPlugin<KisToneGamutMapFilterPlugin>();)
80 QHash<QString, QVariant> params;
91 allTransforms << toneMap;
95 QHash<QString, QVariant> params;
99 if (targetProfile && config->getProperty(
GAMUT_MAP_METHOD).toString() ==
"CUSP_MAP") {
100 QVariantMap cuspDescription;
102 if (!tempCuspDescription.isEmpty()) {
103 Q_FOREACH(
const float key, tempCuspDescription.keys()) {
104 cuspDescription.insert(QString::number(key), tempCuspDescription.value(key));
106 params[
"cuspDescription"] = cuspDescription;
112 allTransforms << gamutMap;
115 if (allTransforms.isEmpty())
return nullptr;
140 Q_UNUSED(useForMasks)
152 ui->targetGamut->showDepth(
false);
153 ui->targetGamut->showColorBrowserButton(
false);
162 ui->cmbGamutMapMethod->addItem(i18n(
"Use Chroma-Lightness Cusp Map"),
"CUSP_MAP");
163 ui->cmbGamutMapMethod->addItem(i18n(
"Minimum Delta E"),
"MINDE");
165 ui->cmbGamutMapMethod->setItemData(0, i18nc(
"@info:tooltip",
"Use a chroma-lightness cusp map for a faster,"
166 " if more inaccurate gamut mapping. Only works for RGB and CMYK profiles,"
167 " will fall back on Minimum Delta E."), Qt::ToolTipRole);
168 ui->cmbGamutMapMethod->setItemData(1, i18nc(
"@info:tooltip",
"Will use the Minimum Delta E method,"
169 " where colors are brought into gamut until they minimally different from the transformed color."
170 " Slow but accurate."), Qt::ToolTipRole);
173 connect(
ui->cmbToneCurveType, SIGNAL(activated(
int)),
ui->stkToneMap, SLOT(setCurrentIndex(
int)));
191 for (
int i = 0; i < 10; i++) {
192 yAxisValues << QString::number(
float(i)/10.0,
'f', 1);
194 ui->toneCurvePreview->setYAxisValues(yAxisValues, 64);
208 ui->cmbMappingModel->setCurrentIndex(
ui->cmbMappingModel->findData(
value));
211 ui->cmbToneCurveType->setCurrentIndex(
ui->cmbToneCurveType->findData(
value));
212 ui->stkToneMap->setCurrentIndex(
ui->cmbToneCurveType->currentIndex());
216 ui->chkToneMap->setChecked(
value.toBool());
219 ui->spnMaxWhite->setValue(
value.toDouble());
222 ui->spnToeStrength->setValue(
value.toDouble());
225 ui->spnToeLength->setValue(
value.toDouble());
228 ui->spnShoulderStrength->setValue(
value.toDouble());
231 ui->spnShoulderLength->setValue(
value.toDouble());
234 ui->spnShoulderAngle->setValue(
value.toDouble());
239 ui->chkGamutMap->setChecked(
value.toBool());
244 ui->targetGamut->setCurrentColorSpace(
251 ui->cmbGamutMapMethod->setCurrentIndex(idx);
258 config->setProperty(
MAPPING_MODEL,
ui->cmbMappingModel->currentData());
263 config->setProperty(
TONE_MAP_TYPE,
ui->cmbToneCurveType->currentData());
278 for (
int x = 0; x < 20; x++) {
279 const float val = (float(x)/19.0)*white;
282 xAxisValues << QString::number(val,
'f', 1);
285 poly.append(QPointF(val/white, y));
287 ui->toneCurvePreview->setGreyscaleCurve(poly);
288 ui->toneCurvePreview->setProfileDataAvailable(
true);
289 ui->toneCurvePreview->setToolTip(i18n(
"Current Maximum White: %1", QString::number(white,
'f', 2)));
290 ui->toneCurvePreview->setXAxisValues(xAxisValues);
291 ui->toneCurvePreview->update();
294 const float white =
ui->spnMaxWhite->value();
296 for (
int x = 0; x < 20; x++) {
297 const float val = (float(x)/19.0)*white;
300 xAxisValues << QString::number(val,
'f', 1);
302 poly.append(QPointF(val/white, y));
304 ui->toneCurvePreview->setGreyscaleCurve(poly);
305 ui->toneCurvePreview->setProfileDataAvailable(
true);
306 ui->toneCurvePreview->setToolTip(i18n(
"Current Maximum White: %1", QString::number(white,
'f', 2)));
307 ui->toneCurvePreview->setXAxisValues(xAxisValues);
308 ui->toneCurvePreview->update();
312 if (
ui->targetGamut->currentColorSpace()) {
320#include "KisToneGamutMapFilter.moc"
float value(const T *src, size_t ch)
const QString GAMUT_MAP_METHOD
const QString GAMUT_MAP_ENABLED
bool, whether to do gamt mapping.
const QString TONE_PIECE_WISE_SHOULDER_ANGLE
const QString MAPPING_MODEL
Enum, model in which the gamut or tone mapping is done.
const QString TONE_MAP_MAX_WHITE
double, the maximum white that needs to be tonemapped.
const QString TONE_PIECE_WISE_SHOULDER_STRENGTH
const QString GAMUT_MAP_TARGET_PROFILE
QString, name of the color profile that is the target gamut.
const QString TONE_PIECE_WISE_TOE_LENGTH
const QString TONE_MAP_ENABLED
bool, whether to do tone mapping.
const QString TONE_PIECE_WISE_SHOULDER_LENGTH
const QString TONE_MAP_TYPE
String, indicates whether to use the cusp map or the MINDE method.
const QString TONE_PIECE_WISE_TOE_STRENGTH
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID XYZAColorModelID("XYZA", ki18n("XYZ/Alpha"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
void add(KisFilterSP item)
static KisFilterRegistry * instance()
static KisResourcesInterfaceSP instance()
~KisToneGamutMapFilterPlugin() override
KisToneGamutMapFilterPlugin(QObject *parent, const QVariantList &)
KoColorTransformation * createTransformation(const KoColorSpace *cs, const KisFilterConfigurationSP config) const override
KisConfigWidget * createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, bool useForMasks) const override
KisFilterConfigurationSP defaultConfiguration(KisResourcesInterfaceSP resourcesInterface) const override
KoColorTransformation * createColorTransformation(const QString &id, const QHash< QString, QVariant > ¶meters) const
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL
const KoID FiltersCategoryColorId("color_filters", ki18nc("The category of color transfer filters, like color to alpha. Noun.", "Colors"))
KisSharedPtr< KisFilter > KisFilterSP
QMap< float, QPointF > KRITAPIGMENT_EXPORT getGamutCuspDescription(const KoColorProfile *profile, KoGamutMappingUtils::MappingModel model, const int samplesPerChannel=5)
getGamutCuspDescription Generates a hexagonal gamut cusp description from a RGB or CMYK profile.
MappingModel
The MappingModel enum This represents the preferred model to do gamut and/or tone mapping in.
float KRITAPIGMENT_EXPORT reinhardToneMapping(const float linearY, const float maxY)
reinhardToneMapping Implements 'extended' reinhard tonemapping.
void setSupportsThreading(bool v)
void setSupportsAdjustmentLayers(bool v)
void setSupportsPainting(bool v)
virtual QString colorModelID() const
const KoColorProfile * profileByName(const QString &name) const
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()
The piecewiseFilmicCurve class Implement's Hable's piecewise filmic curve. https://filmicworlds....
static PiecewiseFilmicCurve fromUserParams(float toeStrength=0.5, float toeLength=0.5, float shoulderStrength=2.0, float shoulderLength=0.5, float shoulderAngle=1.0)
float evalCurve(const float x)