[dia] Bug #591525 - Transparent objects by adding alpha to Color structure



commit b8994a3489256de6baaabaf09a7cf69f39390353
Author: Jason Childs <oblivian users sourceforge net>
Date:   Tue Aug 11 23:55:20 2009 -0400

    Bug #591525 - Transparent objects by adding alpha to Color structure
    
    From: Jason Childs <oblivian users sourceforge net>
    Date: Tue, 11 Aug 2009 23:55:20 -0400
    Subject: [PATCH] Color transparency support
    
    Add alpha to Color structure to support transparency. This change tries
    to be a uninstrusive as possible, any and all references to Color have
    either been upgraded to read/write the new alpha parameter or they
    default to 1.0 to retain the existing functionality.
    If the plugin/importer/exporter does not support transparency, it will
    render the same as before.  The cairo renderer has been updated to use
    alpha and the dia file format has been extended to understand both the
    new alpha value and support older files that don't have alpha for color
    values.

 app/color_area.c                        |   17 +++++++-
 app/connectionpoint_ops.c               |    2 +-
 app/handle_ops.c                        |   24 +++++-----
 app/preferences.h                       |    4 +-
 app/render_gdk.c                        |    6 +-
 bindings/dia-properties.cpp             |    4 +-
 bindings/dia.swig                       |    1 +
 lib/arrows.c                            |    2 +-
 lib/attributes.c                        |    4 +-
 lib/bezier_conn.c                       |    2 +-
 lib/beziershape.c                       |    2 +-
 lib/color.c                             |   29 +++++++++++--
 lib/color.h                             |    9 +++-
 lib/dia_svg.c                           |   13 ++++-
 lib/dia_xml.c                           |   13 ++++-
 lib/diasvgrenderer.c                    |    9 ++--
 lib/layer.c                             |    1 +
 lib/libdia.def                          |    1 +
 lib/prop_attr.c                         |    1 +
 lib/widgets.c                           |   69 ++++++++++++++++++++++--------
 objects/Database/compound.c             |    2 +-
 objects/FS/flow-ortho.c                 |    8 ++--
 objects/FS/flow.c                       |    6 +-
 objects/GRAFCET/action.c                |    2 +-
 objects/GRAFCET/step.c                  |    2 +-
 objects/KAOS/metabinrel.c               |    2 +-
 objects/Misc/analog_clock.c             |    2 +
 objects/Misc/grid_object.c              |    1 +
 objects/SADT/annotation.c               |    1 +
 objects/SISSI/area.c                    |    2 +-
 objects/SISSI/faraday.c                 |    2 +-
 objects/SISSI/room.c                    |    2 +-
 objects/SISSI/site.c                    |    2 +-
 objects/chronogram/chronoline.c         |    2 +
 objects/custom/custom_object.c          |    7 ++-
 objects/custom_lines/line_info.c        |    3 +
 objects/network/network.c               |    2 +-
 plug-ins/cairo/diacairo-interactive.c   |    6 +-
 plug-ins/cairo/diacairo-renderer.c      |   27 ++++++------
 plug-ins/cgm/cgm.c                      |   24 ++++++++---
 plug-ins/drs/dia-render-script-import.c |    1 +
 plug-ins/dxf/dxf-import.c               |   18 +++++---
 plug-ins/libart/dialibartrenderer.c     |    6 +-
 plug-ins/libart/render_libart.c         |    6 +-
 plug-ins/python/diasvg_import.py        |    6 ++-
 plug-ins/python/pydia-color.c           |    7 ++-
 plug-ins/python/pydia-property.c        |    2 +
 plug-ins/svg/svg-import.c               |    1 +
 plug-ins/vdx/vdx-export.c               |    6 +-
 plug-ins/vdx/vdx-import.c               |    7 +++-
 plug-ins/wpg/wpg.c                      |    2 +-
 plug-ins/xfig/xfig-common.c             |   16 ++++----
 plug-ins/xfig/xfig-import.c             |    4 ++
 53 files changed, 268 insertions(+), 132 deletions(-)
---
diff --git a/app/color_area.c b/app/color_area.c
index 1dc2d52..a0050c2 100644
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -220,6 +220,7 @@ color_selection_ok (GtkWidget               *w,
 {
   GtkColorSelection *colorsel;
   GdkColor color;
+  guint alpha;
   Color col;
 
   colorsel=GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(cs));
@@ -227,6 +228,9 @@ color_selection_ok (GtkWidget               *w,
   gtk_color_selection_get_current_color(colorsel,&color);
   GDK_COLOR_TO_DIA(color, col);
 
+  alpha = gtk_color_selection_get_current_alpha(colorsel);
+  col.alpha = alpha / 65535.0;
+
   if (edit_color == FOREGROUND) {
     attributes_set_foreground(&col);
   } else {
@@ -277,6 +281,7 @@ color_selection_changed (GtkWidget *w,
 {
   GtkColorSelection *colorsel;
   GdkColor color;
+  guint alpha;
   Color col;
 
   colorsel=GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(cs));
@@ -284,6 +289,10 @@ color_selection_changed (GtkWidget *w,
   gtk_color_selection_get_current_color(colorsel,&color);
   GDK_COLOR_TO_DIA(color, col);
 
+  alpha = gtk_color_selection_get_current_alpha(colorsel);
+  printf ("col.alpha = %f, alpha = %u\n", col.alpha, alpha);
+  col.alpha = alpha / 65535.0;
+
   if (edit_color == FOREGROUND) {
     attributes_set_foreground(&col);
   } else {
@@ -318,6 +327,9 @@ color_area_edit (void)
 				     _("Select foreground color"):
 				     _("Select background color"));
     color_select_active = 1;
+    gtk_color_selection_set_has_opacity_control(
+        GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
+        TRUE);
 
     gtk_color_selection_set_has_palette (
 	GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (
@@ -371,7 +383,10 @@ color_area_edit (void)
 	GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (
 				GTK_COLOR_SELECTION_DIALOG (color_select))),
 	&color);
-
+  printf ("col.alpha = %f\n", col.alpha);
+  gtk_color_selection_set_current_alpha(
+        GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color_select)->colorsel),
+        (guint)(col.alpha * 65535.0));
 }
 
 static gint
diff --git a/app/connectionpoint_ops.c b/app/connectionpoint_ops.c
index 83f033b..9deeb89 100644
--- a/app/connectionpoint_ops.c
+++ b/app/connectionpoint_ops.c
@@ -25,7 +25,7 @@
 #include "object.h"
 #include "connectionpoint.h"
 
-static Color connectionpoint_color = { 0.4, 0.4, 1.0 };
+static Color connectionpoint_color = { 0.4, 0.4, 1.0, 1.0 };
 
 #define CP_SZ (CONNECTIONPOINT_SIZE/2)
 
diff --git a/app/handle_ops.c b/app/handle_ops.c
index 439105f..e546f56 100644
--- a/app/handle_ops.c
+++ b/app/handle_ops.c
@@ -26,24 +26,24 @@
 
 static const Color handle_color[NUM_HANDLE_TYPES<<1] =
 {
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.0, 1.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 1.0, 0.6, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.0, 1.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 1.0, 0.6, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
   /* dim down the color if the handle is in a group of selected objects */
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.0, 0.7, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 0.7, 0.4, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.0, 0.7, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 0.7, 0.4, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
 };
 
 static const Color handle_color_connected[NUM_HANDLE_TYPES<<1] =
 {
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 1.0, 0.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 1.0, 0.4, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 1.0, 0.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 1.0, 0.4, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
   /* dim down the color if the handle is in a group of selected objects */
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.7, 0.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 0.7, 0.3, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.7, 0.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 0.7, 0.3, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
 };
 
 void
diff --git a/app/preferences.h b/app/preferences.h
index e2ef6d3..b9497d8 100644
--- a/app/preferences.h
+++ b/app/preferences.h
@@ -21,8 +21,8 @@
 #include "diatypes.h"
 #include "diagramdata.h"
 
-#define DEFAULT_GRID_COLOR { 0.85, .90, .90 }
-#define DEFAULT_PAGEBREAK_COLOR { 0.0, 0.0, 0.6 }
+#define DEFAULT_GRID_COLOR { 0.85, .90, .90, 1.0 }
+#define DEFAULT_PAGEBREAK_COLOR { 0.0, 0.0, 0.6, 1.0 }
 
 struct DiaPreferences {
   struct {
diff --git a/app/render_gdk.c b/app/render_gdk.c
index 50c7393..ddd7143 100644
--- a/app/render_gdk.c
+++ b/app/render_gdk.c
@@ -30,11 +30,11 @@
 
 
 /** Used for highlighting mainpoint connections. */
-static Color cp_main_color = { 1.0, 0.8, 0.0 };
+static Color cp_main_color = { 1.0, 0.8, 0.0, 1.0 };
 /** Used for highlighting normal connections. */
-static Color cp_color = { 1.0, 0.0, 0.0 };
+static Color cp_color = { 1.0, 0.0, 0.0, 1.0 };
 
-static Color text_edit_color = {1.0, 1.0, 0.0 };
+static Color text_edit_color = {1.0, 1.0, 0.0, 1.0 };
 
 
 static void clip_region_clear(DiaRenderer *renderer);
diff --git a/bindings/dia-properties.cpp b/bindings/dia-properties.cpp
index fdfc0b8..77e2521 100644
--- a/bindings/dia-properties.cpp
+++ b/bindings/dia-properties.cpp
@@ -234,6 +234,7 @@ set_prop (::Property* p, const char* v)
             ((ColorProperty*)p)->color_data.red = color.red / 65535.0; 
             ((ColorProperty*)p)->color_data.green = color.green / 65535.0; 
             ((ColorProperty*)p)->color_data.blue = color.blue / 65535.0;
+            ((ColorProperty*)p)->color_data.alpha = 1.0;
         }
     }
     else if (strcmp (p->descr->type, PROP_TYPE_STRING) == 0) {
@@ -370,10 +371,11 @@ dia::Properties::setitem (const char* s, const std::vector<double>& v)
     ::Property *p = object_prop_by_name (object, s);
     if (p) {
         bool apply = true;
-        if (strcmp (p->descr->type, PROP_TYPE_COLOUR) == 0 && v.size() == 3) {
+        if (strcmp (p->descr->type, PROP_TYPE_COLOUR) == 0 && v.size() == 4) {
             ((ColorProperty*)p)->color_data.red   = v[0]; 
             ((ColorProperty*)p)->color_data.green = v[1]; 
             ((ColorProperty*)p)->color_data.blue  = v[2];
+            ((ColorProperty*)p)->color_data.alpha = v[3];
 	}
 	else if (strcmp (p->descr->type, PROP_TYPE_LINESTYLE) == 0 && v.size() == 2) {
 	    ((LinestyleProperty *)p)->style = (::LineStyle)(int)v[0];
diff --git a/bindings/dia.swig b/bindings/dia.swig
index 42450f1..66207f5 100755
--- a/bindings/dia.swig
+++ b/bindings/dia.swig
@@ -104,6 +104,7 @@ struct _Color
    float red;
    float green;
    float blue;
+   float alpha;
 };
 
 #if 0 /* works for vc7.1, but not with vc6 and *not* for const char* ? 
diff --git a/lib/arrows.c b/lib/arrows.c
index dc8a1d3..dfd2aa6 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -2024,7 +2024,7 @@ arrow_draw(DiaRenderer *renderer, ArrowType type,
     Arrow arrow = {type, length, width};
     Rectangle bbox = {0, };
     Point p1, p2;
-    Color col = {1.0, 0.0, 1.0};
+    Color col = { 1.0, 0.0, 1.0, 1.0 };
     
     arrow_bbox (&arrow, linewidth, to, from, &bbox);
 
diff --git a/lib/attributes.c b/lib/attributes.c
index 72d37f7..7a44ae3 100644
--- a/lib/attributes.c
+++ b/lib/attributes.c
@@ -21,8 +21,8 @@
 #include "intl.h"
 #include "persistence.h"
 
-static Color attributes_foreground = { 0.0f, 0.0f, 0.0f };
-static Color attributes_background = { 1.0f, 1.0f, 1.0f };
+static Color attributes_foreground = { 0.0f, 0.0f, 0.0f, 1.0f };
+static Color attributes_background = { 1.0f, 1.0f, 1.0f, 1.0f };
 
 static real attributes_default_linewidth = 0.1;
 
diff --git a/lib/bezier_conn.c b/lib/bezier_conn.c
index 6b7501c..d41307c 100644
--- a/lib/bezier_conn.c
+++ b/lib/bezier_conn.c
@@ -745,7 +745,7 @@ bezierconn_simple_draw(BezierConn *bez, DiaRenderer *renderer, real width)
 void
 bezierconn_draw_control_lines(BezierConn *bez, DiaRenderer *renderer)
 {
-  Color line_colour = {0.0, 0.0, 0.6};
+  Color line_colour = { 0.0, 0.0, 0.6, 1.0 };
   Point startpoint;
   int i;
   
diff --git a/lib/beziershape.c b/lib/beziershape.c
index 2129a85..6ef4a17 100644
--- a/lib/beziershape.c
+++ b/lib/beziershape.c
@@ -721,7 +721,7 @@ beziershape_update_boundingbox(BezierShape *bezier)
 void
 beziershape_draw_control_lines(BezierShape *bez, DiaRenderer *renderer)
 {
-  Color line_colour = {0.0, 0.0, 0.6};
+  Color line_colour = { 0.0, 0.0, 0.6, 1.0 };
   Point startpoint;
   int i;
   
diff --git a/lib/color.c b/lib/color.c
index 838a219..ac26af8 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -29,8 +29,8 @@
 static GdkColormap *colormap = NULL;
 
 #ifndef G_OS_WIN32 
-Color color_black = { 0.0f, 0.0f, 0.0f };
-Color color_white = { 1.0f, 1.0f, 1.0f };
+Color color_black = { 0.0f, 0.0f, 0.0f, 1.0f };
+Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
 #endif
 
 GdkColor color_gdk_black, color_gdk_white;
@@ -54,18 +54,38 @@ color_init(void)
 }
 
 /** Allocate a new color object wtih the given values.
+ * Initializes alpha component to 1.0
  * @param r Red component (0 <= r <= 1)
  * @param g Green component (0 <= g <= 1)
  * @param b Blue component (0 <= b <= 1)
  * @returns A newly allocated color object.  This should be freed after use.
  */
 Color *
-color_new_rgb(float r, float g, float b) 
+color_new_rgb(float r, float g, float b)
 {
   Color *col = g_new(Color, 1);
   col->red = r;
   col->green = g;
   col->blue = b;
+  col->alpha = 1.0;
+  return col;
+}
+
+/** Allocate a new color object wtih the given values.
+ * @param r Red component (0 <= r <= 1)
+ * @param g Green component (0 <= g <= 1)
+ * @param b Blue component (0 <= b <= 1)
+ * @param alpha Alpha component (0 <= alpha <= 1)
+ * @returns A newly allocated color object.  This should be freed after use.
+ */
+Color *
+color_new_rgba(float r, float g, float b, float alpha)
+{
+  Color *col = g_new(Color, 1);
+  col->red = r;
+  col->green = g;
+  col->blue = b;
+  col->alpha = alpha;
   return col;
 }
 
@@ -98,5 +118,6 @@ color_equals(Color *color1, Color *color2)
 {
   return (color1->red == color2->red) &&
     (color1->green == color2->green) &&
-    (color1->blue == color2->blue);
+    (color1->blue == color2->blue) &&
+    (color1->alpha == color2->alpha);
 }
diff --git a/lib/color.h b/lib/color.h
index ff3f432..c0a50f9 100644
--- a/lib/color.h
+++ b/lib/color.h
@@ -29,16 +29,18 @@ struct _Color {
   float red;
   float green;
   float blue;
+  float alpha;
 };
 
 void color_init(void);
 Color *color_new_rgb(float r, float g, float b);
+Color *color_new_rgba(float r, float g, float b, float alpha);
 void color_convert(Color *color, GdkColor *gdkcolor);
 gboolean color_equals(Color *color1, Color *color2);
 
 #ifdef G_OS_WIN32
-static Color color_black = { 0.0f, 0.0f, 0.0f };
-static Color color_white = { 1.0f, 1.0f, 1.0f };
+static Color color_black = { 0.0f, 0.0f, 0.0f, 1.0f };
+static Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
 #else
 DIAVAR Color color_black, color_white;
 #endif
@@ -52,6 +54,7 @@ DIAVAR GdkColor color_gdk_black, color_gdk_white;
 #define GDK_COLOR_TO_DIA(from, to) \
 (to).red = (from).red/65535.0; \
 (to).green = (from).green/65535.0; \
-(to).blue = (from).blue/65535.0;
+(to).blue = (from).blue/65535.0; \
+(to).alpha = 1.0;
 
 #endif /* COLOR_H */
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index a214113..4a10c9e 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -101,7 +101,14 @@ _parse_color(gint32 *color, const char *str)
   else if (0 == strncmp(str, "rgb(", 4)) {
     int r = 0, g = 0, b = 0;
     if (3 == sscanf (str+4, "%d,%d,%d", &r, &g, &b))
-      *color = ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
+      /* Set alpha to 1.0 */
+      *color = ((0xFF<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
+    else
+      return FALSE;
+  } else if (0 == strncmp(str, "rgba(", 5)) {
+    int r = 0, g = 0, b = 0, a = 0;
+    if (4 == sscanf (str+4, "%d,%d,%d,%d", &r, &g, &b, &a))
+      *color = ((a<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
     else
       return FALSE;
   } else {
@@ -111,7 +118,7 @@ _parse_color(gint32 *color, const char *str)
 
     if (!se) {
       if (pango_color_parse (&pc, str))
-	*color = ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
+	*color = ((0xFF<<24) & 0xFF000000) | ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
       else
 	return FALSE;
     } else {
@@ -119,7 +126,7 @@ _parse_color(gint32 *color, const char *str)
       gboolean ret = pango_color_parse (&pc, str);
 
       if (ret)
-	*color = ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
+	*color = ((0xFF<<24) & 0xFF000000) | ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
       g_free (sz);
       return ret;
     }
diff --git a/lib/dia_xml.c b/lib/dia_xml.c
index d7859a1..2b34511 100644
--- a/lib/dia_xml.c
+++ b/lib/dia_xml.c
@@ -568,7 +568,7 @@ void
 data_color(DataNode data, Color *col)
 {
   xmlChar *val;
-  int r=0, g=0, b=0;
+  int r=0, g=0, b=0, a=0;
   
   if (data_type(data)!=DATATYPE_COLOR) {
     message_error("Taking color value of non-color node.");
@@ -584,6 +584,11 @@ data_color(DataNode data, Color *col)
     r = hex_digit(val[1])*16 + hex_digit(val[2]);
     g = hex_digit(val[3])*16 + hex_digit(val[4]);
     b = hex_digit(val[5])*16 + hex_digit(val[6]);
+    if (xmlStrlen(val) >= 9) {
+      a = hex_digit(val[7])*16 + hex_digit(val[8]);
+    } else {
+      a = 0xff;
+    }
   }
 
   if (val) xmlFree(val);
@@ -591,6 +596,7 @@ data_color(DataNode data, Color *col)
   col->red = (float)(r/255.0);
   col->green = (float)(g/255.0);
   col->blue = (float)(b/255.0);
+  col->alpha = (float)(a/255.0);
 }
 
 /** Return the value of a point-type data node.
@@ -1026,14 +1032,15 @@ convert_to_hex(float x, char *str)
 void
 data_add_color(AttributeNode attr, const Color *col)
 {
-  char buffer[1+6+1];
+  char buffer[1+8+1];
   DataNode data_node;
 
   buffer[0] = '#';
   convert_to_hex(col->red, &buffer[1]);
   convert_to_hex(col->green, &buffer[3]);
   convert_to_hex(col->blue, &buffer[5]);
-  buffer[7] = 0;
+  convert_to_hex(col->alpha, &buffer[7]);
+  buffer[9] = 0;
 
   data_node = xmlNewChild(attr, NULL, (const xmlChar *)"color", NULL);
   xmlSetProp(data_node, (const xmlChar *)"val", (xmlChar *)buffer);
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index 068a6ad..ed2d315 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -227,7 +227,7 @@ get_draw_style(DiaSvgRenderer *renderer,
   g_string_truncate(str, 0);
 
   /* TODO(CHECK): the shape-export didn't have 'fill: none' here */
-  g_string_printf(str, "fill: none; fill-opacity:0; stroke-width: %s", dia_svg_dtostr(linewidth_buf, renderer->linewidth) );
+  g_string_printf(str, "fill: none; fill-opacity: %f; stroke-width: %s", colour->alpha, dia_svg_dtostr(linewidth_buf, renderer->linewidth) );
   if (strcmp(renderer->linecap, "butt"))
     g_string_append_printf(str, "; stroke-linecap: %s", renderer->linecap);
   if (strcmp(renderer->linejoin, "miter"))
@@ -253,10 +253,9 @@ get_fill_style(DiaSvgRenderer *renderer,
 
   if (!str) str = g_string_new(NULL);
 
-  g_string_printf(str, "fill: #%02x%02x%02x",
-		   (int)(255*colour->red), 
-		   (int)(255*colour->green),
-		   (int)(255*colour->blue));
+  g_string_printf(str, "fill: #%02x%02x%02x; fill-opacity: %f",
+		   (int)(255*colour->red), (int)(255*colour->green),
+		   (int)(255*colour->blue), colour->alpha);
 
   return str->str;
 }
diff --git a/lib/layer.c b/lib/layer.c
index 8cecf6e..8b74463 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -83,6 +83,7 @@ layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
 	col.red = 1.0;
 	col.green = 0.0;
 	col.blue = 1.0;
+	col.alpha = 1.0;
 
         DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer,0.01);
 	DIA_RENDERER_GET_CLASS(renderer)->draw_rect(renderer, &p1, &p2, &col);
diff --git a/lib/libdia.def b/lib/libdia.def
index c9d058e..1ce40ff 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -85,6 +85,7 @@ EXPORTS
  color_equals
  color_init
  color_new_rgb
+ color_new_rgba
 
  composite_add_attribute
  composite_find_attribute
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index df6c7d7..9fb83d6 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -278,6 +278,7 @@ colorprop_new(const PropDescription *pdesc, PropDescToPropPredicate reason)
   prop->color_data.red = 0.0;
   prop->color_data.green = 0.0;
   prop->color_data.blue = 1.0;
+  prop->color_data.alpha = 1.0;
   return prop;
 }
 
diff --git a/lib/widgets.c b/lib/widgets.c
index 71b4dd1..dc2745c 100644
--- a/lib/widgets.c
+++ b/lib/widgets.c
@@ -526,21 +526,26 @@ static GtkWidget *
 dia_color_selector_create_string_item(DiaDynamicMenu *ddm, gchar *string)
 {
   GtkWidget *item = gtk_menu_item_new_with_label(string);
-  gint r, g, b;
-  sscanf(string, "#%2x%2x%2x", &r, &g, &b);
+  gint r, g, b, a;
+  gchar *markup;
   
+  sscanf(string, "#%2x%2x%2x%2x", &r, &g, &b, &a);
+
+  markup = g_strdup_printf("#%02X%02X%02X", r, g, b);
+
   /* See http://web.umr.edu/~rhall/commentary/color_readability.htm for
    * explanation of this formula */
   if (r*299+g*587+b*114 > 500 * 256) {
-    gchar *label = g_strdup_printf("<span foreground=\"black\" background=\"%s\">%s</span>", string, string);
+    gchar *label = g_strdup_printf("<span foreground=\"black\" background=\"%s\">%s</span>", markup, string);
     gtk_label_set_markup(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item))), label);
     g_free(label);
   } else {
-    gchar *label = g_strdup_printf("<span foreground=\"white\" background=\"%s\">%s</span>", string, string);
+    gchar *label = g_strdup_printf("<span foreground=\"white\" background=\"%s\">%s</span>", markup, string);
     gtk_label_set_markup(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item))), label);
     g_free(label);
   }
   
+  g_free(markup);
   return item;
 }
 
@@ -550,6 +555,7 @@ dia_color_selector_more_ok(GtkWidget *ok, gpointer userdata)
   DiaDynamicMenu *ddm = g_object_get_data(G_OBJECT(userdata), "ddm");
   GtkWidget *colorsel = GTK_WIDGET(userdata);
   GdkColor gcol;
+  guint galpha;
   gchar *entry;
 
   gtk_color_selection_get_current_color(
@@ -557,7 +563,11 @@ dia_color_selector_more_ok(GtkWidget *ok, gpointer userdata)
 	    GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel),
 	&gcol);
 
-  entry = g_strdup_printf("#%02X%02X%02X", gcol.red/256, gcol.green/256, gcol.blue/256);
+  galpha = gtk_color_selection_get_current_alpha(
+        GTK_COLOR_SELECTION(
+            GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel));
+
+  entry = g_strdup_printf("#%02X%02X%02X%02X", gcol.red/256, gcol.green/256, gcol.blue/256, galpha/256);
   dia_dynamic_menu_select_entry(ddm, entry);
   g_free(entry);
 
@@ -575,6 +585,8 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
   gchar *old_color = dia_dynamic_menu_get_entry(ddm);
   GtkWidget *parent;
 
+  gtk_color_selection_set_has_opacity_control(colorsel, TRUE);
+
   /* Force history to the old place */
   dia_dynamic_menu_select_entry(ddm, old_color);
 
@@ -596,6 +608,7 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
          tmplist != NULL || advance; 
          tmplist = g_list_next(tmplist)) {
       const gchar* spec;
+      guint r, g, b, a, old_a;
       GdkColor color;
 
       /* handle both lists */
@@ -605,8 +618,20 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
         if (!tmplist)
           break;
       }
-      spec = (gchar *)tmplist->data;
 
+      if (sscanf((gchar *)tmplist->data,"#%02X%02X%02X%02X", &r, &g, &b, &a) != 4) {
+        /* We don't have alpha, default to 1.0 */
+        a = 65535;
+      } else {
+        a = (guint)((((float)a) / 255.0) * 65535.0);
+      }
+      if (sscanf(old_color,"#%02X%02X%02X%02X", &r, &g, &b, &old_a) != 4) {
+        /* We don't have alpha, default to 1.0 */
+        old_a = 65535;
+      } else {
+        old_a = (guint)((((float)old_a) / 255.0) * 65535.0);
+      }
+      spec = g_strndup((gchar *)tmplist->data, 7);
       gdk_color_parse (spec, &color);
 #if 0
       /* the easy way if the Gtk Team would decide to make it public */
@@ -615,11 +640,14 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
       g_string_append (palette, spec);
       g_string_append (palette, ":");
 #endif
-      if (0 == strcmp (spec, old_color)) {
+      if (0 == strcmp ((gchar *)tmplist->data, old_color) && a == old_a) {
         gtk_color_selection_set_previous_color (colorsel, &color);
         gtk_color_selection_set_current_color (colorsel, &color);
+        gtk_color_selection_set_previous_alpha (colorsel, a);
+        gtk_color_selection_set_current_alpha (colorsel, a);
       }
       index++;
+      g_free(spec);
     }
   }
 
@@ -648,15 +676,15 @@ dia_color_selector_new ()
 					GTK_MENU_ITEM(otheritem),
 					"color-menu");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#000000");
+				     "#000000FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#FFFFFF");
+				     "#FFFFFFFF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#FF0000");
+				     "#FF0000FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#00FF00");
+				     "#00FF00FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#0000FF");
+				     "#0000FFFF");
   g_signal_connect(G_OBJECT(otheritem), "activate",
 		   G_CALLBACK(dia_color_selector_more_callback), ddm);
   gtk_widget_show(otheritem);
@@ -668,32 +696,35 @@ void
 dia_color_selector_get_color(GtkWidget *widget, Color *color)
 {
   gchar *entry = dia_dynamic_menu_get_entry(DIA_DYNAMIC_MENU(widget));
-  gint r, g, b;
+  gint r, g, b, a;
 
-  sscanf(entry, "#%2x%2x%2x", &r, &g, &b);
+  sscanf(entry, "#%2x%2x%2x%2x", &r, &g, &b, &a);
   g_free(entry);
   color->red = r / 255.0;
   color->green = g / 255.0;
   color->blue = b / 255.0;
+  color->alpha = a / 255.0;
 }
 
 void
 dia_color_selector_set_color (GtkWidget *widget,
 			      const Color *color)
 {
-  gint red, green, blue;
+  gint red, green, blue, alpha;
   gchar *entry;
   red = color->red * 255;
   green = color->green * 255;
   blue = color->blue * 255;
-  if (color->red > 1.0 || color->green > 1.0 || color->blue > 1.0) {
-    printf("Color out of range: r %f, g %f, b %f\n",
-	   color->red, color->green, color->blue);
+  alpha = color->alpha * 255;
+  if (color->red > 1.0 || color->green > 1.0 || color->blue > 1.0 || color->alpha > 1.0) {
+    printf("Color out of range: r %f, g %f, b %f, a %f\n",
+	   color->red, color->green, color->blue, color->alpha);
     red = MIN(red, 255);
     green = MIN(green, 255);
     blue = MIN(blue, 255);
+    alpha = MIN(alpha, 255);
   }
-  entry = g_strdup_printf("#%02X%02X%02X", red, green, blue);
+  entry = g_strdup_printf("#%02X%02X%02X%02X", red, green, blue, alpha);
   dia_dynamic_menu_select_entry(DIA_DYNAMIC_MENU(widget), entry);
   g_free (entry);
 }
diff --git a/objects/Database/compound.c b/objects/Database/compound.c
index ec4e93b..42e5ee4 100644
--- a/objects/Database/compound.c
+++ b/objects/Database/compound.c
@@ -563,7 +563,7 @@ compound_draw (Compound * comp, DiaRenderer * renderer)
 #if DEBUG_DRAW_MP_DIRECTION
  {
    Point p = comp->mount_point.pos;
-   Color red = {1.0, 0.0, 0.0};
+   Color red = { 1.0, 0.0, 0.0, 1.0 };
    gchar dirs = comp->mount_point.directions;
    if (dirs & DIR_NORTH)
      p.y -= 1.0;
diff --git a/objects/FS/flow-ortho.c b/objects/FS/flow-ortho.c
index 2b842aa..cb96f0d 100644
--- a/objects/FS/flow-ortho.c
+++ b/objects/FS/flow-ortho.c
@@ -78,11 +78,11 @@ struct _OrthflowChange {
   char*				text ;
 };
 
-Color orthflow_color_energy   = { 1.0f, 0.0f, 0.0f };
-Color orthflow_color_material = { 0.8f, 0.0f, 0.8f };
-Color orthflow_color_signal   = { 0.0f, 0.0f, 1.0f };
+Color orthflow_color_energy   = { 1.0f, 0.0f, 0.0f, 1.0f };
+Color orthflow_color_material = { 0.8f, 0.0f, 0.8f, 1.0f };
+Color orthflow_color_signal   = { 0.0f, 0.0f, 1.0f, 1.0f };
+
 
-  
 #define ORTHFLOW_WIDTH 0.1
 #define ORTHFLOW_MATERIAL_WIDTH 0.2
 #define ORTHFLOW_DASHLEN 0.4
diff --git a/objects/FS/flow.c b/objects/FS/flow.c
index 074e392..23c4b69 100644
--- a/objects/FS/flow.c
+++ b/objects/FS/flow.c
@@ -40,9 +40,9 @@
 
 #include "pixmaps/flow.xpm"
 
-Color flow_color_energy   = { 1.0f, 0.0f, 0.0f };
-Color flow_color_material = { 0.8f, 0.0f, 0.8f };
-Color flow_color_signal   = { 0.0f, 0.0f, 1.0f };
+Color flow_color_energy   = { 1.0f, 0.0f, 0.0f, 1.0f };
+Color flow_color_material = { 0.8f, 0.0f, 0.8f, 1.0f };
+Color flow_color_signal   = { 0.0f, 0.0f, 1.0f, 1.0f };
 
 typedef struct _Flow Flow;
 typedef enum {
diff --git a/objects/GRAFCET/action.c b/objects/GRAFCET/action.c
index 2e8582b..5c89623 100644
--- a/objects/GRAFCET/action.c
+++ b/objects/GRAFCET/action.c
@@ -385,7 +385,7 @@ action_draw(Action *action, DiaRenderer *renderer)
     renderer_ops->draw_line(renderer,&p1,&p2,&color_black);
   }
 
-  cl.red = 1.0; cl.blue = cl.green = .2; 
+  cl.red = 1.0; cl.blue = cl.green = .2; cl.alpha = 1.0;
   renderer_ops->draw_rect(renderer,&ul,&br,&color_black);
 }
 
diff --git a/objects/GRAFCET/step.c b/objects/GRAFCET/step.c
index c14629e..39aa64d 100644
--- a/objects/GRAFCET/step.c
+++ b/objects/GRAFCET/step.c
@@ -244,7 +244,7 @@ static void step_been_renamed(const gchar *sid)
   if (*endptr == '\0') __stepnum = snum + 1; 
 }
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 static real
 step_distance_from(Step *step, Point *point)
diff --git a/objects/KAOS/metabinrel.c b/objects/KAOS/metabinrel.c
index c88acdc..a8bce30 100644
--- a/objects/KAOS/metabinrel.c
+++ b/objects/KAOS/metabinrel.c
@@ -91,7 +91,7 @@ struct _Mbr {
 
 #define MBR_DEC_SIZE 1.0
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 static DiaFont *mbr_font = NULL;
 
diff --git a/objects/Misc/analog_clock.c b/objects/Misc/analog_clock.c
index 27284a9..7e59c34 100644
--- a/objects/Misc/analog_clock.c
+++ b/objects/Misc/analog_clock.c
@@ -408,10 +408,12 @@ analog_clock_create(Point *startpoint,
   analog_clock->arrow_color.red = 0.0;
   analog_clock->arrow_color.green = 0.0;
   analog_clock->arrow_color.blue = 0.5;
+  analog_clock->arrow_color.alpha = 1.0;
   analog_clock->arrow_line_width = attributes_get_default_linewidth();
   analog_clock->sec_arrow_color.red = 1.0;
   analog_clock->sec_arrow_color.green = 0.0;
   analog_clock->sec_arrow_color.blue = 0.0;
+  analog_clock->sec_arrow_color.alpha = 1.0;
   analog_clock->sec_arrow_line_width = attributes_get_default_linewidth()/3;
   analog_clock->show_ticks = TRUE;
 
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index e34e63f..b6203a8 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -388,6 +388,7 @@ grid_object_create(Point *startpoint,
   grid_object->gridline_color.red = 0.5;
   grid_object->gridline_color.green = 0.5;
   grid_object->gridline_color.blue = 0.5;
+  grid_object->gridline_color.alpha = 1.0;
   grid_object->gridline_width = attributes_get_default_linewidth();
 
   for (i = 0; i < 9; ++i)
diff --git a/objects/SADT/annotation.c b/objects/SADT/annotation.c
index 355ec81..62f18fe 100644
--- a/objects/SADT/annotation.c
+++ b/objects/SADT/annotation.c
@@ -131,6 +131,7 @@ handle_btn1(Annotation *annotation, Property *prop) {
   col.red = g_random_double();
   col.green = g_random_double();
   col.blue = g_random_double();
+  col.alpha = 1.0;
   annotation->attrs.color = col;
   text_set_attributes(annotation->text,&annotation->attrs);
   /* g_message("end of handle_btn1 for object %p col=%.2f:%.2f:%.2f",
diff --git a/objects/SISSI/area.c b/objects/SISSI/area.c
index f082c0e..5aefa76 100644
--- a/objects/SISSI/area.c
+++ b/objects/SISSI/area.c
@@ -65,7 +65,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_gris_clear = { 0.95f, 0.95f, 0.95f };
+static Color color_gris_clear = { 0.95f, 0.95f, 0.95f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/faraday.c b/objects/SISSI/faraday.c
index ad85c8d..be5eef3 100644
--- a/objects/SISSI/faraday.c
+++ b/objects/SISSI/faraday.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/room.c b/objects/SISSI/room.c
index 7ba7511..01e6d68 100644
--- a/objects/SISSI/room.c
+++ b/objects/SISSI/room.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_gris = { 0.5f, 0.5f, 0.5f };
+static Color color_gris = { 0.5f, 0.5f, 0.5f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/site.c b/objects/SISSI/site.c
index cad894b..582ca55 100644
--- a/objects/SISSI/site.c
+++ b/objects/SISSI/site.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_green_clear = { 0.87, 0.98f, 0.91 };
+static Color color_green_clear = { 0.87, 0.98f, 0.91, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/chronogram/chronoline.c b/objects/chronogram/chronoline.c
index c032385..cb72e06 100644
--- a/objects/chronogram/chronoline.c
+++ b/objects/chronogram/chronoline.c
@@ -478,6 +478,7 @@ inline static void grayify(Color *col,Color *src)
   col->red = .5 * (src->red + color_white.red);
   col->green = .5 * (src->green + color_white.green);
   col->blue = .5 * (src->blue + color_white.blue);
+  col->alpha = .5 * (src->alpha + color_white.alpha);
 }
 
 static void
@@ -634,6 +635,7 @@ chronoline_create(Point *startpoint,
   chronoline->data_color.red = 1.0;
   chronoline->data_color.green = 0.0;
   chronoline->data_color.blue = 0.0;
+  chronoline->data_color.alpha = 1.0;
   chronoline->multibit = FALSE;
   
   chronoline->evtlist = NULL;
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 77d39e0..061f83a 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -833,9 +833,10 @@ get_colour(Custom *custom, Color *colour, gint32 c)
     *colour = custom->text->color;
     break;
   default:
-    colour->red   = ((c & 0xff0000) >> 16) / 255.0;
-    colour->green = ((c & 0x00ff00) >> 8) / 255.0;
-    colour->blue  =  (c & 0x0000ff) / 255.0;
+    colour->alpha = ((c & 0xff000000) >> 24) / 255.0;
+    colour->red   = ((c & 0x00ff0000) >> 16) / 255.0;
+    colour->green = ((c & 0x0000ff00) >> 8) / 255.0;
+    colour->blue  =  (c & 0x000000ff) / 255.0;
     break;
   }
 }
diff --git a/objects/custom_lines/line_info.c b/objects/custom_lines/line_info.c
index 2949e75..5341ea4 100644
--- a/objects/custom_lines/line_info.c
+++ b/objects/custom_lines/line_info.c
@@ -260,6 +260,7 @@ line_info_get_line_color( const gchar* filename, xmlNodePtr node, LineInfo* info
     else if (/*node->ns == shape_ns &&*/ !strcmp((char*)child_node->name, "blue"))
       info->line_color.blue = line_info_get_as_float(filename, child_node);
   }
+  info->line_color.alpha = 1.0;
 }
 
 LineInfo* line_info_load_and_apply_from_xmlfile(const gchar *filename, LineInfo* info);
@@ -276,6 +277,7 @@ LineInfo* line_info_load(const gchar *filename)
   res->line_color.red   = 0.0f;
   res->line_color.green = 0.0f;
   res->line_color.blue  = 0.0f;
+  res->line_color.alpha = 1.0f;
   res->line_style = LINESTYLE_SOLID;
   res->dashlength = 1.0f;
   res->line_width = 0.1f;
@@ -301,6 +303,7 @@ LineInfo* line_info_clone(LineInfo* info)
   res->line_color.red     = info->line_color.red;
   res->line_color.green   = info->line_color.green;
   res->line_color.blue    = info->line_color.blue;
+  res->line_color.alpha   = info->line_color.alpha;
   res->line_style 	  = info->line_style;
   res->dashlength 	  = info->dashlength;
   res->line_width 	  = info->line_width;
diff --git a/objects/network/network.c b/objects/network/network.c
index 072b3de..64ea5c8 100644
--- a/objects/network/network.c
+++ b/objects/network/network.c
@@ -27,7 +27,7 @@
 #include "network.h"
 #include "plug-ins.h"
 
-Color computer_color = { 0.7, 0.7, 0.7 };
+Color computer_color = { 0.7, 0.7, 0.7, 1.0 };
 
 extern DiaObjectType bus_type;
 extern DiaObjectType bus_type_std;
diff --git a/plug-ins/cairo/diacairo-interactive.c b/plug-ins/cairo/diacairo-interactive.c
index 63f17c4..907aba1 100644
--- a/plug-ins/cairo/diacairo-interactive.c
+++ b/plug-ins/cairo/diacairo-interactive.c
@@ -536,7 +536,7 @@ draw_pixel_line(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_move_to (renderer->cr, x1u, y1u);
   cairo_line_to (renderer->cr, x2u, y2u);
   cairo_stroke (renderer->cr);
@@ -559,7 +559,7 @@ draw_pixel_rect(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
   cairo_stroke (renderer->cr);
 }
@@ -592,7 +592,7 @@ fill_pixel_rect(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
   cairo_fill (renderer->cr);
 #endif
diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 53b3188..c3a5d7a 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -100,7 +100,7 @@ begin_render(DiaRenderer *self)
                              renderer->dia->bg_color.red, 
                              renderer->dia->bg_color.green, 
                              renderer->dia->bg_color.blue,
-                             0.0);
+                             renderer->dia->bg_color.alpha);
     }
   else
     {
@@ -119,7 +119,7 @@ begin_render(DiaRenderer *self)
                              renderer->dia->bg_color.red, 
                              renderer->dia->bg_color.green, 
                              renderer->dia->bg_color.blue,
-                             1.0);
+                             renderer->dia->bg_color.alpha);
     }
 #ifdef HAVE_PANGOCAIRO_H
   if (!renderer->layout)
@@ -332,6 +332,7 @@ set_dashlength(DiaRenderer *self, real length)
 static void
 set_fillstyle(DiaRenderer *self, FillStyle mode)
 {
+  DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
   DIAG_NOTE(g_message("set_fillstyle %d", mode));
 
   switch(mode) {
@@ -397,7 +398,7 @@ draw_line(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_line %f,%f -> %f, %f", 
             start->x, start->y, end->x, end->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_move_to (renderer->cr, start->x, start->y);
   cairo_line_to (renderer->cr, end->x, end->y);
   if (!renderer->stroke_pending)
@@ -418,7 +419,7 @@ draw_polyline(DiaRenderer *self,
 
   g_return_if_fail(1 < num_points);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   /* point data */
@@ -446,7 +447,7 @@ _polygon(DiaRenderer *self,
 
   g_return_if_fail(1 < num_points);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   /* point data */
@@ -492,7 +493,7 @@ _rect(DiaRenderer *self,
             fill ? "fill" : "draw",
             ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
   cairo_rectangle (renderer->cr, 
                    ul_corner->x, ul_corner->y, 
@@ -535,7 +536,7 @@ draw_arc(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_arc %fx%f <%f,<%f", 
             width, height, angle1, angle2));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   if (!renderer->stroke_pending)
     cairo_new_path (renderer->cr);
@@ -570,7 +571,7 @@ fill_arc(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_arc %fx%f <%f,<%f", 
             width, height, angle1, angle2));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
   cairo_new_path (renderer->cr);
   start.x = center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle1);
@@ -601,7 +602,7 @@ _ellipse(DiaRenderer *self,
   DIAG_NOTE(g_message("%s_ellipse %fx%f center @ %f,%f", 
             fill ? "fill" : "draw", width, height, center->x, center->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
   cairo_save (renderer->cr);
   /* don't create a line from the current point to the beginning 
@@ -651,7 +652,7 @@ _bezier(DiaRenderer *self,
   DIAG_NOTE(g_message("%s_bezier n:%d %fx%f ...", 
             fill ? "fill" : "draw", numpoints, points->p1.x, points->p1.y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   for (i = 0; i < numpoints; i++)
@@ -714,7 +715,7 @@ draw_string(DiaRenderer *self,
 
   if (len < 1) return; /* shouldn't this be handled by Dia's core ? */
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 #ifdef HAVE_PANGOCAIRO_H
   cairo_save (renderer->cr);
   /* alignment calculation done by pangocairo? */
@@ -744,7 +745,7 @@ draw_string(DiaRenderer *self,
   {
     cairo_text_extents_t extents;
     double x = 0, y = 0;
-    cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+    cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
     cairo_text_extents (renderer->cr,
                         text,
                         &extents);
@@ -902,7 +903,7 @@ _rounded_rect (DiaRenderer *self,
             fill ? "fill" : "draw",
             topleft->x, topleft->y, bottomright->x, bottomright->y, radius));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   cairo_move_to (renderer->cr, /* north-west */
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index e0d2b78..5c9bf3c 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -319,6 +319,7 @@ init_attributes( CgmRenderer *renderer )
     renderer->lcurrent.color.red   = 0;
     renderer->lcurrent.color.green = 0;
     renderer->lcurrent.color.blue  = 0;
+    renderer->lcurrent.color.alpha = 1.0;
 
     renderer->linfile.cap    = -1;
     renderer->linfile.join   = -1;
@@ -327,12 +328,14 @@ init_attributes( CgmRenderer *renderer )
     renderer->linfile.color.red   = -1;
     renderer->linfile.color.green = -1;
     renderer->linfile.color.blue  = -1;
+    renderer->linfile.color.alpha = 1.0;
 
     /* fill/edge defaults */
     renderer->fcurrent.fill_style = 1;          /* solid */
     renderer->fcurrent.fill_color.red = 0;
     renderer->fcurrent.fill_color.green = 0;
     renderer->fcurrent.fill_color.blue = 0;
+    renderer->fcurrent.fill_color.alpha = 1.0;
 
     renderer->fcurrent.edgevis = 0;
     renderer->fcurrent.cap   = 3;            /* round */
@@ -342,11 +345,13 @@ init_attributes( CgmRenderer *renderer )
     renderer->fcurrent.color.red   = 0;
     renderer->fcurrent.color.green = 0;
     renderer->fcurrent.color.blue  = 0;
-   
+    renderer->fcurrent.color.alpha = 1.0;
+
     renderer->finfile.fill_style = -1;
     renderer->finfile.fill_color.red = -1;
     renderer->finfile.fill_color.green = -1;
     renderer->finfile.fill_color.blue = -1;
+    renderer->finfile.fill_color.alpha = 1.0;
 
     renderer->finfile.edgevis = -1;
     renderer->finfile.cap   = -1;            
@@ -356,19 +361,22 @@ init_attributes( CgmRenderer *renderer )
     renderer->finfile.color.red   = -1.0;
     renderer->finfile.color.green = -1.0;
     renderer->finfile.color.blue  = -1.0;
+    renderer->finfile.color.alpha = 1.0;
 
     renderer->tcurrent.font_num    = 1;
     renderer->tcurrent.font_height = 0.1;
     renderer->tcurrent.color.red   = 0.0;
     renderer->tcurrent.color.green = 0.0;
     renderer->tcurrent.color.blue  = 0.0;
+    renderer->tcurrent.color.alpha = 1.0;
 
     renderer->tinfile.font_num    = -1;
     renderer->tinfile.font_height = -1.0;
     renderer->tinfile.color.red   = -1.0;
     renderer->tinfile.color.green = -1.0;
     renderer->tinfile.color.blue  = -1.0;
-   
+    renderer->tinfile.color.alpha = 1.0;
+
 }
     
 
@@ -417,7 +425,8 @@ LineAttrCGM    *lnew, *lold;
     lnew->color = *color;
     if ( lnew->color.red != lold->color.red ||
          lnew->color.green != lold->color.green ||
-         lnew->color.blue != lold->color.blue )
+         lnew->color.blue != lold->color.blue ||
+         lnew->color.alpha != lold->color.alpha)
     {
         write_elhead(renderer->file, 5, 4, 3); /* line colour */
         write_colour(renderer->file, &lnew->color);
@@ -498,7 +507,8 @@ FillEdgeAttrCGM    *fnew, *fold;
         fnew->color = *edge_color;
         if ( fnew->color.red != fold->color.red ||
              fnew->color.green != fold->color.green ||
-             fnew->color.blue != fold->color.blue )
+             fnew->color.blue != fold->color.blue ||
+             fnew->color.alpha != fold->color.alpha)
         {
             write_elhead(renderer->file, 5, 29, 3); /* line colour */
             write_colour(renderer->file, &fnew->color);
@@ -529,7 +539,8 @@ FillEdgeAttrCGM    *fnew, *fold;
         fnew->fill_color = *fill_color;
         if ( fnew->fill_color.red != fold->fill_color.red ||
              fnew->fill_color.green != fold->fill_color.green ||
-             fnew->fill_color.blue != fold->fill_color.blue )
+             fnew->fill_color.blue != fold->fill_color.blue ||
+             fnew->fill_color.alpha != fold->fill_color.alpha)
         {
             write_elhead(renderer->file, 5, 23, 3);   /* fill colour */
             write_colour(renderer->file, &fnew->fill_color);
@@ -578,7 +589,8 @@ TextAttrCGM    *tnew, *told;
     tnew->color = *text_color;
     if ( tnew->color.red != told->color.red ||
          tnew->color.green != told->color.green ||
-         tnew->color.blue != told->color.blue )
+         tnew->color.blue != told->color.blue ||
+         tnew->color.alpha != told->color.alpha)
     {
         write_elhead(renderer->file, 5, 14, 3);   /* text colour */
         write_colour(renderer->file, &tnew->color);
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index 5a6fc0e..76993ab 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -130,6 +130,7 @@ _parse_color (xmlNodePtr node, const char *attrib)
       val->red = color.red / 65535.0; 
       val->green = color.green / 65535.0; 
       val->blue = color.blue / 65535.0;
+      val->alpha = 1.0;
     }
     xmlFree(str);
   }
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index 28f6b7f..be7ecf4 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -158,7 +158,7 @@ read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *line_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
     RGB_t color;
     GPtrArray *props;
     PointProperty *ptprop;
@@ -203,6 +203,7 @@ read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	    line_colour.red = color.r / 255.0;
 	    line_colour.green = color.g / 255.0;
 	    line_colour.blue = color.b / 255.0;
+	    line_colour.alpha = 1.0;
             break;
         }	
     } while(data->code != 0);
@@ -262,7 +263,7 @@ read_entity_solid_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
    DiaObject *polygon_obj;
    MultipointCreateData *pcd;
 
-   Color fill_colour = { 0.5, 0.5, 0.5 };
+   Color fill_colour = { 0.5, 0.5, 0.5, 1.0 };
 
    GPtrArray *props;
    LinestyleProperty *lsprop;
@@ -332,6 +333,7 @@ read_entity_solid_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	    fill_colour.red = color.r / 255.0;
 	    fill_colour.green = color.g / 255.0;
 	    fill_colour.blue = color.b / 255.0;
+	    fill_colour.alpha = 1.0;
             break;
         }	
     } while(data->code != 0);
@@ -414,7 +416,7 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     DiaObject *polyline_obj;
     MultipointCreateData *pcd;
 
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     GPtrArray *props;
     LinestyleProperty *lsprop;
@@ -491,6 +493,7 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
                 line_colour.red = color.r / 255.0;
                 line_colour.green = color.g / 255.0;
                 line_colour.blue = color.b / 255.0;
+                line_colour.alpha = 1.0;
                 break;
             case 70:
                 closed = 1 & atoi( data->value );
@@ -636,7 +639,7 @@ DiaObject *read_entity_circle_dxf(FILE *filedxf, DxfData *data, DiagramData *dia
     Handle *h1, *h2;
     
     DiaObject *ellipse_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     PointProperty *ptprop;
     RealProperty *rprop;
@@ -724,7 +727,7 @@ DiaObject *read_entity_arc_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
   
     DiaObject *arc_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     ColorProperty *cprop;
     PointProperty *ptprop;
@@ -818,7 +821,7 @@ read_entity_ellipse_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *ellipse_obj; 
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
     PointProperty *ptprop;
     RealProperty *rprop;
     BoolProperty *bprop;
@@ -906,7 +909,7 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *text_obj;
-    Color text_colour = { 0.0, 0.0, 0.0 };
+    Color text_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     TextProperty *tprop;
     GPtrArray *props;
@@ -964,6 +967,7 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	   text_colour.red = color.r / 255.0;
 	   text_colour.green = color.g / 255.0;
 	   text_colour.blue = color.b / 255.0;
+	   text_colour.alpha = 1.0;
             break;
         case 72: 
 	   switch(atoi(data->value))
diff --git a/plug-ins/libart/dialibartrenderer.c b/plug-ins/libart/dialibartrenderer.c
index f5ea7ab..cbf2009 100644
--- a/plug-ins/libart/dialibartrenderer.c
+++ b/plug-ins/libart/dialibartrenderer.c
@@ -66,7 +66,7 @@ color_to_abgr(Color *col)
 {
   int rgba;
 
-  rgba = 0x0;
+  rgba = (guint)(0xFF*col->alpha) << 24;
   rgba |= (guint)(0xFF*col->blue) << 16;
   rgba |= (guint)(0xFF*col->green) << 8;
   rgba |= (guint)(0xFF*col->red);
@@ -80,12 +80,12 @@ color_to_rgba(DiaLibartRenderer *renderer, Color *col)
   int rgba;
 
   if (renderer->highlight_color != NULL) {
-      rgba = 0xFF;
+      rgba = (guint)(0xFF*renderer->highlight_color->alpha);
       rgba |= (guint)(0xFF*renderer->highlight_color->red) << 24;
       rgba |= (guint)(0xFF*renderer->highlight_color->green) << 16;
       rgba |= (guint)(0xFF*renderer->highlight_color->blue) << 8;
   } else {
-    rgba = 0xFF;
+    rgba = (guint)(0xFF*col->alpha);
     rgba |= (guint)(0xFF*col->red) << 24;
     rgba |= (guint)(0xFF*col->green) << 16;
     rgba |= (guint)(0xFF*col->blue) << 8;
diff --git a/plug-ins/libart/render_libart.c b/plug-ins/libart/render_libart.c
index 8a3be2e..db54e1f 100644
--- a/plug-ins/libart/render_libart.c
+++ b/plug-ins/libart/render_libart.c
@@ -33,11 +33,11 @@
 #include "color.h"
 
 /** Used for highlighting mainpoint connections. */
-static Color cp_main_color = { 1.0, 0.8, 0.0 };
+static Color cp_main_color = { 1.0, 0.8, 0.0, 1.0 };
 /** Used for highlighting normal connections. */
-static Color cp_color = { 1.0, 0.0, 0.0 };
+static Color cp_color = { 1.0, 0.0, 0.0, 1.0 };
 
-static Color text_edit_color = {1.0, 1.0, 0.0 };
+static Color text_edit_color = {1.0, 1.0, 0.0, 1.0 };
 
 
 static void clip_region_clear(DiaRenderer *self);
diff --git a/plug-ins/python/diasvg_import.py b/plug-ins/python/diasvg_import.py
index af9d8ed..3fdccef 100644
--- a/plug-ins/python/diasvg_import.py
+++ b/plug-ins/python/diasvg_import.py
@@ -38,6 +38,7 @@ dictUnitScales = {
 
 # only compile once
 rColor = re.compile(r"rgb\s*\(\s*(\d+)[, ]+(\d+)[, +](\d+)\s*\)")
+rColora = re.compile(r"rgba\s*\(\s*(\d+)[, ]+(\d+)[, +](\d+)[, +](\d+)\s*\)")
 # not really parsing numbers (Scaled will deal with more)
 rTranslate = re.compile(r"translate\s*\(\s*([^,]+),([^)]+)\s*\)")
 #FIXME: parse more - e.g. AQT - of the strange path data
@@ -68,7 +69,10 @@ def Color(s) :
 	# deliver a StdProp compatible Color (or the original string)
 	m = rColor.match(s)
 	if m :
-		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(2)) / 255.0)
+		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(3)) / 255.0, 1.0)
+	else:
+		m = rColora.match(s)
+		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(3)) / 255.0, int(m.group(4)) / 255.0)
 	# any more ugly color definitions not compatible with pango_color_parse() ?
 	return string.strip(s)
 def _eval (s, _locals) :
diff --git a/plug-ins/python/pydia-color.c b/plug-ins/python/pydia-color.c
index 6fa2ed2..dcf2743 100644
--- a/plug-ins/python/pydia-color.c
+++ b/plug-ins/python/pydia-color.c
@@ -74,10 +74,11 @@ static PyObject *
 PyDiaColor_Str(PyDiaColor *self)
 {
   PyObject* py_s;
-  gchar* s = g_strdup_printf("(%f,%f,%f)",
+  gchar* s = g_strdup_printf("(%f,%f,%f,%f)",
                              (float)(self->color.red),
                              (float)(self->color.green),
-                             (float)(self->color.blue));
+                             (float)(self->color.blue),
+                             (float)(self->color.alpha));
   py_s = PyString_FromString(s);
   g_free (s);
   return py_s;
@@ -90,6 +91,8 @@ static PyMemberDef PyDiaColor_Members[] = {
       "double: green color component [0 .. 1.0]" },
     { "blue", T_FLOAT, offsetof(PyDiaColor, color.blue), 0,
       "double: blue color component [0 .. 1.0]" },
+    { "alpha", T_FLOAT, offsetof(PyDiaColor, color.alpha), 0,
+      "double: alpha color component [0 .. 1.0]" },
     { NULL }
 };
 /*
diff --git a/plug-ins/python/pydia-property.c b/plug-ins/python/pydia-property.c
index ef723e6..7e0838b 100644
--- a/plug-ins/python/pydia-property.c
+++ b/plug-ins/python/pydia-property.c
@@ -308,6 +308,7 @@ PyDia_set_Color (Property *prop, PyObject *val)
       p->color_data.red = color.red / 65535.0; 
       p->color_data.green = color.green / 65535.0; 
       p->color_data.blue = color.blue / 65535.0;
+      p->color_data.alpha = 1.0;
       return 0;
     } else
       g_debug("Failed to parse color string '%s'", str);
@@ -328,6 +329,7 @@ PyDia_set_Color (Property *prop, PyObject *val)
     p->color_data.red = f[0]; 
     p->color_data.green = f[1]; 
     p->color_data.blue = f[2];
+    p->color_data.alpha = 1.0;
     return 0;
   }
   /* also convert char/255 ? */
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index 953167e..5df4abb 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -67,6 +67,7 @@ get_colour(gint32 c)
     colour.red   = ((c & 0xff0000) >> 16) / 255.0;
     colour.green = ((c & 0x00ff00) >> 8) / 255.0;
     colour.blue  =  (c & 0x0000ff) / 255.0;
+    colour.alpha = 1.0;
 
     return colour;
 }
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index 8158943..c173293 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -291,9 +291,9 @@ begin_render(DiaRenderer *self)
     /* renderer->version = 0; */
 
     /* Black and white are 0 and 1 respectively */
-    c.red = 0.0; c.green = 0.0; c.blue = 0.0;
+    c.red = 0.0; c.green = 0.0; c.blue = 0.0; c.alpha = 1.0;
     vdxCheckColor(renderer, &c);
-    c.red = 1.0; c.green = 1.0; c.blue = 1.0;
+    c.red = 1.0; c.green = 1.0; c.blue = 1.0; c.alpha = 1.0;
     vdxCheckColor(renderer, &c);
 }
 
@@ -1638,7 +1638,7 @@ write_header(DiagramData *data, VDXRenderer *renderer)
     struct vdx_Char Char;
     struct vdx_Para Para;
     struct vdx_Tabs Tabs;
-    static Color color_black = {0,0,0};
+    static Color color_black = { 0.0, 0.0, 0.0, 1.0 };
 
     g_debug("write_header");
 
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index 2afd8df..a152ad8 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -205,13 +205,16 @@ Color
 vdx_parse_color(const char *s, const VDXDocument *theDoc)
 {
     int colorvalues;
-    Color c = {0, 0, 0};
+    Color c = {0, 0, 0, 0};
     if (s[0] == '#')
     {
         sscanf(s, "#%xd", &colorvalues);
+        /* A wild fabricated guess? */
+        /* c.alpha = ((colorvalues & 0xff000000)>>24) / 255.0; */
         c.red = ((colorvalues & 0x00ff0000)>>16) / 255.0;
         c.green = ((colorvalues & 0x0000ff00)>>8) / 255.0;
         c.blue = (colorvalues & 0x000000ff) / 255.0;
+        c.alpha = 1.0;
         return c;
     }
     if (g_ascii_isdigit(s[0]))
@@ -720,6 +723,7 @@ vdx_simple_properties(DiaObject *obj,
             cprop->color_data.red = 0;
             cprop->color_data.green = 0;
             cprop->color_data.blue = 0;
+            cprop->color_data.alpha = 1.0;
         }
         else
         {
@@ -727,6 +731,7 @@ vdx_simple_properties(DiaObject *obj,
             cprop->color_data.red = 1;
             cprop->color_data.green = (theDoc->shape_id >> 8)/255.0;
             cprop->color_data.blue = (theDoc->shape_id & 0xff)/255.0;
+            cprop->color_data.alpha = 1.0;
         }
     }
 
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index 09ea102..24c2343 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -275,7 +275,7 @@ begin_render(DiaRenderer *self)
 
   gint16 i;
   guint8* pPal;
-  Color color = {1, 1, 1};
+  Color color = { 1.0, 1.0, 1.0, 1.0 };
 
   DIAG_NOTE(g_message("begin_render"));
 
diff --git a/plug-ins/xfig/xfig-common.c b/plug-ins/xfig/xfig-common.c
index a980d74..639a00d 100644
--- a/plug-ins/xfig/xfig-common.c
+++ b/plug-ins/xfig/xfig-common.c
@@ -21,14 +21,14 @@
 #include "xfig.h"
 
 Color fig_default_colors[FIG_MAX_DEFAULT_COLORS] =
-{ { 0x00, 0x00, 0x00}, {0x00, 0x00, 0xff}, {0x00, 0xff, 0x00}, {0x00, 0xff, 0xff}, 
-  { 0xff, 0x00, 0x00}, {0xff, 0x00, 0xff}, {0xff, 0xff, 0x00}, {0xff, 0xff, 0xff},
-  { 0x00, 0x00, 0x8f}, {0x00, 0x00, 0xb0}, {0x00, 0x00, 0xd1}, {0x87, 0xcf, 0xff},
-  { 0x00, 0x8f, 0x00}, {0x00, 0xb0, 0x00}, {0x00, 0xd1, 0x00}, {0x00, 0x8f, 0x8f},
-  { 0x00, 0xb0, 0xb0}, {0x00, 0xd1, 0xd1}, {0x8f, 0x00, 0x00}, {0xb0, 0x00, 0x00},
-  { 0xd1, 0x00, 0x00}, {0x8f, 0x00, 0x8f}, {0xb0, 0x00, 0xb0}, {0xd1, 0x00, 0xd1},
-  { 0x7f, 0x30, 0x00}, {0xa1, 0x3f, 0x00}, {0xbf, 0x61, 0x00}, {0xff, 0x7f, 0x7f},
-  { 0xff, 0xa1, 0xa1}, {0xff, 0xbf, 0xbf}, {0xff, 0xe1, 0xe1}, {0xff, 0xd7, 0x00}};
+{ { 0x00, 0x00, 0x00, 0xff }, { 0x00, 0x00, 0xff, 0xff }, { 0x00, 0xff, 0x00, 0xff }, { 0x00, 0xff, 0xff, 0xff },
+  { 0xff, 0x00, 0x00, 0xff }, { 0xff, 0x00, 0xff, 0xff }, { 0xff, 0xff, 0x00, 0xff }, { 0xff, 0xff, 0xff, 0xff },
+  { 0x00, 0x00, 0x8f, 0xff }, { 0x00, 0x00, 0xb0, 0xff }, { 0x00, 0x00, 0xd1, 0xff }, { 0x87, 0xcf, 0xff, 0xff },
+  { 0x00, 0x8f, 0x00, 0xff }, { 0x00, 0xb0, 0x00, 0xff }, { 0x00, 0xd1, 0x00, 0xff }, { 0x00, 0x8f, 0x8f, 0xff },
+  { 0x00, 0xb0, 0xb0, 0xff }, { 0x00, 0xd1, 0xd1, 0xff }, { 0x8f, 0x00, 0x00, 0xff }, { 0xb0, 0x00, 0x00, 0xff },
+  { 0xd1, 0x00, 0x00, 0xff }, { 0x8f, 0x00, 0x8f, 0xff }, { 0xb0, 0x00, 0xb0, 0xff }, { 0xd1, 0x00, 0xd1, 0xff },
+  { 0x7f, 0x30, 0x00, 0xff }, { 0xa1, 0x3f, 0x00, 0xff }, { 0xbf, 0x61, 0x00, 0xff }, { 0xff, 0x7f, 0x7f, 0xff },
+  { 0xff, 0xa1, 0xa1, 0xff }, { 0xff, 0xbf, 0xbf, 0xff }, { 0xff, 0xe1, 0xe1, 0xff }, { 0xff, 0xd7, 0x00, 0xff }};
 
 /** These are the "old-name" font names corresponding to the XFig standard
  *  fonts.  See the list in font.c.
diff --git a/plug-ins/xfig/xfig-import.c b/plug-ins/xfig/xfig-import.c
index 1436b27..70f00e9 100644
--- a/plug-ins/xfig/xfig-import.c
+++ b/plug-ins/xfig/xfig-import.c
@@ -124,16 +124,19 @@ fig_area_fill_color(int area_fill, int color_index) {
 	    col.red = 0xff*(20-area_fill)/20;
 	    col.green = 0xff*(20-area_fill)/20;
 	    col.blue = 0xff*(20-area_fill)/20;
+	    col.alpha = 1.0;
 	} else {
 	    col.red = (col.red*area_fill)/20;
 	    col.green = (col.green*area_fill)/20;
 	    col.blue = (col.blue*area_fill)/20;
+	    col.alpha = 1.0;
 	}
     } else if (area_fill > 20 && area_fill <= 40) {
 	/* White and black area illegal here */
 	col.red += (0xff-col.red)*(area_fill-20)/20;
 	col.green += (0xff-col.green)*(area_fill-20)/20;
 	col.blue += (0xff-col.blue)*(area_fill-20)/20;
+	col.alpha = 1.0;
     } else {
 	message_warning(_("Patterns are not supported by Dia"));
     }
@@ -1056,6 +1059,7 @@ fig_read_object(FILE *file) {
 	color.red = ((colorvalues & 0x00ff0000)>>16) / 255.0;
 	color.green = ((colorvalues & 0x0000ff00)>>8) / 255.0;
 	color.blue = (colorvalues & 0x000000ff) / 255.0;
+	color.alpha = 1.0;
 
 	fig_colors[colornumber-32] = color;
 	break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]