summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
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
parentebd3958c0641d82b54f26118155e4669725900e2 (diff)
downloadgdk-pixbuf-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')
-rw-r--r--gdk-pixbuf/ChangeLog5
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c58
-rw-r--r--gdk-pixbuf/gdk-pixbuf.h3
3 files changed, 66 insertions, 0 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index a3ebb8f28..59eb2f350 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,8 @@
+2001-04-18 Havoc Pennington <hp@redhat.com>
+
+ * gdk-pixbuf.c (gdk_pixbuf_fill): Function to fill pixbuf with a
+ given color.
+
Wed Apr 4 01:41:02 2001 Tim Janik <timj@gtk.org>
* pixops/Makefile.am (noinst_LTLIBRARIES): include $top_srcdir
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 2a65082d9..12b8e6144 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"
diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h
index dd40abbe4..b8b5a03af 100644
--- a/gdk-pixbuf/gdk-pixbuf.h
+++ b/gdk-pixbuf/gdk-pixbuf.h
@@ -145,6 +145,9 @@ GdkPixbuf *gdk_pixbuf_new_from_inline (const guchar *inline_pixbuf,
int length,
GError **error);
+/* Mutations */
+void gdk_pixbuf_fill (GdkPixbuf *pixbuf,
+ guint32 pixel);
/* Saving */