Parcourir la source

LibPDF: In convert_to_srgb(), also apply sRGB curve (ish)

We did convert from the input space to linear space and then
to linear sRGB, but we forgot to re-apply gamma.

This uses the x^2.2 curve instead of the real sRGB curve for now.
Nico Weber il y a 1 an
Parent
commit
a207ab709a
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 4 1
      Userland/Libraries/LibPDF/ColorSpace.cpp

+ 4 - 1
Userland/Libraries/LibPDF/ColorSpace.cpp

@@ -257,7 +257,10 @@ constexpr Array<float, 3> convert_to_srgb(Array<float, 3> xyz)
         1.0572252,
     };
 
-    return matrix_multiply(conversion_matrix, xyz);
+    auto linear_srgb = matrix_multiply(conversion_matrix, xyz);
+
+    // FIXME: Use the real sRGB curve by replacing this function with Gfx::ICC::sRGB().from_pcs().
+    return { pow(linear_srgb[0], 1.0f / 2.2f), pow(linear_srgb[1], 1.0f / 2.2f), pow(linear_srgb[2], 1.0f / 2.2f) };
 }
 
 PDFErrorOr<NonnullRefPtr<CalRGBColorSpace>> CalRGBColorSpace::create(Document* document, Vector<Value>&& parameters)