68
68
QWeakPointer<AbstractRasterImageViewTool> mTool;
70
bool mApplyDisplayTransform; // Defaults to true. Can be set to false if there is no need or no way to apply color profile
70
71
cmsHTRANSFORM mDisplayTransform;
72
void updateDisplayTransform()
73
void updateDisplayTransform(QImage::Format format)
75
GV_RETURN_IF_FAIL(format != QImage::Format_Invalid);
76
mApplyDisplayTransform = false;
74
77
if (mDisplayTransform) {
75
78
cmsDeleteTransform(mDisplayTransform);
77
80
mDisplayTransform = 0;
78
82
Cms::Profile::Ptr profile = q->document()->cmsProfile();
82
86
Cms::Profile::Ptr monitorProfile = Cms::Profile::getMonitorProfile();
83
87
if (!monitorProfile) {
88
kWarning() << "Could not get monitor color profile";
87
92
cmsUInt32Number cmsFormat = 0;
88
switch (q->document()->image().format()) {
89
94
case QImage::Format_RGB32:
90
95
case QImage::Format_ARGB32:
91
96
cmsFormat = TYPE_BGRA_8;
99
kWarning() << "This image has a color profile, but Gwenview can only apply color profile on RGB32 or ARGB32 images";
96
// FIXME: Wrap cmsHTRANSFORM type?
97
102
mDisplayTransform = cmsCreateTransform(profile->handle(), cmsFormat,
98
103
monitorProfile->handle(), cmsFormat,
99
104
INTENT_PERCEPTUAL, cmsFLAGS_BLACKPOINTCOMPENSATION);
105
mApplyDisplayTransform = true;
102
108
void createBackgroundTexture()
303
309
void RasterImageView::updateFromScaler(int zoomedImageLeft, int zoomedImageTop, const QImage& image)
305
if (d->mDisplayTransform) {
306
quint8 *bytes = const_cast<quint8*>(image.bits());
307
cmsDoTransform(d->mDisplayTransform, bytes, bytes, image.width() * image.height());
311
if (d->mApplyDisplayTransform) {
312
if (!d->mDisplayTransform) {
313
d->updateDisplayTransform(image.format());
315
if (d->mDisplayTransform) {
316
quint8 *bytes = const_cast<quint8*>(image.bits());
317
cmsDoTransform(d->mDisplayTransform, bytes, bytes, image.width() * image.height());
310
321
d->resizeBuffer();