summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-04 11:18:22 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-04 13:03:23 +0000
commitaa616abc9ab02e333cf0cad4f524b15c710bf449 (patch)
tree3d0afb0ab0942a4175bede1fac6c67fdc0c52315
parent30976635d7072c06d00e39b106e41be7b08c6c49 (diff)
[png] Use RGB for opaque images.
If the ARGB32 is opaque, discard the alpha channel - so we should generate byte identical output to the reference images.
-rw-r--r--src/cairo-png.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 06e7cb55..4721825e 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -190,7 +190,10 @@ write_png (cairo_surface_t *surface,
switch (image->format) {
case CAIRO_FORMAT_ARGB32:
depth = 8;
- png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ if (_cairo_image_analyze_transparency (image) == 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:
depth = 8;
@@ -237,12 +240,12 @@ write_png (cairo_surface_t *surface,
*/
png_write_info (png, info);
- if (image->format == CAIRO_FORMAT_ARGB32)
+ if (png_color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
png_set_write_user_transform_fn (png, unpremultiply_data);
- else if (image->format == CAIRO_FORMAT_RGB24)
+ } else if (png_color_type == PNG_COLOR_TYPE_RGB) {
png_set_write_user_transform_fn (png, convert_data_to_bytes);
- if (image->format == CAIRO_FORMAT_RGB24)
png_set_filler (png, 0, PNG_FILLER_AFTER);
+ }
png_write_image (png, rows);
png_write_end (png, info);