summaryrefslogtreecommitdiff
path: root/gdk/gdkpixbuf-render.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-11-01 16:34:23 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-11-01 16:34:23 +0000
commitfcaa719b7d563047245fc3d7f57ad5b714ddd9a4 (patch)
tree7c258b0f338a8c43e0cad95d1278faf9df7384ab /gdk/gdkpixbuf-render.c
parent15767742768d7d4a294cfba12dc9cad5cd302e36 (diff)
downloadgtk+-fcaa719b7d563047245fc3d7f57ad5b714ddd9a4.tar.gz
Clip the rectangle to be rendered to the drawable, since
2000-11-01 Havoc Pennington <hp@redhat.com> * 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
Diffstat (limited to 'gdk/gdkpixbuf-render.c')
-rw-r--r--gdk/gdkpixbuf-render.c32
1 files changed, 31 insertions, 1 deletions
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)