diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2009-12-24 22:50:31 +0100 |
---|---|---|
committer | Wim Taymans <wim@metal.(none)> | 2009-12-24 22:50:31 +0100 |
commit | 0620797a18b3cf72a69b64d25332ef0be719f223 (patch) | |
tree | d9372946fd35414432add18292fa90d3f2e19788 | |
parent | a65240d1c148599e431bf2f0892dfaa507e73ae6 (diff) |
alpha: scale and clamp alpha to its full extend
Convert the alpha value to 0->255 when setting and to 0->256 when using as
a scaling factor. This makes sure we can reach the full opacity value of 0xff in
all cases.
-rw-r--r-- | gst/alpha/gstalpha.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c index 01bcbde8e..6aa1f8af5 100644 --- a/gst/alpha/gstalpha.c +++ b/gst/alpha/gstalpha.c @@ -212,2 +212,3 @@ gst_alpha_base_init (gpointer g_class) } + static void @@ -349,2 +350,3 @@ gst_alpha_set_property (GObject * object, guint prop_id, } + static void @@ -472,3 +474,3 @@ gst_alpha_set_ayuv (guint8 * src, guint8 * dest, gint width, gint height, { - gint b_alpha = (gint) (alpha * 255); + gint s_alpha = CLAMP ((gint) (alpha * 256), 0, 256); gint y, x; @@ -477,3 +479,3 @@ gst_alpha_set_ayuv (guint8 * src, guint8 * dest, gint width, gint height, for (x = 0; x < width; x++) { - *dest++ = (*src++ * b_alpha) >> 8; + *dest++ = (*src++ * s_alpha) >> 8; *dest++ = *src++; @@ -489,3 +491,3 @@ gst_alpha_set_i420 (guint8 * src, guint8 * dest, gint width, gint height, { - gint b_alpha = (gint) (alpha * 255); + gint b_alpha = CLAMP ((gint) (alpha * 255), 0, 255); guint8 *srcY; |