From 564d64a1323c5cbcde2dd9365ac790fe8aa1c5a6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 5 Nov 2008 18:47:34 +0000 Subject: [png] Complete the idempotent read_png() -> write_png() Write out the original PNG mime-data if attached to the surface during cairo_surface_write_to_png(). Similar to how the compressed alternate representations are handled by the other backends. Note: by automatically attaching and using the mime-data in preference to the image data, we break the read_from_png(); draw(); write_to_png() cycle. --- src/cairo-png.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/cairo-png.c') diff --git a/src/cairo-png.c b/src/cairo-png.c index b4aeb0813..a130ba25d 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -148,6 +148,8 @@ write_png (cairo_surface_t *surface, png_info *info; png_byte **volatile rows = NULL; png_color_16 white; + const unsigned char *mime_data; + unsigned int mime_data_length; int png_color_type; int depth; @@ -196,6 +198,18 @@ write_png (cairo_surface_t *surface, png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn); + /* XXX This is very questionable. + * This breaks the read_from_png(); draw(); write_to_png(); cycle, but + * that is affected by mime-data in general. OTOH, by using mime-data + * here we are consistent with the other backends. + */ + cairo_surface_get_mime_data (surface, CAIRO_MIME_TYPE_PNG, + &mime_data, &mime_data_length); + if (mime_data != NULL) { + write_func (png, (png_bytep) mime_data, mime_data_length); + goto BAIL3; + } + switch (image->format) { case CAIRO_FORMAT_ARGB32: depth = 8; -- cgit v1.2.1