From 9e8a594905316d14aeb55ab5ab5f50e03cb847c6 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 28 Feb 2018 16:24:18 -0500 Subject: Support pngs with incorrect CMF bytes Bug: chromium:807324 Though these pngs are technically incorrect, many such PNGs exist, and they are supported in Chromium. Ensure that users of SkCodec (e.g. Android, Flutter) display them as well. Change-Id: I2f1e573b4b7039cea81f96397cc0aa4cbc9461c3 Reviewed-on: https://skia-review.googlesource.com/111082 Commit-Queue: Leon Scroggins Reviewed-by: Derek Sollenberger --- src/codec/SkPngCodec.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/codec') diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index 9df7bc67e1..df22121b4c 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -22,6 +22,7 @@ #include "SkTemplates.h" #include "SkUtils.h" +#define PNG_SET_OPTION_SUPPORTED #include "png.h" #include @@ -787,6 +788,10 @@ static SkCodec::Result read_header(SkStream* stream, SkPngChunkReader* chunkRead return SkCodec::kInternalError; } + // This setting ensures that we display images with incorrect CMF bytes. + // See crbug.com/807324. + png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW, PNG_OPTION_ON); + AutoCleanPng autoClean(png_ptr, stream, chunkReader, outCodec); png_infop info_ptr = png_create_info_struct(png_ptr); -- cgit v1.2.3