minor fix for GdkPixbuf



Hi List !

attached patch issues proper cliping for
gdk_pixbuf_get_from_drawable () in
gdk_pixbuf_render_to_drawable_alpha (case ALPHA_FULL)

Regards.
--- gdkpixbuf-render.c.orig	Wed Nov  1 17:34:23 2000
+++ gdkpixbuf-render.c	Tue Jun 26 17:22:50 2001
@@ -329,7 +329,46 @@ gdk_pixbuf_render_to_drawable_alpha (Gdk
       else if (alpha_mode == GDK_PIXBUF_ALPHA_FULL)
         {
           GdkPixbuf *sub = NULL;
-          
+
+	  if (GDK_IS_WINDOW (drawable))
+	    {
+	      gint        x_origin, y_origin;
+	      static gint screen_width = -1;
+	      static gint screen_height = -1;
+
+	      if (screen_width < 0)
+	        {
+	          screen_width = gdk_screen_width ();
+	          screen_height = gdk_screen_height ();
+		}
+
+	      gdk_window_get_origin (GDK_WINDOW (drawable),
+	    			     &x_origin, &y_origin);
+
+	      if (x_origin + dest_x < 0)
+	        {
+		  width += x_origin + dest_x;
+		  src_x -= x_origin + dest_x;
+		  dest_x = - x_origin;
+		}
+
+	      if (y_origin + dest_y < 0)
+	        {
+		  height += y_origin + dest_y;
+		  src_y -= y_origin + dest_y;
+		  dest_y = - y_origin;
+		}
+
+	      if (x_origin + dest_x + width > screen_width)
+	        width = screen_width - dest_x - x_origin;
+
+	      if (y_origin + dest_y + height > screen_height)
+	        height = screen_height - dest_y - y_origin;
+
+	      if (width <= 0 || height <= 0)
+	        goto out;
+	    }
+
           composited = gdk_pixbuf_get_from_drawable (NULL,
                                                      drawable,
                                                      NULL,
@@ -377,6 +416,8 @@ gdk_pixbuf_render_to_drawable_alpha (Gdk
                                      dither,
                                      x_dither, y_dither);
     }
+
+out:
 
   if (bitmap)
     gdk_bitmap_unref (bitmap);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]