[gnome-shell] Use the right conversion from cairo to GdkPixbuf



commit 9b9f33bc8be1f1a97a68d12eeeb9b85a3f36ce38
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Feb 16 03:50:28 2013 +0100

    Use the right conversion from cairo to GdkPixbuf
    
    GdkPixbuf is stored in memory as individual bytes, in strict red-green-blue-alpha
    order, while cairo image surfaces are stored as 32bits units whose
    order depends on the endianess.
    It is probably possible to do something better, taking advantage
    of cogl and the GL using the actual component order, but for now
    it is easier to use the GDK utility to convert the cairo surface.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693931

 src/shell-screenshot.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c
index 924713f..c354612 100644
--- a/src/shell-screenshot.c
+++ b/src/shell-screenshot.c
@@ -183,22 +183,19 @@ write_screenshot_thread (GSimpleAsyncResult *result,
   else
     {
       GdkPixbuf *pixbuf;
-      pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (screenshot_data->image),
-                                         GDK_COLORSPACE_RGB,
-                                         TRUE,
-                                         8,
-                                         cairo_image_surface_get_width (screenshot_data->image),
-                                         cairo_image_surface_get_height (screenshot_data->image),
-                                         cairo_image_surface_get_stride (screenshot_data->image),
-                                         NULL,
-                                         NULL);
+
+      pixbuf = gdk_pixbuf_get_from_surface (screenshot_data->image,
+                                            0, 0,
+                                            cairo_image_surface_get_width (screenshot_data->image),
+                                            cairo_image_surface_get_height (screenshot_data->image));
+
       if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
                                     "tEXt::Software", "gnome-screenshot", NULL))
         status = CAIRO_STATUS_SUCCESS;
       else
         status = CAIRO_STATUS_WRITE_ERROR;
 
-      g_clear_object (&pixbuf);
+      g_object_unref (pixbuf);
     }
 
 


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