Only treat PNG_COLOR_TYPE_RGB as 565

Bug: 12145
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: I81dcce771c8492cdcf5677d3c13167a1231acfe4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445963
Reviewed-by: Heather Miller <hcm@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
(cherry picked from commit 983ae8625b05737e7528fac074030d11e225961d)
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446397
Reviewed-by: Break Glass <breakglass@skia.org>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Heather Miller <hcm@google.com>
Owners-Override: Joe Gregorio <jcgregorio@google.com>
1 file changed