[cairo-commit] cairo-demo/cairo_snippets/snippets clip_image.cairo, 1.1, 1.2 curve_rectangle.cairo, 1.3, 1.4 fill_and_stroke.cairo, 1.1, 1.2 fill_and_stroke2.cairo, 1.1, 1.2 image.cairo, 1.1, 1.2 imagepattern.cairo, 1.1, 1.2 libsvg.cairo, 1.1, 1.2 text.cairo, 1.2, 1.3

Kristian Hogsberg commit at pdx.freedesktop.org
Mon May 2 19:22:50 PDT 2005


Committed by: krh

Update of /cvs/cairo/cairo-demo/cairo_snippets/snippets
In directory gabe:/tmp/cvs-serv13074/snippets

Modified Files:
	clip_image.cairo curve_rectangle.cairo fill_and_stroke.cairo 
	fill_and_stroke2.cairo image.cairo imagepattern.cairo 
	libsvg.cairo text.cairo 
Log Message:
2005-05-02  Kristian Høgsberg  <krh at redhat.com>

        * png_io.c:
        * png_io.h:
        * cairo_snippets_png.c:
        * Makefile.am: Drop custom PNG IO functions and use cairo's new
        PNG functions.

        * prepare_snippets.c:
        * snippets/clip_image.cairo:
        * snippets/curve_rectangle.cairo:
        * snippets/fill_and_stroke.cairo:
        * snippets/fill_and_stroke2.cairo:
        * snippets/image.cairo:
        * snippets/imagepattern.cairo:
        * snippets/libsvg.cairo:
        * snippets/text.cairo: Port to cairos new group semantics by using
        cairo_fill_preserve() instead of cairo_save()/cairo_restore() to
        keep the current path after filling it.  Use
        cairo_image_surface_create_from_png() to load png files.  Fix
        pointer signedness in a couple of places.



Index: clip_image.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/clip_image.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- clip_image.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ clip_image.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -1,5 +1,4 @@
-int              w,h,stride;
-char            *buffer;
+int              w, h;
 cairo_surface_t *image;
 
 snippet_normalize (cr, width, height);
@@ -8,10 +7,9 @@
 cairo_clip (cr);
 cairo_new_path (cr); /* path not consumed by clip()*/
 
-buffer = read_png_argb32 (
-              "data/romedalen.png", &w,&h, &stride);
-image  = cairo_surface_create_for_image (
-              buffer, CAIRO_FORMAT_ARGB32, w,h, stride);
+image = cairo_image_surface_create_from_png ("data/romedalen.png");
+w = cairo_image_surface_get_width (image);
+h = cairo_image_surface_get_height (image);
 
 cairo_scale (cr, 1.0/w, 1.0/h);
 
@@ -19,4 +17,3 @@
 cairo_show_surface (cr, image, w, h);
 
 cairo_surface_destroy (image);
-free (buffer);

Index: curve_rectangle.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/curve_rectangle.cairo,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- curve_rectangle.cairo	21 Apr 2005 21:05:22 -0000	1.3
+++ curve_rectangle.cairo	3 May 2005 02:22:48 -0000	1.4
@@ -50,10 +50,7 @@
 }
 cairo_close_path (cr);
 
-/* and fill/stroke it */
-cairo_save (cr);
-    cairo_set_rgb_color (cr, 0.5,0.5,1);
-    cairo_fill (cr);
-cairo_restore (cr);
+cairo_set_rgb_color (cr, 0.5,0.5,1);
+cairo_fill_preserve (cr);
 cairo_set_source_rgba (cr, 0.5, 0, 0, 0.5);
 cairo_stroke (cr);

Index: fill_and_stroke.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/fill_and_stroke.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fill_and_stroke.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ fill_and_stroke.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -4,11 +4,9 @@
 cairo_line_to (cr, 0.9, 0.9);
 cairo_rel_line_to (cr, -0.4, 0.0);
 cairo_curve_to (cr, 0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
-
-cairo_save (cr);
-    cairo_set_rgb_color (cr, 0, 0, 1);
-    cairo_fill (cr);
-cairo_restore (cr);
-
 cairo_close_path (cr);
+
+cairo_set_rgb_color (cr, 0, 0, 1);
+cairo_fill_preserve (cr);
+cairo_set_rgb_color (cr, 0, 0, 0);
 cairo_stroke (cr);

Index: fill_and_stroke2.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/fill_and_stroke2.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fill_and_stroke2.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ fill_and_stroke2.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -12,10 +12,7 @@
 cairo_rel_line_to (cr, -0.2, -0.2);
 cairo_close_path (cr);
 
-
-cairo_save (cr);
-    cairo_set_rgb_color (cr, 0, 0, 1);
-    cairo_fill (cr);
-cairo_restore (cr);
-
+cairo_set_rgb_color (cr, 0, 0, 1);
+cairo_fill_preserve (cr);
+cairo_set_rgb_color (cr, 0, 0, 0);
 cairo_stroke (cr);

Index: image.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/image.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- image.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ image.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -1,13 +1,11 @@
-int              w,h,stride;
-char            *buffer;
+int              w, h;
 cairo_surface_t *image;
 
 snippet_normalize (cr, width, height);
 
-buffer = read_png_argb32 (
-              "data/romedalen.png", &w,&h, &stride);
-image  = cairo_surface_create_for_image (
-              buffer, CAIRO_FORMAT_ARGB32, w,h, stride);
+image = cairo_image_surface_create_from_png ("data/romedalen.png");
+w = cairo_image_surface_get_width (image);
+h = cairo_image_surface_get_height (image);
 
 cairo_translate (cr, 0.5, 0.5);
 cairo_rotate (cr, 45* M_PI/180);
@@ -17,4 +15,4 @@
 cairo_move_to (cr, 0,0);
 cairo_show_surface (cr, image, w, h);
 cairo_surface_destroy (image);
-free (buffer);
+

Index: imagepattern.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/imagepattern.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- imagepattern.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ imagepattern.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -1,15 +1,13 @@
-int              w,h,stride;
-char            *buffer;
+int              w, h;
 cairo_surface_t *image;
 cairo_pattern_t *pattern;
 cairo_matrix_t  *matrix;
 
 snippet_normalize (cr, width, height);
 
-buffer = read_png_argb32 (
-              "data/romedalen.png", &w,&h, &stride);
-image  = cairo_surface_create_for_image (
-              buffer, CAIRO_FORMAT_ARGB32, w,h, stride);
+image = cairo_image_surface_create_from_png ("data/romedalen.png");
+w = cairo_image_surface_get_width (image);
+h = cairo_image_surface_get_height (image);
 
 cairo_surface_set_repeat (image, 1);
 pattern = cairo_pattern_create_for_surface (image);
@@ -31,4 +29,3 @@
 
 cairo_pattern_destroy (pattern);
 cairo_surface_destroy (image);
-free (buffer);

Index: libsvg.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/libsvg.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- libsvg.cairo	1 Feb 2005 22:58:09 -0000	1.1
+++ libsvg.cairo	3 May 2005 02:22:48 -0000	1.2
@@ -1,5 +1,5 @@
-svg_cairo_t *svgc;
-int          w, h;
+svg_cairo_t  *svgc;
+unsigned int  w, h;
 
 snippet_normalize (cr, width, height);
 

Index: text.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/snippets/text.cairo,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- text.cairo	21 Apr 2005 21:05:22 -0000	1.2
+++ text.cairo	3 May 2005 02:22:48 -0000	1.3
@@ -8,10 +8,9 @@
 
 cairo_move_to (cr, 0.27, 0.65);
 cairo_text_path (cr, "void");
-cairo_save (cr);
-    cairo_set_rgb_color (cr, 0.5,0.5,1);
-    cairo_fill (cr);
-cairo_restore (cr);
+cairo_set_rgb_color (cr, 0.5, 0.5, 1);
+cairo_fill_preserve (cr);
+cairo_set_rgb_color (cr, 0, 0, 0);
 cairo_set_line_width (cr, 0.01);
 cairo_stroke (cr);
 




More information about the cairo-commit mailing list