summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2010-10-10 11:17:41 +0200
committerraveit65 <[email protected]>2018-04-08 13:15:23 +0200
commit73ca24244f1f42a5aa055aff4e0ae85f8f78816c (patch)
treebcc6f2059b81d157ec7fa92f9b05a2955aa27004 /libdocument
parent62ca1c0f5e3caf27650be9774ffd231a47da267d (diff)
downloadatril-73ca24244f1f42a5aa055aff4e0ae85f8f78816c.tar.bz2
atril-73ca24244f1f42a5aa055aff4e0ae85f8f78816c.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
Diffstat (limited to 'libdocument')
-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 *