summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Graham <[email protected]>2018-01-28 16:41:08 -0700
committerNathaniel Graham <[email protected]>2018-01-29 15:42:57 -0700
commit338ffeee4deea6c9bf8d240593b5bc375ae50dd7 (patch)
treefa5517b3e40481421e04f20f807c45270f66f266
parent8a6a4ea6b9853ef4c9a916d2d91d8a7a02ad6b64 (diff)
Add a user-facing control to choose the ICC color rendering intent
Summary: FEATURE: 359909 FIXED-IN: 18.04 Allow the user to choose the ICC color rendering intent, instead of hardcoding INTENT_PERCEPTUAL Supersedes D8763 Test Plan: The GUI control appears and seems to work as intended. {F5680320} - Tested that the default value of Perceptual is used when there is no value in ~/.config/gwenviewrc - Tested that the value gets set in ~/.config/gwenviewrc - Tested that removing the value in ~/.config/gwenviewrc reverts the GUI setting to Perceptual - Tested that toggling the setting back and forth actually has an impact when using a display with an active color profile. Here's an example: Perceptual: {F5677933} Relative Colorimetric: {F5677990} Reviewers: DrSlony, rkflx Reviewed By: rkflx Subscribers: muhlenpfordt, rempt, behrmann Differential Revision: https://phabricator.kde.org/D10076
-rw-r--r--app/advancedconfigpage.ui99
-rw-r--r--app/configdialog.cpp8
-rw-r--r--app/configdialog.h1
-rw-r--r--lib/documentview/rasterimageview.cpp13
-rw-r--r--lib/gwenviewconfig.kcfg15
-rw-r--r--lib/renderingintent.h47
6 files changed, 179 insertions, 4 deletions
diff --git a/app/advancedconfigpage.ui b/app/advancedconfigpage.ui
index dca1f4b..096cef0 100644
--- a/app/advancedconfigpage.ui
+++ b/app/advancedconfigpage.ui
@@ -56,7 +56,7 @@
</widget>
</item>
<item row="2" column="0">
- <spacer name="verticalSpacer_3">
+ <spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -106,14 +106,107 @@
</layout>
</item>
<item row="4" column="0" colspan="2">
- <spacer name="verticalSpacer">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="colorRenderingLabel">
+ <property name="text">
+ <string>Rendering intent:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>relativeRenderingIntentRadioButton</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QRadioButton" name="perceptualRenderingIntentRadioButton">
+ <property name="text">
+ <string comment="@option:Perceptual rendering intent">Perceptual</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLabel" name="perceptualHelpLabel">
+ <property name="text">
+ <string>Scale all colors equally to fit them within the active color profile's color gamut</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" colspan="2">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="8" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QRadioButton" name="relativeRenderingIntentRadioButton">
+ <property name="text">
+ <string comment="@option:Relative Colorimetric rendering intent">Relative Colorimetric</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="9" column="1">
+ <widget class="QLabel" name="relativeHelpLabel">
+ <property name="text">
+ <string>Squash colors that don't fit within the active color profile's color gamut, leaving other colors untouched</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1">
+ <spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>151</height>
+ <height>20</height>
</size>
</property>
</spacer>
diff --git a/app/configdialog.cpp b/app/configdialog.cpp
index 6dcb306..7cdbfab 100644
--- a/app/configdialog.cpp
+++ b/app/configdialog.cpp
@@ -91,9 +91,17 @@ ConfigDialog::ConfigDialog(QWidget* parent)
// Advanced
widget = setupPage(mAdvancedConfigPage);
+
+ mRenderingIntentGroup = new InvisibleButtonGroup(widget);
+ mRenderingIntentGroup->setObjectName(QLatin1String("kcfg_RenderingIntent"));
+ mRenderingIntentGroup->addButton(mAdvancedConfigPage.relativeRenderingIntentRadioButton, int(RenderingIntent::Relative));
+ mRenderingIntentGroup->addButton(mAdvancedConfigPage.perceptualRenderingIntentRadioButton, int(RenderingIntent::Perceptual));
+
pageItem = addPage(widget, i18n("Advanced"));
pageItem->setIcon(QIcon::fromTheme("preferences-other"));
mAdvancedConfigPage.cacheHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
+ mAdvancedConfigPage.perceptualHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
+ mAdvancedConfigPage.relativeHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
updateViewBackgroundFrame();
}
diff --git a/app/configdialog.h b/app/configdialog.h
index 5f208aa..4bca637 100644
--- a/app/configdialog.h
+++ b/app/configdialog.h
@@ -50,6 +50,7 @@ private:
InvisibleButtonGroup* mAnimationMethodGroup;
InvisibleButtonGroup* mZoomModeGroup;
InvisibleButtonGroup* mThumbnailBarOrientationGroup;
+ InvisibleButtonGroup* mRenderingIntentGroup;
Ui_GeneralConfigPage mGeneralConfigPage;
Ui_ImageViewConfigPage mImageViewConfigPage;
Ui_AdvancedConfigPage mAdvancedConfigPage;
diff --git a/lib/documentview/rasterimageview.cpp b/lib/documentview/rasterimageview.cpp
index 3a44662..44188c2 100644
--- a/lib/documentview/rasterimageview.cpp
+++ b/lib/documentview/rasterimageview.cpp
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <lib/imagescaler.h>
#include <lib/cms/cmsprofile.h>
#include <lib/gvdebug.h>
+#include <lib/gwenviewconfig.h>
// KDE
@@ -106,9 +107,19 @@ struct RasterImageViewPrivate
qWarning() << "Gwenview can only apply color profile on RGB32 or ARGB32 images";
return;
}
+
+ cmsUInt32Number renderingIntent = 0;
+ switch (GwenviewConfig::renderingIntent()) {
+ case RenderingIntent::Perceptual:
+ renderingIntent = INTENT_PERCEPTUAL;
+ break;
+ case RenderingIntent::Relative:
+ renderingIntent = INTENT_RELATIVE_COLORIMETRIC;
+ break;
+ }
mDisplayTransform = cmsCreateTransform(profile->handle(), cmsFormat,
monitorProfile->handle(), cmsFormat,
- INTENT_PERCEPTUAL, cmsFLAGS_BLACKPOINTCOMPENSATION);
+ renderingIntent, cmsFLAGS_BLACKPOINTCOMPENSATION);
mApplyDisplayTransform = true;
}
diff --git a/lib/gwenviewconfig.kcfg b/lib/gwenviewconfig.kcfg
index 7cab5bb..1e8866d 100644
--- a/lib/gwenviewconfig.kcfg
+++ b/lib/gwenviewconfig.kcfg
@@ -11,6 +11,7 @@
<include>lib/documentview/documentview.h</include>
<include>lib/documentview/rasterimageview.h</include>
<include>lib/print/printoptionspage.h</include>
+ <include>lib/renderingintent.h</include>
<group name="SideBar">
<entry name="PreferredMetaInfoKeyList" type="StringList">
<default>General.Name,General.ImageSize,Exif.Photo.ExposureTime,Exif.Photo.Flash</default>
@@ -158,6 +159,20 @@
own zoom and position (if these are changed, image A will NOT
be displayed with the updated zoom and position).</whatsthis>
</entry>
+
+ <entry name="RenderingIntent" type="Enum">
+ <choices name="Gwenview::RenderingIntent::Enum">
+ <choice name="RenderingIntent::Perceptual"/>
+ <choice name="RenderingIntent::Relative"/>
+ </choices>
+ <default>RenderingIntent::Perceptual</default>
+ <whatsthis>Defines how colors are rendered when your display
+ uses an ICC color profile and an image has colors that do not
+ fit within the profile's color gamut. "Perceptual" will scale
+ the colors of the entire image so that they all fit within the
+ display's capabilities. "Relative" will squash only the colors
+ that cannot be displayed, and leave the other colors alone.</whatsthis>
+ </entry>
</group>
<group name="ThumbnailView">
diff --git a/lib/renderingintent.h b/lib/renderingintent.h
new file mode 100644
index 0000000..29b417e
--- /dev/null
+++ b/lib/renderingintent.h
@@ -0,0 +1,47 @@
+// vim: set tabstop=4 shiftwidth=4 expandtab:
+/*
+Gwenview: an image viewer
+Copyright 2018 Nate Graham <[email protected]>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
+
+*/
+#ifndef RENDERINGINTENT_H
+#define RENDERINGINTENT_H
+
+// Qt
+
+// KDE
+
+// Local
+
+namespace Gwenview
+{
+
+namespace RenderingIntent
+{
+/**
+ * This enum represents the different color rendering modes
+ */
+enum Enum {
+ Perceptual,
+ Relative
+};
+
+} // namespace RenderingIntent
+
+} // namespace Gwenview
+
+#endif /* RENDERINGINTENT_H */