-
Notifications
You must be signed in to change notification settings - Fork 721
Tiff: Support decoding f16 images #3015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
c4c4a13
ad1e61c
bc1a5b0
51b43c8
c802566
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,6 +126,7 @@ where | |||||||||||||
| (tiff::ColorType::Gray(1), Uint) => ColorType::L8, | ||||||||||||||
| (tiff::ColorType::Gray(8), Uint) => ColorType::L8, | ||||||||||||||
| (tiff::ColorType::Gray(16), Uint) => ColorType::L16, | ||||||||||||||
| (tiff::ColorType::Gray(16), IEEEFP) => ColorType::L32F, | ||||||||||||||
| (tiff::ColorType::Gray(32), IEEEFP) => ColorType::L32F, | ||||||||||||||
| (tiff::ColorType::GrayA(8), Uint) => ColorType::La8, | ||||||||||||||
| (tiff::ColorType::GrayA(16), Uint) => ColorType::La16, | ||||||||||||||
|
|
@@ -135,6 +136,8 @@ where | |||||||||||||
| (tiff::ColorType::RGBA(16), Uint) => ColorType::Rgba16, | ||||||||||||||
| (tiff::ColorType::CMYK(8), Uint) => ColorType::Rgb8, | ||||||||||||||
| (tiff::ColorType::CMYK(16), Uint) => ColorType::Rgb16, | ||||||||||||||
| (tiff::ColorType::CMYK(16), IEEEFP) => ColorType::Rgb32F, | ||||||||||||||
| (tiff::ColorType::RGBA(16), IEEEFP) => ColorType::Rgba32F, | ||||||||||||||
| (tiff::ColorType::RGB(32), IEEEFP) => ColorType::Rgb32F, | ||||||||||||||
| (tiff::ColorType::RGBA(32), IEEEFP) => ColorType::Rgba32F, | ||||||||||||||
| (tiff::ColorType::YCbCr(8), Uint) => ColorType::Rgb8, | ||||||||||||||
|
|
@@ -152,6 +155,9 @@ where | |||||||||||||
| (tiff::ColorType::CMYK(8), Uint) => ExtendedColorType::Cmyk8, | ||||||||||||||
| (tiff::ColorType::CMYK(16), Uint) => ExtendedColorType::Cmyk16, | ||||||||||||||
| (tiff::ColorType::YCbCr(8), Uint) => ExtendedColorType::YCbCr8, | ||||||||||||||
| (tiff::ColorType::Gray(16), IEEEFP) => ExtendedColorType::L16F, | ||||||||||||||
| (tiff::ColorType::CMYK(16), IEEEFP) => ExtendedColorType::Rgb16F, | ||||||||||||||
| (tiff::ColorType::RGBA(16), IEEEFP) => ExtendedColorType::Rgba16F, | ||||||||||||||
| _ => color_type.into(), | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -534,6 +540,18 @@ impl<R: BufRead + Seek> ImageDecoder for TiffDecoder<R> { | |||||||||||||
|
|
||||||||||||||
| ycbcr_to_rgb8(ycbcr, lr, lg, lb, out); | ||||||||||||||
| } | ||||||||||||||
| DecodingResult::F16(v) | ||||||||||||||
| if matches!( | ||||||||||||||
| info.original_color_type, | ||||||||||||||
| ExtendedColorType::L16F | ||||||||||||||
| | ExtendedColorType::Rgb16F | ||||||||||||||
| | ExtendedColorType::Rgba16F | ||||||||||||||
| ) => | ||||||||||||||
| { | ||||||||||||||
| for (half, out) in v.iter().zip(buf.as_chunks_mut::<4>().0.iter_mut()) { | ||||||||||||||
| *out = half.to_f32().to_ne_bytes(); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+535
to
+537
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a bit more intuitive:
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, unfortunately. A slice of |
||||||||||||||
| } | ||||||||||||||
| DecodingResult::U8(v) => { | ||||||||||||||
| buf.copy_from_slice(v); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.