Re: Some small bugs
- From: Alexander Larsson <alla lysator liu se>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list gnome org
- Subject: Re: Some small bugs
- Date: Thu, 22 Feb 2001 10:17:31 +0100 (CET)
On 21 Feb 2001, Owen Taylor wrote:
>
> Alexander Larsson <alla lysator liu se> writes:
>
> > On 20 Feb 2001, Owen Taylor wrote:
> > > I think this isn't the correct fix - I believe that the problem is
> > > that there has been a incompatible change in gdk_pixmap_new_from_xpm_d()
> > > [ and friends ]; before, a no-transparency XMP gave a solid mask,
> > > now it gives a NULL mask.
> > >
> > > So, I think we need to fix that instead, since it will break a LOT
> > > of app programs as well.
> > >
> > > It should be pretty easy - something like:
> > >
> > > if (mask && !*mask)
> > > [ Create solid mask ]
> > >
> >
> > How about this one then? It changes gdk_pixmap_create_from_xpm_d,
> > gdk_pixmap_colormap_create_from_xpm_d, gdk_pixmap_create_from_xpm and
> > gdk_pixmap_colormap_create_from_xpm,
> >
> > gdk_pixmap_colormap_new_from_pixbuf is *not* changed, since it's a new
> > API call which don't have backwards compatibility demands, and I think
> > NULL mask for no alpha is a more logical behaviour.
>
> gdk_pixmap_colormap_new_from_pixbuf() isn't an API call - it's an
> internal static function used to simplify the code. The API call for
> creating a pixmap from a pixbuf is:
> gdk_pixbuf_render_pixmap_and_mask().
>
> So, I think it makes sense to put the mask-filling code in
> there instead of duplicating it. The whole point of
> gdk_pixmap_colormap_new_from_pixbuf was to avoid duplication of
> code!
Doh!
/ Alex
Index: gdkpixmap.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpixmap.c,v
retrieving revision 1.37
diff -u -p -r1.37 gdkpixmap.c
--- gdkpixmap.c 2000/12/15 01:46:39 1.37
+++ gdkpixmap.c 2001/02/22 09:11:17
@@ -430,6 +430,25 @@ gdk_pixmap_get_image (GdkDrawable *d
x, y, width, height);
}
+static GdkBitmap *
+make_solid_mask(gint width, gint height)
+{
+ GdkBitmap *bitmap;
+ GdkGC *gc;
+ GdkGCValues gc_values;
+
+ bitmap = gdk_pixmap_new (NULL, width, height, 1);
+
+ gc_values.foreground.pixel = 1;
+ gc = gdk_gc_new_with_values (bitmap, &gc_values, GDK_GC_FOREGROUND);
+
+ gdk_draw_rectangle (bitmap, gc, TRUE, 0, 0, width, height);
+
+ gdk_gc_unref (gc);
+
+ return bitmap;
+}
+
#define PACKED_COLOR(c) ((((c)->red & 0xff) << 8) | ((c)->green & 0xff) | ((c)->blue >> 8))
static GdkPixmap *
@@ -473,6 +492,10 @@ gdk_pixmap_colormap_new_from_pixbuf (Gdk
if (mask)
gdk_pixbuf_render_pixmap_and_mask (pixbuf, NULL, mask, 128);
+ if (mask && !*mask)
+ *mask = make_solid_mask (gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+
return pixmap;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]