summaryrefslogtreecommitdiff
path: root/src/cairo-png.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-05 18:47:34 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-05 18:47:34 +0000
commit564d64a1323c5cbcde2dd9365ac790fe8aa1c5a6 (patch)
treece14f37a38c8dcbfd0a79818cb9eb42f1031d4e7 /src/cairo-png.c
parentec559822cfe6df0006ca2db2aa3a11699326865c (diff)
downloadcairo-564d64a1323c5cbcde2dd9365ac790fe8aa1c5a6.tar.gz
[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.
Diffstat (limited to 'src/cairo-png.c')
-rw-r--r--src/cairo-png.c14
1 files changed, 14 insertions, 0 deletions
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;