Commit Graph

35 Commits

Author SHA1 Message Date
Eirik Aavitsland ff6cf6764d Tiff: Align 16 to 8 bit colormap conversion to libtiff
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>
2019-10-29 08:18:05 +01:00
Qt Forward Merge Bot 2a10b41260 Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: I2437b8b4b535e4f02740070e0352e1825c67fa3c
2019-10-12 03:07:56 +02:00
Eirik Aavitsland ab09c9dd9a Tiff handler: Improve writing performance for some cases
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>
2019-10-09 22:30:15 +02:00
Allan Sandfeld Jensen d63c1d05e4 Read/write ICC profile in TIFF plugin
Adds reading and writing of embedded color spaces on the TIFF plugin.

Change-Id: I53e8a16ff65f7986e9d51a5b543335e27b43e346
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2019-08-17 10:09:08 +02:00
Sona Kurazyan 7ad0ef0f31 Fix compilation with disabled deprecated APIs
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>
2019-07-08 09:58:59 +02:00
Qt Forward Merge Bot 9293902f32 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf

Change-Id: Ie44fe655653166bf5a4436aedd80d060afa45d5a
2019-03-27 10:29:42 +01:00
Eirik Aavitsland 0989f6aa2d tiff handler: fix compilation failure
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>
2019-03-25 12:01:07 +00:00
Allan Sandfeld Jensen 9f69817344 Add Grayscale16 support to TIFF
Change-Id: I927d9ab0af78baf90d8fd8d44088218dff0e7082
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2019-01-03 09:36:03 +00:00
Qt Forward Merge Bot a9be081dac Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: I56fb4e7a178ac79c75a846d9a7bcd8f1f3533673
2018-10-27 03:01:54 +02:00
Eirik Aavitsland 8455ab6cb2 tiffhandler: improve stripsize
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>
2018-10-25 12:19:14 +00:00
Eirik Aavitsland ceebd297c3 tiff handler: ensure valid value of the compression option
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>
2018-09-17 12:42:35 +00:00
Allan Sandfeld Jensen 2842212e88 Add RGBA64 format support to TIFF plugin
TIFF is one of the primary formats for HDR images.

Change-Id: I5310b5c9a625fd3e759e5120be6ba547c633c81c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2018-08-23 11:54:53 +00:00
Eirik Aavitsland 254bcd4793 Fix tiffhandler: ensure saved tiffs have suitable ROWSPERSTRIP tag set
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>
2018-06-06 07:22:21 +00:00
Jerome Duval 51ab877ae9 qtiffhandler: correct types for height and width
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>
2017-06-14 11:21:42 +00:00
Eirik Aavitsland c7a6a451a5 Extend support for tiled tiff files to all color formats
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>
2017-03-16 14:08:34 +00:00
Eirik Aavitsland 30301436b5 Add support for tiled, color indexed tiff files
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>
2017-03-15 11:53:40 +00:00
Sandro Mani d2306d7485 Add support for multipage TIFF images to QTiffHandler
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>
2017-01-25 09:46:19 +00:00
Allan Sandfeld Jensen 4e25236729 Use LZW compression on 1- and 8-bit formats
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>
2016-06-15 08:16:52 +00:00
Liang Qi cb800de1f4 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	.qmake.conf

Change-Id: Id59a8238134f1b0e172b22cd7e95d984a3f66401
2016-02-15 20:57:16 +01:00
Allan Sandfeld Jensen 58f19cf8d5 Improve interpretation of undefined alpha-channels
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>
2016-02-11 09:29:17 +00:00
Jani Heikkinen 8d76583e7d Updated license headers
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>
2016-01-20 20:12:46 +00:00
Allan Sandfeld Jensen 454fb13c46 Handle Grayscale8 TIFFs
Correctly read and write Grayscale8 image format.

Change-Id: I537c68f94077458c69ee1de08b5b37986b54aa26
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
2015-05-29 13:24:02 +00:00
Allan Sandfeld Jensen a1d412aec4 Optional application of orientation for TIFF
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>
2015-05-19 08:32:10 +00:00
Allan Sandfeld Jensen 8363c855f5 Correctly interpret RGBA tiff images as premultiplied
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>
2015-05-12 11:06:41 +00:00
Allan Sandfeld Jensen 4c00a26fc5 Clean up reading TIFF headers
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>
2015-05-04 17:55:14 +00:00
Liang Qi 5b1a331812 Merge remote-tracking branch 'origin/5.4' into 5.5
Change-Id: Ib6f1512a15f2714a712ff82df55a9d3de8e46ffd
2015-04-15 09:10:02 +02:00
Allan Sandfeld Jensen f65a4c931b Replace malloc'ed tables with QVarLengthArray
Basic cleanup using proper Qt classes instead of malloc.

Change-Id: I532b47aac7cfe15a5963371224288bec08135f25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-03-17 22:09:10 +00:00
Jani Heikkinen 6aeeadf865 Update copyright headers
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>
2015-02-11 13:20:21 +00:00
Jani Heikkinen dd5634f8f4 Update license headers and add new licenses
- Renamed LICENSE.LGPL to LICENSE.LGPLv21
- Added LICENSE.LGPLv3 & LICENSE.GPLv2
- Removed LICENSE.GPL

Change-Id: I803e1abdc6f126d5251746422e16fff7463f2dff
Reviewed-by: Antti Kokko <antti.kokko@digia.com>
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@digia.com>
2014-08-25 06:52:29 +02:00
Allan Sandfeld Jensen 218c48b5c3 Save opaque images as opaque TIFF files
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>
2014-07-04 14:47:08 +02:00
Allan Sandfeld Jensen 5c4036eeb2 Use RGBA8888 format to simplify TIFF writing
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>
2014-02-10 18:36:26 +01:00
Leonard Lee 44ea4280b2 Fix TIFFTAG_RESOLUTIONUNIT handling.
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>
2013-02-05 17:28:02 +01:00
Sergio Ahumada f377f4960a Update copyright year in Digia's license headers
Change-Id: I82e67b5704007d838d6ab1ee1bc9a870bff7d4c8
Reviewed-by: aavit <eirik.aavitsland@digia.com>
2013-01-02 13:16:31 +01:00
Iikka Eklund 1e036655df Change copyrights from Nokia to Digia
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>
2012-09-23 08:24:41 +02:00
Kent Hansen f68a3dc48d Add TIFF plugin
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>
2012-02-01 13:31:19 +01:00