From 76543c69699edd45e02310fdc4278f56c7a13d23 Mon Sep 17 00:00:00 2001 From: ellson Date: Thu, 23 Aug 2007 04:04:33 +0000 Subject: [PATCH] attempting to fix tranparency in -Tgif:cairo - not there yet --- plugin/gd/gvformatter_gd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } } -- 2.40.0