Browse Source

LibGfx/TIFF: Support WhiteIsZero parameter for grayscale images

PhotometricInterpretation::WhiteIsZero is used to inverse black and
white on bilevel and grayscale images.
Lucas CHOLLET 1 year ago
parent
commit
3ae29fdeec
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

+ 5 - 1
Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

@@ -97,7 +97,11 @@ private:
         }
         }
 
 
         if (*m_metadata.samples_per_pixel() == 1) {
         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);
             return Color(luminosity, luminosity, luminosity);
         }
         }