For paletted images, tiff stores a color map with 16 bit deep
entries. When reading such images, the tiff handler tried to be clever
in the 16 to 8 bit mapping, but this resulted in slightly different
result than what libtiff itself produces if asked to read and convert
such an image (TIFFReadRGBAImageOriented()). libtiff simply ignores
the lower 8 bits, so we should do the same.
Importantly, this makes no difference when 8 bit original data is
stored in the orthodox 16 bit way, where e.g. 0xAB is stored as 0xABAB
- like we do. However, the alternative storages 0xAB00 and 0xABFF
exist in the wild, even in sample images in Qt repos.
Also, if we later should want to support proper 16 bit data here, the
previous code was anyway wrong: just dividing with 257 is highly
unorthodox. The correct way would be to use proper rounding like
QRgba64::toArgb32().
Fixes: QTBUG-79522
Change-Id: I7bd90ad7b89a923bd431781f4927b13ad0544407
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
For 1 byte deep formats, the writing routine went through the
copy-and-convert-in-chunks loop for no reason: no conversion was done
or needed.
For huge images of some formats, the chunk size computation could fail
because of int overflow, resulting in suboptimal chunk sizes.
Change-Id: I966351d9a8728987c9e885f4949d98ba94d4ac19
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Adds reading and writing of embedded color spaces on the TIFF plugin.
Change-Id: I53e8a16ff65f7986e9d51a5b543335e27b43e346
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
The QImageIOHandler::name() has been deprecated since 5.13, but its
overrides weren't. Enabled compilation of the overrides only when the
QImageIOHandler::name() is compiled.
Task-number: QTBUG-76491
Change-Id: I913f03f730969ea88864a5a08afe50c4eac533ca
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Avoid using the tmsize_t type, since it may not be defined.
Fixes: QTBUG-74283
Change-Id: I63a496173ec08c6ceac569c516d11a4711e32649
Reviewed-by: Richard Öhlinger <richard.oehlinger@adbsafegate.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
libtiff's default stripsize is tiny (8KB), so splitting the image into
such strips on writing would significantly hurt the compression
rate. Aim for 4MB strips instead.
Task-number: QTBUG-70820
Change-Id: I07a9a8c81edf62e802b4ae8d6729a76df15e42ac
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Bound the value of the compression setting to the possible values of
the QTiffHandler::Compression enum.
Change-Id: I50e1eb8014654d8b4403d7f06e6099661e57562c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
TIFF is one of the primary formats for HDR images.
Change-Id: I5310b5c9a625fd3e759e5120be6ba547c633c81c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
When writing an image without compression, libtiff will automatically
store it in strips of default size, and add a ROWSPERSTRIP tag
accordingly. However, if compression is enabled, libtiff does not do
this. The lack of this tag may create trouble for readers.
Fix by explicitly setting the tag in all cases.
[ChangeLog][TIFF] Ensure saved tiffs have suitable ROWSPERSTRIP tag set
Task-number: QTBUG-68609
Change-Id: I838c83be25158d7f13e220098e960010b8cb2789
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
qMin() was used with quint32 and uint32. This fixes the build on Haiku.
Change-Id: I193f561b9a63ffe9ee5ae991084118a821e3f22d
Reviewed-by: Augustin Cavalier <waddlesplash@gmail.com>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit extends the recently added support for tiled tiff images
of color index format to also cover grayscale and mono images. RGB
images were already covered, since the libtiff API used for those
handles tiled images transparently.
This commit also simplifies the tiff read() function by sharing
common code among the different formats.
[ChangeLog][TIFF] Extend support for tiled tiff files to all color formats
Change-Id: I13f94bbca65dd6a35384a415906034e245ad8b79
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
For color index images, the tiff handler uses scanline based
reading. The tiff decoder does not support that if the image is stored
in tiled format. This commit adds tile based reading for such cases.
[ChangeLog][TIFF] Added support for tiled, color indexed tiff files
Task-number: QTBUG-12636
Change-Id: Ic759903c75c8252267429f01e3dd9706fc516f8f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Allows multipage TIFF images to be read via QImageReader::jumpToImage
and QImageReader::jumpNextToImage.
[ChangeLog][QtGui][QImageReader] Support multipage TIFF images through
QImageReader
Change-Id: Id6ac68b75500148e51be11eff3d296c929d2d95c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
The documentation says we use LZW, and LZW both works and produces
smaller results, so it would make sense to follow our documentation.
This also fixes a problem with some readers having trouble with the
CCITTRLE compressions.
Task-number: QTBUG-53774
Change-Id: Ie2d179279a4ce65d8578c037ad59cc37ca854825
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Libtiff does not process the alpha-channel if its definition is not
specified. However to match how Qt used to save TIFF images and how
tested image viewers interpret them, we need to treat unspecified alpha
channels as unpremultiplied.
Task-number: QTBUG-50902
Change-Id: Id72218ed5bf702b54ffa3b5b47d6230facbfa0c4
Reviewed-by: aavit <eirik.aavitsland@theqtcompany.com>
From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new LGPL header instead of LGPL21 one
(in those files which will be under LGPL v3)
Change-Id: I6ae2887539c66fa4e1388a9486fe798f2e595434
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Make the image orientation only optionally applied for TIFF images
to match the new image handler flags.
The default however remains to apply transformation, as opposed
to JPEGs.
The patch also adds the capability to write metadata orientation.
Change-Id: Ie24664516138641342ab6d7559d591f38b9f1e8a
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
The TIFFReadRGBAImageOriented method turns out to return colors with
alpha premultiplied by default. The only reason we pass our own tests
is because we also save the colors incorrectly unpremultiplied.
The patch fixes the format type of the returned images, and explictily
writes the how alpha should be interpreted in the saved files.
Change-Id: Ie1c3881acfe07eae25ca735adf243c1636f656a0
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Split reading TIFF headers from the decoding to make it
possible to read correct metadata on undecoded images.
This fixes reading the image format from the QImageReader,
and is necessary for later patches.
Change-Id: Ida27e98252bf95459d87354586d4a5fba348efcb
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.
Change-Id: I6aafb5f38bfaf68a9f4eaca69a56006db5cd8843
Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
Reviewed-by: aavit <eirik.aavitsland@theqtcompany.com>
We currently save all non-indexed images as RGBA TIFF files. We should
save them without an alpha channel, to save space and maintain the
information that they are opaque.
Task-number: QTBUG-18475
Change-Id: Id656f4078ea0a1b88235fb04add99a4680422354
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
We write TIFF files using big-endian RGBA, by using the RGBA8888 QImage
format we can remove the manual conversion done in qtiffhandler.
Change-Id: I4a7f4810ce4332d1608813d9cd6371bc13d94df0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
If there is no TIFFTAG_RESOLUTIONUNIT record, the value of resUnit
should be RESUNIT_INCH and not RESUNIT_NONE.
Task-number: QTBUG-22322
Change-Id: Idb1ffeec85fdb5a23d93fa53505440a9e2f8914e
Reviewed-by: aavit <eirik.aavitsland@digia.com>
Change copyrights and license headers from Nokia to Digia
Change-Id: Ia126f46d5f67e9acf9e2efc8bf99c50fd1c22809
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Moved out from qtbase.
Task-number: QTBUG-23887
Change-Id: I57d30173e6624d41dba1610084a7ed949ae84d1d
Reviewed-by: aavit <qt_aavit@ovi.com>
Sanity-Review: Kent Hansen <kent.hansen@nokia.com>