summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2010-10-10 11:17:41 +0200
committerraveit65 <[email protected]>2018-04-08 13:07:52 +0200
commit28243c0141d459ec6d637eebb4c368c29a89a603 (patch)
tree87155ed5b5cfd2511dd8c886ac07eebfdaa3bd84
parentc1a56c96b724c3cf380a61b8e95fde1839a34f54 (diff)
downloadatril-28243c0141d459ec6d637eebb4c368c29a89a603.tar.bz2
atril-28243c0141d459ec6d637eebb4c368c29a89a603.tar.xz
libdocument: Use gdk_pixbuf_get_from_surface()
....instead of our own implementation origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-0&id=91a30f4
-rw-r--r--libdocument/ev-document-misc.c66
1 files changed, 4 insertions, 62 deletions
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index 40d03400..3755f011 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -229,68 +229,10 @@ ev_document_misc_pixbuf_from_surface (cairo_surface_t *surface)
{
g_return_val_if_fail (surface, NULL);
- GdkPixbuf *pixbuf;
- cairo_surface_t *image;
- cairo_t *cr;
- gboolean has_alpha;
- gint width, height;
- cairo_format_t surface_format;
- gint pixbuf_n_channels;
- gint pixbuf_rowstride;
- guchar *pixbuf_pixels;
- gint x, y;
-
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
-
- surface_format = cairo_image_surface_get_format (surface);
- has_alpha = (surface_format == CAIRO_FORMAT_ARGB32);
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE, 8,
- width, height);
- pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
- pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf);
-
- image = cairo_image_surface_create_for_data (pixbuf_pixels,
- surface_format,
- width, height,
- pixbuf_rowstride);
- cr = cairo_create (image);
- cairo_set_source_surface (cr, surface, 0, 0);
-
- if (has_alpha)
- cairo_mask_surface (cr, surface, 0, 0);
- else
- cairo_paint (cr);
-
- cairo_destroy (cr);
- cairo_surface_destroy (image);
-
- for (y = 0; y < height; y++) {
- guchar *p = pixbuf_pixels + y * pixbuf_rowstride;
-
- for (x = 0; x < width; x++) {
- guchar tmp;
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- tmp = p[0];
- p[0] = p[2];
- p[2] = tmp;
- p[3] = (has_alpha) ? p[3] : 0xff;
-#else
- tmp = p[0];
- p[0] = p[1];
- p[1] = p[2];
- p[2] = p[3];
- p[3] = (has_alpha) ? tmp : 0xff;
-#endif
- p += pixbuf_n_channels;
- }
- }
-
- return pixbuf;
+ return gdk_pixbuf_get_from_surface (surface,
+ 0, 0,
+ cairo_image_surface_get_width (surface),
+ cairo_image_surface_get_height (surface));
}
cairo_surface_t *