diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-11-06 10:04:54 +0100 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-11-07 10:42:08 +0100 |
commit | 52a3f1b00cca13767eefabf61742d2d802c56511 (patch) | |
tree | f1a70dfb18ca2d0503ce07dcf05c7128062a59fb /src/gui/image/qimage_p.h | |
parent | e6a0a945c591da3e3e66a6d7a350b4befd77a459 (diff) |
Fix accuracy of ARGB32->A2RGB30 conversions
It was converted over ARGB32PM, when it should have been directly
converted to not lose accuracy, instead there was an unnecessary direct
ARGB32->RGB30 conversion, which was converted to the necessary type.
This also improves the selection of conversion over ARGB32PM or RGBA64PM
for ARGB32 and RGBA8888 by using 32-bit conversion when alpha is not
relevant.
Change-Id: I5990d8a23b2909d3910d8c1213fa46477742b052
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/image/qimage_p.h')
-rw-r--r-- | src/gui/image/qimage_p.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 9e2d9c86bb..0930955f5a 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -276,6 +276,29 @@ inline QImage::Format qt_alphaVersion(QImage::Format format) return QImage::Format_ARGB32_Premultiplied; } +inline bool qt_highColorPrecision(QImage::Format format, bool opaque = false) +{ + // Formats with higher color precision than ARGB32_Premultiplied. + switch (format) { + case QImage::Format_ARGB32: + case QImage::Format_RGBA8888: + return !opaque; + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: + return true; + default: + break; + } + return false; +} + + inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format) { const QImage::Format toFormat = qt_alphaVersion(format); |