Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 899423ad authored by Henrik Fehlauer's avatar Henrik Fehlauer

Update view after changing rendering intent config

Summary:
This is a follow-up patch to D10076, so after changing the rendering
intent in Gwenview's config dialog the displayed image is updated
immediately after clicking on {nav OK} or {nav Apply}. Before, it was
necessary to {nav Reload} the image manually or pan around.

Currently this is only implemented for raster images. In case someone
figures out colour management for SVGs, this patch should be extended to
SVGs too.

Depends on {D10076}.

CCBUG: 359909

Test Plan:
Set up an ICC profile as described in D10076#197598 and open an
out-of-gamut image. Change the rendering intent in Gwenview's config
dialog, click {nav Apply} and observe that the image's colours change
immediately. Saving to the config file still works.

Reviewers: ngraham, muhlenpfordt

Reviewed By: ngraham

Differential Revision: https://phabricator.kde.org/D10187
parent 7769905d
......@@ -26,7 +26,6 @@ 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
......@@ -37,9 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <QPointer>
#include <QDebug>
// LCMS2
#include <lcms2.h>
namespace Gwenview
{
......@@ -54,6 +50,7 @@ struct RasterImageViewPrivate
// Config
RasterImageView::AlphaBackgroundMode mAlphaBackgroundMode;
QColor mAlphaBackgroundColor;
cmsUInt32Number mRenderingIntent;
bool mEnlargeSmallerImages;
// /Config
......@@ -108,18 +105,9 @@ struct RasterImageViewPrivate
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,
renderingIntent, cmsFLAGS_BLACKPOINTCOMPENSATION);
mRenderingIntent, cmsFLAGS_BLACKPOINTCOMPENSATION);
mApplyDisplayTransform = true;
}
......@@ -213,6 +201,7 @@ RasterImageView::RasterImageView(QGraphicsItem* parent)
d->mAlphaBackgroundMode = AlphaBackgroundCheckBoard;
d->mAlphaBackgroundColor = Qt::black;
d->mRenderingIntent = INTENT_PERCEPTUAL;
d->mEnlargeSmallerImages = false;
d->mBufferIsEmpty = true;
......@@ -249,6 +238,14 @@ void RasterImageView::setAlphaBackgroundColor(const QColor& color)
}
}
void RasterImageView::setRenderingIntent(const RenderingIntent::Enum& renderingIntent)
{
if (d->mRenderingIntent != renderingIntent) {
d->mRenderingIntent = renderingIntent;
updateBuffer();
}
}
void RasterImageView::loadFromDocument()
{
Document::Ptr doc = document();
......
......@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Local
#include <lib/documentview/abstractimageview.h>
#include <lib/renderingintent.h>
// KDE
......@@ -55,6 +56,7 @@ public:
void setAlphaBackgroundMode(AlphaBackgroundMode mode);
void setAlphaBackgroundColor(const QColor& color);
void setRenderingIntent(const RenderingIntent::Enum& renderingIntent);
Q_SIGNALS:
void currentToolChanged(AbstractRasterImageViewTool*);
......
......@@ -138,6 +138,7 @@ void RasterImageViewAdapter::loadConfig()
{
d->mView->setAlphaBackgroundMode(GwenviewConfig::alphaBackgroundMode());
d->mView->setAlphaBackgroundColor(GwenviewConfig::alphaBackgroundColor());
d->mView->setRenderingIntent(GwenviewConfig::renderingIntent());
d->mView->setEnlargeSmallerImages(GwenviewConfig::enlargeSmallerImages());
}
......
......@@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#ifndef RENDERINGINTENT_H
#define RENDERINGINTENT_H
// Qt
// KDE
// Local
#include <lcms2.h>
namespace Gwenview
{
......@@ -35,9 +31,9 @@ namespace RenderingIntent
/**
* This enum represents the different color rendering modes
*/
enum Enum {
Perceptual,
Relative
enum Enum : cmsUInt32Number {
Perceptual = INTENT_PERCEPTUAL,
Relative = INTENT_RELATIVE_COLORIMETRIC
};
} // namespace RenderingIntent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment