summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/gdk-pixbuf.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-04-18 18:09:18 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-04-18 18:09:18 +0000
commit60b6a010e931aaaf97d723c893068381a421f0a0 (patch)
tree14982e448c4281c77bdfb5cd17add1a61fe72fce /gdk-pixbuf/gdk-pixbuf.c
parentebd3958c0641d82b54f26118155e4669725900e2 (diff)
downloadgtk+-60b6a010e931aaaf97d723c893068381a421f0a0.tar.gz
fix to properly queue resizes when the image is set
2001-04-18 Havoc Pennington <hp@redhat.com> * gtk/gtkimage.c: fix to properly queue resizes when the image is set * gtk/gtktextview.c (gtk_text_view_do_popup): desensitize Paste if the insertion point isn't editable * demos/gtk-demo/images.c: Added a GtkImage demo * demos/gtk-demo/drawingarea.c: drawing area demo * demos/gtk-demo/menus.c (create_menu): cleanups 2001-04-18 Havoc Pennington <hp@redhat.com> * gdk-pixbuf.c (gdk_pixbuf_fill): Function to fill pixbuf with a given color.
Diffstat (limited to 'gdk-pixbuf/gdk-pixbuf.c')
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 2a65082d93..12b8e61441 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -409,6 +409,64 @@ gdk_pixbuf_error_quark (void)
return q;
}
+/**
+ * gdk_pixbuf_fill:
+ * @pixbuf: a #GdkPixbuf
+ * @pixel: RGBA pixel to clear to (0xffffff00 is opaque white, 0x000000ff transparent black)
+ *
+ * Clears a pixbuf to the given RGBA value, converting the RGBA value into
+ * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
+ * doesn't have an alpha channel.
+ *
+ **/
+void
+gdk_pixbuf_fill (GdkPixbuf *pixbuf,
+ guint32 pixel)
+{
+ guchar *pixels;
+ gboolean all_the_same = FALSE;
+ guint r, g, b, a;
+
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+
+ pixels = pixbuf->pixels;
+
+ r = (pixel & 0xff000000) >> 24;
+ g = (pixel & 0x00ff0000) >> 16;
+ b = (pixel & 0x0000ff00) >> 8;
+ a = (pixel & 0x000000ff);
+
+ if (r == g && g == b) {
+ if (!pixbuf->has_alpha)
+ all_the_same = TRUE;
+ else
+ all_the_same = (r == a);
+ }
+
+ if (all_the_same) {
+ memset (pixels, r,
+ pixbuf->rowstride * pixbuf->height);
+ } else {
+ guchar *p;
+ guchar *end;
+
+ /* feel free to optimize this */
+
+ p = pixels;
+ end = pixels + pixbuf->rowstride * pixbuf->height;
+ end -= (pixbuf->rowstride - pixbuf->width);
+
+ while (p < end) {
+ *p++ = r;
+ *p++ = g;
+ *p++ = b;
+ if (pixbuf->has_alpha)
+ *p++ = a;
+ }
+ }
+}
+
+
/* Include the marshallers */
#include <glib-object.h>
#include "gdk-pixbuf-marshal.c"