diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-03-12 01:05:25 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-03-12 01:40:59 -0400 |
commit | f02a649a3ce5735f5a20103fe6f1002b3a421501 (patch) | |
tree | e75bdc2f7cacd8ab92be8cc9c1be3fb39874b23c /clients/screenshot.c | |
parent | bcacef19b032d1162120c4a48412bb62b90ad61c (diff) | |
download | weston-f02a649a3ce5735f5a20103fe6f1002b3a421501.tar.gz |
Consolidate image loading code and move to shared/
Diffstat (limited to 'clients/screenshot.c')
-rw-r--r-- | clients/screenshot.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/clients/screenshot.c b/clients/screenshot.c index 51f32805..8b1edf6e 100644 --- a/clients/screenshot.c +++ b/clients/screenshot.c @@ -27,8 +27,7 @@ #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> -#include <glib.h> -#include <gdk-pixbuf/gdk-pixbuf.h> +#include <cairo.h> #include <wayland-client.h> #include "screenshooter-client-protocol.h" @@ -129,18 +128,13 @@ create_shm_buffer(int width, int height, void **data_out) static void write_png(int width, int height, void *data) { - GdkPixbuf *pixbuf, *normal; - GError *error = NULL; - - g_type_init(); - pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, - 8, width, height, width * 4, NULL, - NULL); - - normal = gdk_pixbuf_flip(pixbuf, FALSE); - gdk_pixbuf_save(normal, "wayland-screenshot.png", "png", &error, NULL); - g_object_unref(normal); - g_object_unref(pixbuf); + cairo_surface_t *surface; + + surface = cairo_image_surface_create_for_data(data, + CAIRO_FORMAT_ARGB32, + width, height, width * 4); + cairo_surface_write_to_png(surface, "wayland-screenshot.png"); + cairo_surface_destroy(surface); } int main(int argc, char *argv[]) |