summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2005-10-25 10:23:26 +0000
committerJulien Moutte <julien@moutte.net>2005-10-25 10:23:26 +0000
commitcc0c33355e638707d01671e455f9b236f928f8cc (patch)
treed27e675cc62b0fc53c905ad3621f28dfead1c1e3
parentecc3125b2720abe199d9da2133f67827bdaaf7aa (diff)
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 <julien@moutte.net> * 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.
-rw-r--r--ChangeLog7
-rw-r--r--ext/libpng/gstpngdec.c20
2 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 83c04b67..9b40a9db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-10-25 Julien MOUTTE <julien@moutte.net>
+
+ * 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.
+
2005-10-24 Edward Hervey <edward@fluendo.com>
* ext/dv/gstdvdemux.c: (gst_dvdemux_add_pads):
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);