Closed weiji14 closed 4 months ago
Shouldn't there be more logic to actually handle reading/writing these types?
Shouldn't there be more logic to actually handle reading/writing these types?
I've added a couple of roundtrip tests to check reading/writing SByte and SShort TIFFs, see if that looks ok.
Btw, I looked under https://github.com/libsdl-org/libtiff/tree/v4.6.0/test/images and couldn't find any obvious example TIFF files of int8/int16 types, so I just converted the uint8/uint16 tiffs using gdal_translate
with some scaling. Happy to exchange those to better samples if needed.
Gentle ping @fintelia to see if this PR looks ok? I'm slowly refactoring the geotiff
crate downstream to rely on image-tiff's enums, and it would be nice to have this PR wrapped up so that I can continue with https://github.com/georust/geotiff/pull/15.
Support SignedByte (i8) and SignedShort (i16) types by:
tiff::decoder::ifd::Value::SignedByte
andtiff::decoder::ifd::Value::SignedShort
enum variantsTiffFormatError::SignedByteExpected
andTiffFormatError::SignedShortExpected
enum variantsinto_i8
andinto_i16
methods underimpl Value
insrc/decoder/ifd.rs
Also included two new TIFF files to test roundtrip decoding/encoding:
tests/images/minisblack-1c-i8b.tiff
gdal_translate -ot Int8 -co PIXELTYPE=SIGNEDBYTE -scale 0 255 \-128 128 tests/images/minisblack-1c-8b.tiff tests/images/minisblack-1c-i8b.tiff
tests/images/minisblack-1c-i16b.tiff
gdal_translate -ot Int16 -co PIXELTYPE=SIGNEDBYTE -scale 0 65536 \-32767 32767 tests/images/minisblack-1c-16b.tiff tests/images/minisblack-1c-i16b.tiff
References:
Addresses https://github.com/image-rs/image-tiff/issues/204#issuecomment-1708003609