diff options
author | Benjamin Otte <otte@redhat.com> | 2010-02-23 21:52:45 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-04-23 23:30:08 +0200 |
commit | a3825d23c129b1945ea42653d3b7e39f82a2d6e4 (patch) | |
tree | 6d734ece3cc3ba0190854195b235b761df9a5c4f | |
parent | bf921f41abe3af37b3e0f951ccd9d5199a042068 (diff) |
png: Make code not complain about every new format
-rw-r--r-- | src/cairo-png.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/cairo-png.c b/src/cairo-png.c index b3af91f4..fe2930fb 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -172,7 +172,13 @@ write_png (cairo_surface_t *surface, /* Handle the various fallback formats (e.g. low bit-depth XServers) * by coercing them to a simpler format using pixman. */ - clone = _cairo_image_surface_coerce (image); + if (image->pixman_color_space == PIXMAN_COLOR_SPACE_ARGB && + image->format == CAIRO_FORMAT_A1) { + cairo_surface_reference (&image->base); + clone = image; + } else { + clone = _cairo_image_surface_coerce (image); + } status = clone->base.status; if (unlikely (status)) goto BAIL1; @@ -207,31 +213,29 @@ write_png (cairo_surface_t *surface, png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn); - switch (clone->format) { - case CAIRO_FORMAT_ARGB32: + switch (clone->base.content) { + case CAIRO_CONTENT_COLOR_ALPHA: depth = 8; if (_cairo_image_analyze_transparency (clone) == CAIRO_IMAGE_IS_OPAQUE) png_color_type = PNG_COLOR_TYPE_RGB; else png_color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; - case CAIRO_FORMAT_RGB24: + case CAIRO_CONTENT_COLOR: depth = 8; png_color_type = PNG_COLOR_TYPE_RGB; break; - case CAIRO_FORMAT_A8: - depth = 8; - png_color_type = PNG_COLOR_TYPE_GRAY; - break; - case CAIRO_FORMAT_A1: - depth = 1; + case CAIRO_CONTENT_ALPHA: png_color_type = PNG_COLOR_TYPE_GRAY; + if (clone->format == CAIRO_FORMAT_A1) { + depth = 1; #ifndef WORDS_BIGENDIAN - png_set_packswap (png); + png_set_packswap (png); #endif + } else { + depth = 8; + } break; - case CAIRO_FORMAT_INVALID: - case CAIRO_FORMAT_RGB16_565: default: status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT); goto BAIL4; |