From fcaa719b7d563047245fc3d7f57ad5b714ddd9a4 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 1 Nov 2000 16:34:23 +0000 Subject: [PATCH] Clip the rectangle to be rendered to the drawable, since 2000-11-01 Havoc Pennington * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): Clip the rectangle to be rendered to the drawable, since get_from_drawable() requires a region within the drawable --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gdk/gdkpixbuf-render.c | 32 +++++++++++++++++++++++++++++++- 8 files changed, 73 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 433258998f..9ae227850d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 433258998f..9ae227850d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2000-11-01 Havoc Pennington + + * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): + Clip the rectangle to be rendered to the drawable, since + get_from_drawable() requires a region within the drawable + 2000-11-01 Havoc Pennington * gtk/gtkimage.c (gtk_image_expose): Um, don't randomly subtract 4 diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index 9ef7bb6f6b..cb4b9ea2bf 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -266,6 +266,8 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap = NULL; GdkGC *gc; GdkPixbuf *composited = NULL; + gint dwidth, dheight; + g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB); @@ -277,9 +279,37 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width); g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height); - if (width == 0 || height == 0) + /* Clip to the drawable; this is required for get_from_drawable() so + * can't be done implicitly + */ + + if (dest_x < 0) + { + src_x -= dest_x; + width += dest_x; + dest_x = 0; + } + + if (dest_y < 0) + { + src_y -= dest_y; + height += dest_y; + dest_y = 0; + } + + gdk_drawable_get_size (drawable, &dwidth, &dheight); + + if ((dest_x + width) > dwidth) + width = dwidth - dest_x; + + if ((dest_y + height) > dheight) + height = dheight - dest_y; + + if (width <= 0 || height <= 0) return; + /* Actually draw */ + gc = gdk_gc_new (drawable); if (pixbuf->has_alpha)