diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-05-27 18:08:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-22 12:22:37 +0000 |
commit | e0139718bbe1317a46bf841870847159959840e5 (patch) | |
tree | 4165dacff66ff9c0ae371eaafa396c8720c13762 /src/gui/image/qimagereader.cpp | |
parent | c29383769a7ce9e3c757f980bf856aa4d9caf887 (diff) |
Export gamma setting and metadata in QImageReader
The PNG image plugin has the capability of applying gamma correction
to read PNGs, but doesn't do so by default, and we export no way of
accessing this through the qimagereader API.
This patch adds the ability to read the PNG file gamma, and overriding
decoded gamma to get gamma correction.
Change-Id: Iaf9eaac0827516db6bc02247c58026270cd1f610
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui/image/qimagereader.cpp')
-rw-r--r-- | src/gui/image/qimagereader.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index ba79bf40e5..83ec91bb40 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1203,6 +1203,39 @@ bool QImageReader::autoTransform() const } /*! + \since 5.6 + + This is an image format specific function that forces images with + gamma information to be gamma corrected to \a gamma. For image formats + that do not support gamma correction, this value is ignored. + + To gamma correct to a standard PC color-space, set gamma to \c 1/2.2. + + \sa gamma() +*/ +void QImageReader::setGamma(float gamma) +{ + if (d->initHandler() && d->handler->supportsOption(QImageIOHandler::Gamma)) + d->handler->setOption(QImageIOHandler::Gamma, gamma); +} + +/*! + \since 5.6 + + Returns the gamma level of the decoded image. If setGamma() has been + called and gamma correction is supported it will return the gamma set. + If gamma level is not supported by the image format, \c 0.0 is returned. + + \sa setGamma() +*/ +float QImageReader::gamma() const +{ + if (d->initHandler() && d->handler->supportsOption(QImageIOHandler::Gamma)) + return d->handler->option(QImageIOHandler::Gamma).toFloat(); + return 0.0; +} + +/*! Returns \c true if an image can be read for the device (i.e., the image format is supported, and the device seems to contain valid data); otherwise returns \c false. |