Re: BUG: CAIRO_FORMAT_ARGB32, image_surface transparency = CAIRO_IMAGE_IS_OPAQUE after write_png()
Adrian Johnson <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On 07/06/16 15:28, [email protected] wrote: > Ok, but writing PNG shall not affect consequent writings. If we paint > later with transparent source it is not opaque anymore and then > _cairo_image_analyze_transparency() shall run again. I missed that part of the bug report. I thought the bug was about writing ARGB32 images as opaque PNG when all alpha is 255. Failing to analyze the transparency after updating the image is a bug. The attached patch should fix it. > I think it would be good idea to add some function like > cairo_surface_write_to_png_flat() which will dump image data > to PNG in the same format as surface. It also can be usefull for > debugging then user can open file in image viwer and see what data > in what format hi is actually working on. The PNG surface is a convenience for testing, debugging, and creating examples. Providing comprehensive support for image reading and writing with various options is outside the scope of cairo. There are other libraries that can perform this task. -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo
0001-image-only-cache-transparency-and-color-analysis-for.patch
(text/x-patch, 1.4 KB)
From 4899600853cebaca1aafcb59815748e7a0e99fa2 Mon Sep 17 00:00:00 2001 From: Adrian Johnson <[email protected]> Date: Tue, 7 Jun 2016 20:42:53 +0930 Subject: [PATCH] image: only cache transparency and color analysis for snapshot surfaces --- src/cairo-image-surface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 13d6272..0e4aa99 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -52,6 +52,7 @@ #include "cairo-recording-surface-private.h" #include "cairo-region-private.h" #include "cairo-scaled-font-private.h" +#include "cairo-surface-snapshot-inline.h" #include "cairo-surface-snapshot-private.h" #include "cairo-surface-subsurface-private.h" @@ -1158,7 +1159,7 @@ _cairo_image_analyze_transparency (cairo_image_surface_t *image) { int x, y; - if (image->transparency != CAIRO_IMAGE_UNKNOWN) + if (_cairo_surface_is_snapshot (&image->base) && image->transparency != CAIRO_IMAGE_UNKNOWN) return image->transparency; if ((image->base.content & CAIRO_CONTENT_ALPHA) == 0) @@ -1215,7 +1216,7 @@ _cairo_image_analyze_color (cairo_image_surface_t *image) { int x, y; - if (image->color != CAIRO_IMAGE_UNKNOWN_COLOR) + if (_cairo_surface_is_snapshot (&image->base) && image->color != CAIRO_IMAGE_UNKNOWN_COLOR) return image->color; if (image->format == CAIRO_FORMAT_A1) -- 2.1.4