summaryrefslogtreecommitdiff
path: root/gdk/gdkrgb.c
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2004-08-23 05:19:52 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-08-23 05:19:52 +0000
commitec066eeef855e8b8c32303ebb5018bf6f910a7ac (patch)
tree6ac5c727a95dcfed035de363cd4e1331c1b0cc1f /gdk/gdkrgb.c
parent515c055ccdd96741d14e9767be9575d1a19b4a4d (diff)
downloadgtk+-ec066eeef855e8b8c32303ebb5018bf6f910a7ac.tar.gz
Set unused bits in pixel to 1s in case they are used as alpha; copying
Mon Aug 23 01:17:59 2004 Matthias Clasen <maclas@gmx.de> * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused bits in pixel to 1s in case they are used as alpha; copying code from gdk_colormap_alloc_colors(). (#150466, Rich Wareham)
Diffstat (limited to 'gdk/gdkrgb.c')
-rw-r--r--gdk/gdkrgb.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c
index 555cf7d1f5..4dfd315150 100644
--- a/gdk/gdkrgb.c
+++ b/gdk/gdkrgb.c
@@ -745,6 +745,8 @@ gdk_rgb_xpixel_from_rgb_internal (GdkColormap *colormap,
else if (image_info->visual->type == GDK_VISUAL_TRUE_COLOR ||
image_info->visual->type == GDK_VISUAL_DIRECT_COLOR)
{
+ guint32 unused;
+
#ifdef VERBOSE
g_print ("shift, prec: r %d %d g %d %d b %d %d\n",
image_info->visual->red_shift,
@@ -754,8 +756,15 @@ gdk_rgb_xpixel_from_rgb_internal (GdkColormap *colormap,
image_info->visual->blue_shift,
image_info->visual->blue_prec);
#endif
+ /* If bits not used for color are used for something other than padding,
+ * it's likely alpha, so we set them to 1s.
+ */
+ unused = ~ (image_info->visual->red_mask |
+ image_info->visual->green_mask |
+ image_info->visual->blue_mask |
+ (((~(guint32)0)) << image_info->visual->depth));
- pixel = (((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) +
+ pixel = (unused + ((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) +
((g >> (16 - image_info->visual->green_prec)) << image_info->visual->green_shift) +
((b >> (16 - image_info->visual->blue_prec)) << image_info->visual->blue_shift));
}