Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWdgOptionsPNG Class Reference

#include <kis_png_export.h>

+ Inheritance diagram for KisWdgOptionsPNG:

Public Member Functions

KisPropertiesConfigurationSP configuration () const override
 
 KisWdgOptionsPNG (QWidget *parent)
 
void setConfiguration (const KisPropertiesConfigurationSP config) override
 
- Public Member Functions inherited from KisConfigWidget
virtual KoCanvasResourcesInterfaceSP canvasResourcesInterface () const
 
virtual void setCanvasResourcesInterface (KoCanvasResourcesInterfaceSP canvasResourcesInterface)
 
virtual void setView (KisViewManager *view)
 
 ~KisConfigWidget () override
 

Private Slots

void on_alpha_toggled (bool checked)
 
void onConversionPolicyChanged ()
 

Private Attributes

bool m_floatingPoint {false}
 

Additional Inherited Members

- Signals inherited from KisConfigWidget
void sigConfigurationItemChanged ()
 
void sigConfigurationUpdated ()
 
void sigDropLockedConfig (KisPropertiesConfigurationSP p)
 
void sigSaveLockedConfig (KisPropertiesConfigurationSP p)
 
- Protected Member Functions inherited from KisConfigWidget
 KisConfigWidget (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(), int delay=200)
 

Detailed Description

Definition at line 15 of file kis_png_export.h.

Constructor & Destructor Documentation

◆ KisWdgOptionsPNG()

KisWdgOptionsPNG::KisWdgOptionsPNG ( QWidget * parent)

Definition at line 149 of file kis_png_export.cc.

150 : KisConfigWidget(parent)
151{
152 setupUi(this);
153
154 connect(cmbFloatingConversion, SIGNAL(activated(int)), this, SLOT(onConversionPolicyChanged()));
155 connect(chkCICP, SIGNAL(toggled(bool)), this, SLOT(onConversionPolicyChanged()));
156 connect(gbSaveColorInfo, SIGNAL(toggled(bool)), this, SLOT(onConversionPolicyChanged()));
157}
KisConfigWidget(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(), int delay=200)
void onConversionPolicyChanged()

References onConversionPolicyChanged().

Member Function Documentation

◆ configuration()

KisPropertiesConfigurationSP KisWdgOptionsPNG::configuration ( ) const
overridevirtual
Returns
the configuration

Implements KisConfigWidget.

Definition at line 264 of file kis_png_export.cc.

265{
266
268
269 bool alpha = this->alpha->isChecked();
270 bool interlace = interlacing->isChecked();
271 int compression = (int)compressionLevel->value();
272 bool tryToSaveAsIndexed = this->tryToSaveAsIndexed->isChecked();
273 bool forceSRGB = chkForceSRGB->isEnabled()? chkForceSRGB->isChecked(): false;
274 bool storeAuthor = chkAuthor->isChecked();
275 bool storeMetaData = chkMetaData->isChecked();
276 bool downsample = chkDownsample->isChecked();
277
278 bool saveColorInfo = gbSaveColorInfo->isChecked();
279 bool saveCICP = chkCICP->isChecked();
280 bool extraColor = chkExtraColorChunks->isChecked();
281
282 QString conversionMode = cmbFloatingConversion->currentData(Qt::UserRole+1).toString();
283
284 QVariant transparencyFillcolor;
285 transparencyFillcolor.setValue(bnTransparencyFillColor->color());
286
287 cfg->setProperty("alpha", alpha);
288 cfg->setProperty("indexed", tryToSaveAsIndexed);
289 cfg->setProperty("compression", compression);
290 cfg->setProperty("interlaced", interlace);
291 cfg->setProperty("transparencyFillcolor", transparencyFillcolor);
292 cfg->setProperty("forceSRGB", forceSRGB);
293 cfg->setProperty("storeAuthor", storeAuthor);
294 cfg->setProperty("storeMetaData", storeMetaData);
295 cfg->setProperty("downsample", downsample);
296 cfg->setProperty("storeColorSpaceInfo", saveColorInfo);
297 cfg->setProperty("writeCicpIfPossible", saveCICP);
298 cfg->setProperty("storeExtraColorChunks", extraColor);
299 cfg->setProperty("floatingPointConversionOption", conversionMode);
300 return cfg;
301}

◆ on_alpha_toggled

void KisWdgOptionsPNG::on_alpha_toggled ( bool checked)
privateslot

Definition at line 303 of file kis_png_export.cc.

304{
305 bnTransparencyFillColor->setEnabled(!checked);
306}

◆ onConversionPolicyChanged

void KisWdgOptionsPNG::onConversionPolicyChanged ( )
privateslot

Definition at line 308 of file kis_png_export.cc.

309{
310 cmbFloatingConversion->setEnabled(m_floatingPoint && (chkCICP->isChecked() && chkCICP->isEnabled()));
311 const QString conversionMode = cmbFloatingConversion->currentData(Qt::UserRole+1).toString();
312 if (cmbFloatingConversion->isEnabled()) {
313 chkForceSRGB->setEnabled(conversionMode == "KeepSame");
314 } else {
315 chkForceSRGB->setEnabled(true);
316 }
317}

References m_floatingPoint.

◆ setConfiguration()

void KisWdgOptionsPNG::setConfiguration ( const KisPropertiesConfigurationSP config)
overridevirtual
Parameters
configthe configuration for this configuration widget.

Implements KisConfigWidget.

Definition at line 159 of file kis_png_export.cc.

160{
161 // the export manager should have prepared some info for us!
165
166 // Setup the floating point conversion options.
167 QStringList conversionOptionsList = { i18nc("Color space name", "Rec 2100 PQ"), i18nc("Color space name", "Rec 2100 HLG")};
168 QStringList toolTipList = {i18nc("@tooltip", "The image will be converted to Rec 2020 linear first, and then encoded with a perceptual quantizer curve"
169 " (also known as SMPTE 2048 curve). Recommended for HDR images where the absolute brightness is important."),
170 i18nc("@tooltip", "The image will be converted to Rec 2020 linear first, and then encoded with a Hybrid Log Gamma curve."
171 " Recommended for HDR images where the display may not understand HDR.")};
172 QStringList conversionOptionName = {"Rec2100PQ", "Rec2100HLG"};
173 int cicpPrimaries = cfg->getInt(KisImportExportFilter::CICPPrimariesTag,
174 static_cast<int>(PRIMARIES_UNSPECIFIED));
175 if (cicpPrimaries != PRIMARIES_UNSPECIFIED) {
176 conversionOptionsList << i18nc("Color space option plus transfer function name", "Keep colorants, encode PQ");
177 toolTipList << i18nc("@tooltip", "The image will be linearized first, and then encoded with a perceptual quantizer curve"
178 " (also known as the SMPTE 2048 curve). Recommended for images where the absolute brightness is important.");
179 conversionOptionName << "ApplyPQ";
180
181 conversionOptionsList << i18nc("Color space option plus transfer function name", "Keep colorants, encode HLG");
182 toolTipList << i18nc("@tooltip", "The image will be linearized first, and then encoded with a Hybrid Log Gamma curve."
183 " Recommended for images intended for screens which cannot understand PQ");
184 conversionOptionName << "ApplyHLG";
185
186 conversionOptionsList << i18nc("Color space option plus transfer function name", "Keep colorants, encode SMPTE ST 428");
187 toolTipList << i18nc("@tooltip", "The image will be linearized first, and then encoded with SMPTE ST 428."
188 " Krita always opens images like these as linear floating point, this option is there to reverse that");
189 conversionOptionName << "ApplySMPTE428";
190 }
191
192 conversionOptionsList << i18nc("Color space option", "No changes, clip");
193 toolTipList << i18nc("@tooltip", "The image will be converted plainly to 16bit integer, and values that are out of bounds are clipped, the icc profile will be embedded.");
194 conversionOptionName << "KeepSame";
195
196
197 cmbFloatingConversion->clear();
198 cmbFloatingConversion->addItems(conversionOptionsList);
199 for (int i=0; i< toolTipList.size(); i++) {
200 cmbFloatingConversion->setItemData(i, toolTipList.at(i), Qt::ToolTipRole);
201 cmbFloatingConversion->setItemData(i, conversionOptionName.at(i), Qt::UserRole+1);
202 }
203 QString optionName =
204 cfg->getString("floatingPointConversionOption", "KeepSame");
205 if (conversionOptionName.contains(optionName)) {
206 cmbFloatingConversion->setCurrentIndex(
207 conversionOptionName.indexOf(optionName));
208 }
209 const QString colorDepthId =
211 if ((colorDepthId == Float16BitsColorDepthID.id()
212 || colorDepthId == Float32BitsColorDepthID.id()
213 || colorDepthId == Float64BitsColorDepthID.id())
214 && cfg->getString(KisImportExportFilter::ColorModelIDTag) == "RGBA") {
215 m_floatingPoint = true;
216 } else {
217 m_floatingPoint = false;
218 }
219
220 gbSaveColorInfo->setChecked(cfg->getBool("storeColorSpaceInfo", true));
221 chkCICP->setChecked(cfg->getBool("writeCicpIfPossible", true));
222 chkExtraColorChunks->setChecked(cfg->getBool("storeExtraColorChunks", true));
223
224
225 const bool isThereAlpha = cfg->getBool(KisImportExportFilter::ImageContainsTransparencyTag);
226
227 alpha->setChecked(cfg->getBool("alpha", isThereAlpha));
228
229 bnTransparencyFillColor->setEnabled(!alpha->isChecked());
230
232 tryToSaveAsIndexed->setVisible(true);
233 if (alpha->isChecked()) {
234 tryToSaveAsIndexed->setChecked(false);
235 }
236 else {
237 tryToSaveAsIndexed->setChecked(cfg->getBool("indexed", false));
238 }
239 }
240 else {
241 tryToSaveAsIndexed->setVisible(false);
242 }
243 interlacing->setChecked(cfg->getBool("interlaced", false));
244 compressionLevel->setValue(cfg->getInt("compression", 3));
245 compressionLevel->setRange(1, 9, 0);
246
247 tryToSaveAsIndexed->setVisible(!isThereAlpha);
248
249 chkForceSRGB->setChecked(cfg->getBool("forceSRGB", false));
250
251 chkAuthor->setChecked(cfg->getBool("storeAuthor", false));
252 chkMetaData->setChecked(cfg->getBool("storeMetaData", false));
253
254 KoColor background(KoColorSpaceRegistry::instance()->rgb8());
255 background.fromQColor(Qt::white);
256 bnTransparencyFillColor->setDefaultColor(background);
257 bnTransparencyFillColor->setColor(cfg->getColor("transparencyFillcolor", background));
258
259 chkDownsample->setChecked(cfg->getBool("downsample", false));
260
262}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
@ PRIMARIES_UNSPECIFIED
static const QString ColorDepthIDTag
static const QString ColorModelIDTag
static const QString CICPPrimariesTag
static const QString ImageContainsTransparencyTag
static const QString sRGBTag
QString id() const
Definition KoID.cpp:63
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
static KoColorSpaceRegistry * instance()

References KisImportExportFilter::CICPPrimariesTag, KisImportExportFilter::ColorDepthIDTag, KisImportExportFilter::ColorModelIDTag, Float16BitsColorDepthID, Float32BitsColorDepthID, Float64BitsColorDepthID, KoColor::fromQColor(), KoID::id(), KisImportExportFilter::ImageContainsTransparencyTag, KoColorSpaceRegistry::instance(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_floatingPoint, onConversionPolicyChanged(), PRIMARIES_UNSPECIFIED, RGBAColorModelID, and KisImportExportFilter::sRGBTag.

Member Data Documentation

◆ m_floatingPoint

bool KisWdgOptionsPNG::m_floatingPoint {false}
private

Definition at line 30 of file kis_png_export.h.

30{false};

The documentation for this class was generated from the following files: