@@ -229,68 +229,10 @@ ev_document_misc_pixbuf_from_surface (cairo_surface_t *surface)
229229{
230230 g_return_val_if_fail (surface , NULL );
231231
232- GdkPixbuf * pixbuf ;
233- cairo_surface_t * image ;
234- cairo_t * cr ;
235- gboolean has_alpha ;
236- gint width , height ;
237- cairo_format_t surface_format ;
238- gint pixbuf_n_channels ;
239- gint pixbuf_rowstride ;
240- guchar * pixbuf_pixels ;
241- gint x , y ;
242-
243- width = cairo_image_surface_get_width (surface );
244- height = cairo_image_surface_get_height (surface );
245-
246- surface_format = cairo_image_surface_get_format (surface );
247- has_alpha = (surface_format == CAIRO_FORMAT_ARGB32 );
248-
249- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB ,
250- TRUE, 8 ,
251- width , height );
252- pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf );
253- pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf );
254- pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf );
255-
256- image = cairo_image_surface_create_for_data (pixbuf_pixels ,
257- surface_format ,
258- width , height ,
259- pixbuf_rowstride );
260- cr = cairo_create (image );
261- cairo_set_source_surface (cr , surface , 0 , 0 );
262-
263- if (has_alpha )
264- cairo_mask_surface (cr , surface , 0 , 0 );
265- else
266- cairo_paint (cr );
267-
268- cairo_destroy (cr );
269- cairo_surface_destroy (image );
270-
271- for (y = 0 ; y < height ; y ++ ) {
272- guchar * p = pixbuf_pixels + y * pixbuf_rowstride ;
273-
274- for (x = 0 ; x < width ; x ++ ) {
275- guchar tmp ;
276-
277- #if G_BYTE_ORDER == G_LITTLE_ENDIAN
278- tmp = p [0 ];
279- p [0 ] = p [2 ];
280- p [2 ] = tmp ;
281- p [3 ] = (has_alpha ) ? p [3 ] : 0xff ;
282- #else
283- tmp = p [0 ];
284- p [0 ] = p [1 ];
285- p [1 ] = p [2 ];
286- p [2 ] = p [3 ];
287- p [3 ] = (has_alpha ) ? tmp : 0xff ;
288- #endif
289- p += pixbuf_n_channels ;
290- }
291- }
292-
293- return pixbuf ;
232+ return gdk_pixbuf_get_from_surface (surface ,
233+ 0 , 0 ,
234+ cairo_image_surface_get_width (surface ),
235+ cairo_image_surface_get_height (surface ));
294236}
295237
296238cairo_surface_t *
0 commit comments