diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-11-21 15:10:39 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-11-24 09:40:14 +0000 |
commit | ffd316ebe3963b7ff8d94a3484ac85de793b8299 (patch) | |
tree | 6b933591f176af9451c746ee2c340ae7bd8c72fb /src/gui/image/qimage_conversions.cpp | |
parent | 38a446b69e95423d8d42d33b30b3154caa475e09 (diff) |
Replace QDrawHelperGammaTables with QColorProfile
Turns the two set of tables in QDrawHelperGammaTables into two
QColorProfile classes that use similar structures and can be reused for
other gamma correction.
At the same time clean-up and improve the comma-correct blending code
to use the new profiles and QRgba64 precision.
Change-Id: I302bd87a5c836e1010fff6d633eeb56fd4ae2ff0
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/gui/image/qimage_conversions.cpp')
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index c646ee96b4..d685d50d49 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -39,6 +39,7 @@ #include <private/qdrawhelper_p.h> #include <private/qguiapplication_p.h> +#include <private/qcolorprofile_p.h> #include <private/qsimd_p.h> #include <private/qimage_p.h> #include <qendian.h> @@ -82,23 +83,17 @@ const uchar *qt_get_bitflip_array() void qGamma_correct_back_to_linear_cs(QImage *image) { - const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); - if (!tables) + const QColorProfile *cp = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); + if (!cp) return; - const uchar *gamma = tables->qt_pow_rgb_gamma; // gamma correct the pixels back to linear color space... int h = image->height(); int w = image->width(); for (int y=0; y<h; ++y) { - uint *pixels = (uint *) image->scanLine(y); - for (int x=0; x<w; ++x) { - uint p = pixels[x]; - uint r = gamma[qRed(p)]; - uint g = gamma[qGreen(p)]; - uint b = gamma[qBlue(p)]; - pixels[x] = (r << 16) | (g << 8) | b | 0xff000000; - } + QRgb *pixels = reinterpret_cast<QRgb *>(image->scanLine(y)); + for (int x=0; x<w; ++x) + pixels[x] = cp->toLinear(pixels[x]); } } |