Commit Graph
59 Commits
Author SHA1 Message Date
Andrew Champion ec0477125f Tags: restore primitive conversions as inherent methods 2020-02-01 18:25:05 +00:00
Andrew Champion eadec8f0b9 Remove most unchecked size/index casts
Convert most unchecked size/index `as` casts to checked casts with
`TryFrom`, included another top-level error variant.

This has several motivations:
- Making the library as robust as possible, including to platform
differences.
- Unchecked casts are susceptible to breakage during refactorings.
- Preparing for BigTIFF support, which will require the introduction of
generics and associated types for some parts of the de/encoders.
Unchecked primitive casts cannot be bound, while TryFrom can, and
overflowing conversions become more likely.
- Remaining u16 casts may be prone in failure in existing practice and
not just in theory during future changes.
2019-12-21 15:57:24 +00:00
Andrew Champion 462697e373 Add support for CMYK(16|32|64) decoding 2019-12-21 15:57:24 +00:00
Andrew Champion f92be13f6c Factor tags into own module
Tag representations are not decoder- or encoder-specific, so should live
in their own module accessible to both for reuse. The decoder::ifd
module remains since this module is mainly dedicated to decoding the
IFD.
2019-12-21 15:57:24 +00:00
Andrew Champion f9cace84da Deduplicate primitive conversions for tag enum 2019-12-21 15:57:24 +00:00
Andrew Champion d510a9f4ab Strictly handle expected tag value types
Resolve several TODOs where tag values were cast from u32 without checks
by providing generic methods that error when the value fails casting to
the desired type. In addition to being more correct, this simplifies and
shortens decoding logic.

Remove `find_tag_u32` and `find_tag_u32_vec` as they are now redundant
and a GitHub code search found no usages outside copies of
`image-tiff`.
2019-12-21 15:57:24 +00:00
Andrew Champion 8b96793671 Simplify expression (minor) 2019-12-21 15:57:24 +00:00
Andrew Champion 27ae65160d Deduplicate decoding buffer construction 2019-12-21 15:57:24 +00:00
Andrew Champion abd6aee19f Remove outdate and ambiguous TODO (minor) 2019-12-16 22:10:57 +00:00
Andrew Champion e5d2e7862c Parse all homogeneous bit depth RGB(A) color types
Make the behavior of RGB and RGBA like Gray in returning ColorTypes for
all homogeneous bit depths, even if those depths are not 8, 16, 32 or
64. Note that this does not change which color types can actually be
decoded.
2019-12-11 15:03:05 +00:00
Andrew Champion 6e61de81b6 Simplify color type matching 2019-12-11 12:56:11 +00:00
Andrew Champion 0c53e1066a Support 64-bit rgb and rgba decoding 2019-12-10 20:18:53 +00:00
Andrew Champion f4e985e0bd Support 64-bit grayscale decoding 2019-12-10 20:18:53 +00:00
Andrew Champion 1f92c562bc Support 32-bit rgb and rgba decoding 2019-12-10 20:18:51 +00:00
Andrew Champion fca4e1f88a Support 32-bit grayscale decoding 2019-12-10 20:18:23 +00:00
Andreas Molzer 7b672998db Get rid of num-traits crate
Turns out the only use was as a private bound which was unused within
that method.
2019-11-12 20:06:02 +01:00
Andreas Molzer a6696ab02f fixup! Move everything to the tags macro 2019-11-10 19:24:22 +01:00
Andreas Molzer f88c9f00c3 Move everything to the tags macro 2019-11-10 18:02:42 +01:00
Andreas Molzer f80f4a06d5 Make the Unknown field optional
Several other uses that currently rely on num-traits for conversion have
no Unknown representation. Thus, the converter now outputs only known
variants or an error and the exposing function then can put the error
value into an Unknown variant instead.
2019-11-10 18:02:08 +01:00
HeroicKatora 6aea7b33c1 Merge pull request #49 from Masterchef365/deflate
Old-style DEFLATE compression support
2019-11-01 00:42:18 +01:00
Masterchef365 f8d4b57120 Change implementation details for InflateError, add uncompressed cap 2019-10-04 18:52:39 -07:00
Masterchef365 205626bd62 Switch to miniz_oxide crate for DEFLATE decompression 2019-10-02 18:51:47 -07:00
Masterchef365 ce73d39d57 Add old-style DEFLATE support 2019-10-02 18:51:07 -07:00
Masterchef365 b79128d766 Add Deflate and OldDeflate compression type recognition 2019-10-02 18:51:07 -07:00
Callum Tolley 3868f78067 Make Limits struct fields publicly accessible 2019-09-22 22:11:24 +01:00
Yuki Okushi ea19f0f686 Remove try! macros 2019-08-29 19:10:27 +09:00
Dustin Thomson 30eb8487a6 Signed value support
Add support for SBYTE, SSHORT, SLONG, SRATIONAL as per the Tiff 6.0 spec
Add support for multiple BYTE
2019-08-14 21:22:56 -06:00
Birk Tjelmeland 514b7cddaa Change minimal rustc version to 1.24.1 2019-05-03 23:12:29 +02:00
Birk Tjelmeland 48f16f5206 Merge pull request #41 from birktj/fix-bugs
Fix divide by zero bug
2019-04-25 22:30:31 +02:00
Birk Tjelmeland 4609425be9 Merge pull request #37 from jimrybarski/master
Allow Decoder::next_image() to be called multiple times to allow paging through a multi-page TIFF
2019-04-25 18:23:06 +02:00
Birk Tjelmeland dbf532b0a9 Fix divide by zero bug
This fixes #33
2019-04-25 14:58:08 +02:00
Atul Bhosale 522fbd1a69 Format code using 'cargo fmt' 2019-04-18 00:04:43 +05:30
Jim Rybarski d314a032de Merge branch 'master' of github.com:PistonDevelopers/image-tiff 2019-03-29 09:47:35 -05:00
Jim Rybarski 198f3ff3dc Allow Decoder::next_image() to be called multiple times to allow paging through a multi-page TIFF 2019-03-28 15:14:44 -05:00
Birk Tjelmeland 5e86931dff Fix possibly overflowing multiplications 2019-03-12 11:07:57 +01:00
Birk Tjelmeland 5c3f50f800 Fix compiler and clippy warnings 2019-02-28 07:58:07 +01:00
Birk Tjelmeland bd0d66c09f Fix potential out of bounds array access 2019-02-27 19:45:59 +01:00
Birk Tjelmeland d637e1f7f6 Fix memory exhaustion bug 2019-02-27 16:15:57 +01:00
Birk Tjelmeland 6aa5f3add5 Made DecodingBuffer public
Marked `DecodingBuffer` and `read_strip_to_buffer`
as public to reduce copies in eventual `TiffReader`.
2019-02-08 21:05:25 +01:00
Birk Tjelmeland 6884558687 Incremental decoding implemented 2019-02-01 11:08:13 +01:00
Jonathan Behrens fab6734275 Remove unsafe code 2019-01-11 15:03:40 -05:00
Jonathan Behrens 60f5a8f450 Fix calculation of uncompressed_strip_size 2018-09-23 01:12:39 -04:00
Sven Nilsen c3aaadaa4e Fix missing errors 2018-09-19 18:12:19 +02:00
Sven Nilsen 0228fc3204 Merge branch 'master' into 16bit-performance 2018-09-19 17:54:56 +02:00
Sven Nilsen 742784ddc7 Merge branch 'master' into master 2018-09-19 15:25:24 +02:00
Felix Schütt 0089e93b49 Migrate from String to properly typed TiffUnsupportedError 2018-09-13 13:44:16 +02:00
Felix Schütt 2c6ca5459a Migrate from String to properly typed TiffFormatError 2018-09-13 13:20:50 +02:00
zroug 345aff0629 Greatly improved performance for 16 bit images 2018-08-27 23:05:16 +02:00
zroug 724e5e8c80 Fixed: Decoder::expand_strip might not read the full strip 2018-08-27 23:05:16 +02:00
zroug 583b241cef Replaced unsafe code in Decoder::read_image 2018-08-27 23:05:16 +02:00