diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-19 11:30:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-23 23:37:37 +0200 |
commit | 733ca2230c283cdfaae424eac481ddc33593f44f (patch) | |
tree | 235d10076fd80c4d1659f2b951e5b203bfe4e2b4 /src/gui | |
parent | b6f7efba4831c411456400e2df87df99877f67ae (diff) |
Fix comparisons of image with different color spaces
Take color space into account when comparing images, and fix gamma
comparison that was trying to be too accurate.
Change-Id: I3674653abb21b66aaacb557addc4afb4ee75cfdd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimage.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qcolorspace.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index cd2fe5bc10..7ac4b3546e 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3834,7 +3834,9 @@ bool QImage::operator==(const QImage & i) const return false; // obviously different stuff? - if (i.d->height != d->height || i.d->width != d->width || i.d->format != d->format) + if (i.d->height != d->height || i.d->width != d->width) + return false; + if (i.d->format != d->format || i.d->colorSpace != d->colorSpace) return false; if (d->format != Format_RGB32) { diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 3c336c9fe7..d058505e68 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -651,7 +651,7 @@ bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) if (colorSpace1.transferFunction() != colorSpace2.transferFunction()) return false; if (colorSpace1.transferFunction() == QColorSpace::TransferFunction::Gamma) - return colorSpace1.gamma() == colorSpace2.gamma(); + return (qAbs(colorSpace1.gamma() - colorSpace2.gamma()) <= (1.0f / 512.0f)); return true; } |