Blame 0001-Fix-some-issues-with-icon-handling.patch

39130f8
From 8ad8318ae483cae8f6a9b53245e10de428e55a63 Mon Sep 17 00:00:00 2001
39130f8
From: Matthias Clasen <mclasen@redhat.com>
39130f8
Date: Mon, 5 Apr 2010 11:31:01 -0400
39130f8
Subject: [PATCH] Fix some issues with icon handling
39130f8
39130f8
Preserve alpha channels if present in the file, and be careful
39130f8
about not passing out-of-bounds coordinates to gdk_pixbuf_new_subpixbuf()
39130f8
---
39130f8
 src/um-crop-area.c |   18 ++++++++++++++----
39130f8
 1 files changed, 14 insertions(+), 4 deletions(-)
39130f8
39130f8
diff --git a/src/um-crop-area.c b/src/um-crop-area.c
39130f8
index 2c473a1..14ba5ee 100644
39130f8
--- a/src/um-crop-area.c
39130f8
+++ b/src/um-crop-area.c
39130f8
@@ -107,8 +107,10 @@ update_pixbufs (UmCropArea *area)
39130f8
             gdk_pixbuf_get_height (area->priv->pixbuf) != allocation.height) {
39130f8
                 if (area->priv->pixbuf != NULL)
39130f8
                         g_object_unref (area->priv->pixbuf);
39130f8
-                area->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
39130f8
-                                             allocation.width, allocation.height);
39130f8
+                area->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
39130f8
+                                                     gdk_pixbuf_get_has_alpha (area->priv->browse_pixbuf),
39130f8
+                                                     8,
39130f8
+                                                     allocation.width, allocation.height);
39130f8
 
39130f8
                 color = &widget->style->bg[GTK_WIDGET_STATE (widget)];
39130f8
                 pixel = ((color->red & 0xff00) << 16) |
39130f8
@@ -800,9 +802,17 @@ um_crop_area_new (void)
39130f8
 GdkPixbuf *
39130f8
 um_crop_area_get_picture (UmCropArea *area)
39130f8
 {
39130f8
+        gint width, height;
39130f8
+
39130f8
+        width = gdk_pixbuf_get_width (area->priv->browse_pixbuf);
39130f8
+        height = gdk_pixbuf_get_height (area->priv->browse_pixbuf);
39130f8
+        width = MIN (area->priv->crop.width, width - area->priv->crop.x);
39130f8
+        height = MIN (area->priv->crop.height, height - area->priv->crop.y);
39130f8
+
39130f8
         return gdk_pixbuf_new_subpixbuf (area->priv->browse_pixbuf,
39130f8
-                                         area->priv->crop.x, area->priv->crop.y,
39130f8
-                                         area->priv->crop.width, area->priv->crop.height);
39130f8
+                                         area->priv->crop.x,
39130f8
+                                         area->priv->crop.y,
39130f8
+                                         width, height);
39130f8
 }
39130f8
 
39130f8
 void
39130f8
-- 
39130f8
1.7.0.1
39130f8