diff src/graph_engine_cairo.c @ 602:ac2e6468a22a openvg

Replace mbe_image_surface_create_from_png() with mbe_pattern_create_image()
author Thinker K.F. Li <thinker@branda.to>
date Fri, 02 Jul 2010 13:42:22 +0800
parents b42d69ab8857
children 7b4e80ab671a
line wrap: on
line diff
--- a/src/graph_engine_cairo.c	Fri Jul 02 11:59:17 2010 +0800
+++ b/src/graph_engine_cairo.c	Fri Jul 02 13:42:22 2010 +0800
@@ -153,6 +153,45 @@
     return ptn;
 }
 
+mbe_pattern_t *
+mbe_pattern_create_image(mb_img_data_t *img) {
+    cairo_surface_t *surf;
+    cairo_pattern_t *ptn;
+    cairo_format_t fmt;
+
+    switch(img->fmt) {
+    case MB_IFMT_ARGB32:
+	fmt = CAIRO_FORMAT_ARGB32;
+	break;
+	
+    case MB_IFMT_RGB24:
+	fmt = CAIRO_FORMAT_RGB24;
+	break;
+	
+    case MB_IFMT_A8:
+	fmt = CAIRO_FORMAT_A8;
+	break;
+	
+    case MB_IFMT_A1:
+	fmt = CAIRO_FORMAT_A1;
+	break;
+	
+    case MB_IFMT_RGB16_565:
+	fmt = CAIRO_FORMAT_RGB16_565;
+	break;
+	
+    default:
+	return NULL;
+    }
+    
+    surf = cairo_image_surface_create_for_data(img->content, fmt,
+					       img->w, img->h, img->stride);
+    ptn = cairo_pattern_create_for_surface(surf);
+    cairo_surface_destroy(surf);
+    
+    return ptn;
+}
+
 void
 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) {
     area_t *area;