浏览代码

LibGfx/JPEG: Accept grayscale images with an App14 segment

The adobe specification doesn't even consider JPEG images with a single
component. So let's not consider the content of the App14 segment for
grayscale images.
Lucas CHOLLET 2 年之前
父节点
当前提交
af14ed6b2e
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp

+ 3 - 1
Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp

@@ -1687,7 +1687,9 @@ static void ycck_to_rgb(JPEGLoadingContext const& context, Vector<Macroblock>& m
 
 static ErrorOr<void> handle_color_transform(JPEGLoadingContext const& context, Vector<Macroblock>& macroblocks)
 {
-    if (context.color_transform.has_value()) {
+    // Note: This is non-standard but some encoder still add the App14 segment for grayscale images.
+    //       So let's ignore the color transform value if we only have one component.
+    if (context.color_transform.has_value() && context.components.size() != 1) {
         // https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.872-201206-I!!PDF-E&type=items
         // 6.5.3 - APP14 marker segment for colour encoding