From: ellson Date: Thu, 23 Aug 2007 04:04:33 +0000 (+0000) Subject: attempting to fix tranparency in -Tgif:cairo - not there yet X-Git-Tag: LAST_LIBGRAPH~32^2~5356 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76543c69699edd45e02310fdc4278f56c7a13d23;p=graphviz attempting to fix tranparency in -Tgif:cairo - not there yet --- diff --git a/plugin/gd/gvformatter_gd.c b/plugin/gd/gvformatter_gd.c index 27575c66b..f8de542f9 100644 --- a/plugin/gd/gvformatter_gd.c +++ b/plugin/gd/gvformatter_gd.c @@ -42,7 +42,7 @@ static void cairo_surface_write_to_gd(cairo_surface_t *surface, format_type format, FILE *f) { gdImagePtr im; - unsigned int width, height, x, y, *data, color; + unsigned int width, height, x, y, *data, color, alpha; width = cairo_image_surface_get_width(surface); height = cairo_image_surface_get_height(surface); @@ -52,9 +52,12 @@ cairo_surface_write_to_gd(cairo_surface_t *surface, format_type format, FILE *f) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { color = *data++; - /* gd uses a transparency alpha instead of the more typical opacity */ /* gd's max alpha is 127 */ - color = (color & 0xffffff) | ((127 - (color >> 25)) << 24); + if ((alpha = (color >> 25) & 0x7f)) + /* gd's alpha is transparency instead of opacity */ + color = (color & 0xffffff) | ((127 - alpha) << 24); + else + color = im->transparent; gdImageSetPixel (im, x, y, color); } }