[cairo-commit]
cairo/test cairo-test.c, 1.19, 1.20 create-for-png.c, 1.1, 1.2
Kristian Hogsberg
commit at pdx.freedesktop.org
Mon Apr 25 20:42:56 PDT 2005
- Previous message: [cairo-commit] cairo ChangeLog,1.521,1.522
- Next message: [cairo-commit] cairo/src cairo-image-surface.c, 1.37,
1.38 cairo-png.c, 1.7, 1.8 cairo.c, 1.79, 1.80 cairo.h, 1.101, 1.102
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: krh
Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv14976/test
Modified Files:
cairo-test.c create-for-png.c
Log Message:
2005-04-25 Kristian Høgsberg <krh at redhat.com>
* src/cairo-png.c (cairo_surface_write_png): Factor out bulk of
the code into a new callback based function, write_png(). Call it
with a stdio write callback.
(cairo_surface_write_png_to_stream): New function to write a
surface to a PNG stream.
(cairo_image_surface_create_from_png): Likewise, move most of the
code to read_png(), clean up error handling and reduce this
function to calling read_png() with a stdio based read function.
(cairo_image_surface_create_from_png_stream): New function to
create an image surface from a PNG stream.
* src/cairo-image-surface.c (cairo_image_surface_get_width)
(cairo_image_surface_get_height): New functions to get widht and
height of an image surface.
* src/cairo.h: Add new prototype and error codes.
* test/create-for-png.c (draw): Adjust to new PNG API.
Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cairo-test.c 14 Apr 2005 21:42:27 -0000 1.19
+++ cairo-test.c 26 Apr 2005 03:42:54 -0000 1.20
@@ -169,9 +169,7 @@
return CAIRO_TEST_SUCCESS;
}
- png_file = fopen (png_name, "wb");
- cairo_surface_write_png (cairo_get_target_surface (cr), png_file);
- fclose (png_file);
+ cairo_surface_write_png (cairo_get_target_surface (cr), png_name);
cairo_destroy (cr);
Index: create-for-png.c
===================================================================
RCS file: /cvs/cairo/cairo/test/create-for-png.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- create-for-png.c 4 Apr 2005 16:47:12 -0000 1.1
+++ create-for-png.c 26 Apr 2005 03:42:54 -0000 1.2
@@ -44,23 +44,22 @@
char *filename;
FILE *file;
cairo_surface_t *surface;
- int surface_width, surface_height;
+ int png_width, png_height;
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
"create-for-png-ref.png");
- file = fopen (filename, "r");
- if (file == NULL) {
+
+ surface = cairo_image_surface_create_from_png (filename);
+ free (filename);
+
+ if (surface == NULL) {
fprintf (stderr, "Error: failed to open file %s\n", filename);
- free (filename);
return CAIRO_TEST_FAILURE;
}
- free (filename);
-
- surface = cairo_image_surface_create_for_png (file,
- &surface_width,
- &surface_height);
- cairo_show_surface (cr, surface, surface_width, surface_height);
+ png_width = cairo_image_surface_get_width (surface);
+ png_height = cairo_image_surface_get_height (surface);
+ cairo_show_surface (cr, surface, png_width, png_height);
cairo_surface_destroy (surface);
- Previous message: [cairo-commit] cairo ChangeLog,1.521,1.522
- Next message: [cairo-commit] cairo/src cairo-image-surface.c, 1.37,
1.38 cairo-png.c, 1.7, 1.8 cairo.c, 1.79, 1.80 cairo.h, 1.101, 1.102
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list