summaryrefslogtreecommitdiff
path: root/gdk/gdkpixbuf-drawable.c
diff options
context:
space:
mode:
authorCody Russell <bratsche@src.gnome.org>1999-10-10 07:20:37 +0000
committerCody Russell <bratsche@src.gnome.org>1999-10-10 07:20:37 +0000
commita4013d86fbfe7c38f7927c0630a85a8ade53795a (patch)
tree4d0b044f07bed6caea17b4899086bf8f69853e27 /gdk/gdkpixbuf-drawable.c
parent2501ca70d64d184e3ec6893fffdba94bb2b9172e (diff)
downloadgtk+-a4013d86fbfe7c38f7927c0630a85a8ade53795a.tar.gz
Changed 'pixbuf' variable to 'art_pixbuf' in the core function.
Core function now determines whether the requested geometry is on screen or not. If part of it is not then the request is clamped to geometry that is on the screen.
Diffstat (limited to 'gdk/gdkpixbuf-drawable.c')
-rw-r--r--gdk/gdkpixbuf-drawable.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c
index 3969763303..aa7b9b1ed2 100644
--- a/gdk/gdkpixbuf-drawable.c
+++ b/gdk/gdkpixbuf-drawable.c
@@ -1,5 +1,5 @@
/*
- * creates an ArtPixBuf from a Drawable
+ * Creates an GdkPixBuf from a Drawable
*
* Author:
* Cody Russell <bratsche@dfw.net>
@@ -21,7 +21,7 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
gint with_alpha)
{
GdkImage *image;
- ArtPixBuf *pixbuf;
+ ArtPixBuf *art_pixbuf;
GdkColormap *colormap;
art_u8 *buff;
art_u8 *pixels;
@@ -30,9 +30,39 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
art_u8 r, g, b;
gint xx, yy;
gint fatness;
+ gint screen_width, screen_height;
+ gint window_width, window_height, window_x, window_y;
g_return_val_if_fail (window != NULL, NULL);
+ screen_width = gdk_screen_width();
+ screen_height = gdk_screen_height();
+ gdk_window_get_geometry(window, NULL, NULL,
+ &window_width, &window_height, NULL);
+ gdk_window_get_origin(window, &window_x, &window_y);
+
+ if(window_x < 0)
+ {
+ x = ABS(window_x);
+ width = window_width - x;
+ }
+ else
+ {
+ width = CLAMP(window_x + window_width, window_x,
+ screen_width) - window_x;
+ }
+
+ if(window_y < 0)
+ {
+ y = ABS(window_y);
+ height = window_height - y;
+ }
+ else
+ {
+ height = CLAMP(window_y + window_height, window_y,
+ screen_height) - window_y;
+ }
+
image = gdk_image_get (window, x, y, width, height);
colormap = gdk_rgb_get_cmap ();