pngdec: Fix 16bit RGB images display

Due to the alpha value being inserted with _BEFORE, we were ending up
with ARGB instead of RGBA, thus displaying completely wrong colours.
According to libpng's manual, "to add an opaque alpha channel, use filler=0xff
or 0xffff and PNG_FILLER_AFTER which will generate RGBA pixels".

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4756>
This commit is contained in:
Piotr Brzeziński 2023-06-01 16:21:47 +02:00 committed by GStreamer Marge Bot
parent e4c43db5d5
commit 476d350b03

View file

@ -250,7 +250,7 @@ gst_pngdec_caps_create_and_set (GstPngDec * pngdec)
/* Add alpha channel if 16-bit depth, but not for GRAY images */ /* Add alpha channel if 16-bit depth, but not for GRAY images */
if ((bpc > 8) && (color_type != PNG_COLOR_TYPE_GRAY)) { if ((bpc > 8) && (color_type != PNG_COLOR_TYPE_GRAY)) {
png_set_add_alpha (pngdec->png, 0xffff, PNG_FILLER_BEFORE); png_set_add_alpha (pngdec->png, 0xffff, PNG_FILLER_AFTER);
png_set_swap (pngdec->png); png_set_swap (pngdec->png);
} }
#if 0 #if 0