From cc0c33355e638707d01671e455f9b236f928f8cc Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Tue, 25 Oct 2005 10:23:26 +0000 Subject: ext/libpng/gstpngdec.c: Temporary hack to get correct colors order when we have a png image with alpha channel. Original commit message from CVS: 2005-10-25 Julien MOUTTE * ext/libpng/gstpngdec.c: (user_info_callback), (gst_pngdec_caps_create_and_set), (gst_pngdec_task): Temporary hack to get correct colors order when we have a png image with alpha channel. --- ext/libpng/gstpngdec.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'ext/libpng') diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index aa537a3f..35515723 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -175,7 +175,7 @@ user_info_callback (png_structp png_ptr, png_infop info) { GstPngDec *pngdec = NULL; GstFlowReturn ret = GST_FLOW_OK; - gint bpc = 0; + gint bpc = 0, color_type; png_uint_32 width, height; size_t buffer_size; GstBuffer *buffer = NULL; @@ -193,6 +193,13 @@ user_info_callback (png_structp png_ptr, png_infop info) png_set_strip_16 (pngdec->png); } + /* Get Color type */ + color_type = png_get_color_type (pngdec->png, pngdec->info); + + /* HACK: The doc states that it's RGBA but apparently it's not... */ + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr (pngdec->png); + /* Update the info structure */ png_read_update_info (pngdec->png, pngdec->info); @@ -340,7 +347,7 @@ gst_pngdec_caps_create_and_set (GstPngDec * pngdec) ret = GST_FLOW_ERROR; } - GST_LOG ("our caps %s", gst_caps_to_string (res)); + GST_DEBUG_OBJECT (pngdec, "our caps %" GST_PTR_FORMAT, res); gst_caps_unref (res); @@ -354,7 +361,7 @@ gst_pngdec_task (GstPad * pad) GstPngDec *pngdec; GstBuffer *buffer = NULL; size_t buffer_size = 0; - gint i = 0, bpc = 0; + gint i = 0, bpc = 0, color_type; png_bytep *rows, inp; png_uint_32 width, height, rowbytes; GstFlowReturn ret = GST_FLOW_OK; @@ -382,6 +389,13 @@ gst_pngdec_task (GstPad * pad) png_set_strip_16 (pngdec->png); } + /* Get Color type */ + color_type = png_get_color_type (pngdec->png, pngdec->info); + + /* HACK: The doc states that it's RGBA but apparently it's not... */ + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr (pngdec->png); + /* Update the info structure */ png_read_update_info (pngdec->png, pngdec->info); -- cgit