From 3ae29fdeec2d0b68cc082a6db8678e785792a4cb Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Fri, 1 Dec 2023 19:29:55 -0500 Subject: [PATCH] LibGfx/TIFF: Support WhiteIsZero parameter for grayscale images PhotometricInterpretation::WhiteIsZero is used to inverse black and white on bilevel and grayscale images. --- Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp index ec4ffd5cbc..ec74c37594 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp @@ -97,7 +97,11 @@ private: } if (*m_metadata.samples_per_pixel() == 1) { - auto const luminosity = TRY(read_component(stream, bits_per_sample[0])); + auto luminosity = TRY(read_component(stream, bits_per_sample[0])); + + if (m_metadata.photometric_interpretation() == PhotometricInterpretation::WhiteIsZero) + luminosity = ~luminosity; + return Color(luminosity, luminosity, luminosity); }