Only treat PNG_COLOR_TYPE_RGB as 565

Bug: 190188264
Bug: skia:5616
Test: imagedecoder_png_fuzzer
Test: Codec_PngRoundTrip

If a PNG's sBIT specifies that the significant bits are 565, SkPngCodec
treats the image as defaulting to kRGB_565_SkColorType, rather than the
typical kN32_SkColorType. This feature is likely rarely used in the
wild, but it is used by Skia to encode kRGB_565_SkColorType to a PNG and
then recreate the original SkPixmap. These Skia-created PNGs always use
PNG_COLOR_TYPE_RGB, so only respect this sBIT with PNG_COLOR_TYPE_RGB.

Further, if the PNG is PNG_COLOR_TYPE_PALETTE, treating it as 565 means
that we read it incorrectly.

Change-Id: I15d9571398870ecf67a150e46d28d4545afcf3c8
(cherry picked from commit f6de97fce5c06b0388d278f63179d7282c136e2e)
1 file changed