Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 6773)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 6774)
@@ -877,5 +877,5 @@
         String colStr = specName != null ? get("color."+specName) : "";
         if (colStr.isEmpty()) {
-            colStr = get("color." + colKey, ColorHelper.color2html(def));
+            colStr = get("color." + colKey, ColorHelper.color2html(def, true));
         }
         if (colStr != null && !colStr.isEmpty()) {
@@ -893,5 +893,5 @@
 
     synchronized public boolean putColor(String colKey, Color val) {
-        return put("color."+colKey, val != null ? ColorHelper.color2html(val) : null);
+        return put("color."+colKey, val != null ? ColorHelper.color2html(val, true) : null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj	(revision 6773)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj	(revision 6774)
@@ -52,5 +52,5 @@
 |   < REGEX: "/" <REGEX_CHAR_WITHOUT_STAR> ( <REGEX_CHAR_WITHOUT_STAR> | "*" )*  "/" >
 |   < #H: ["0"-"9","a"-"f","A"-"F"] >
-|   < HEXCOLOR: "#" ( <H><H><H><H><H><H> | <H><H><H> ) >
+|   < HEXCOLOR: "#" ( <H><H><H><H><H><H><H><H> | <H><H><H><H><H><H> | <H><H><H> ) >
 |   < S: ( " " | "\t" | "\n" | "\r" | "\f" )+ >
 |   < STAR: "*" >
Index: /trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy	(revision 6773)
+++ /trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy	(revision 6774)
@@ -2,4 +2,6 @@
 
 import org.openstreetmap.josm.Main
+
+import java.awt.Color
 
 class PreferencesTest extends GroovyTestCase {
@@ -10,5 +12,17 @@
 
     void testColorName() {
-        Main.pref.getColorName("color.layer {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx") == "{5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx"
+        assert Main.pref.getColorName("color.layer {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx") == "color.layer {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx"
+    }
+
+    void testColorAlpha() {
+        assert Main.pref.getColor("foo", new Color(0x12345678, true)).alpha == 0x12
+        assert Main.pref.putColor("bar", new Color(0x12345678, true))
+        assert Main.pref.getColor("bar", null).alpha == 0x12
+    }
+
+    void testColorNameAlpha() {
+        assert Main.pref.getColor("foo", "bar", new Color(0x12345678, true)).alpha == 0x12
+        assert Main.pref.getDefaultColor("foo") == new Color(0x34, 0x56, 0x78, 0x12)
+        assert Main.pref.getDefaultColor("foo").alpha == 0x12
     }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy	(revision 6773)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy	(revision 6774)
@@ -225,5 +225,19 @@
         def expected = new Color(0x88DD22)
         assert e.getCascade(Environment.DEFAULT_LAYER).get("color") == expected
-        assert Main.pref.getDefaultColor("MapCSS.testcolour1") == expected
+        assert Main.pref.getDefaultColor("mappaint.mapcss.testcolour1") == expected
+    }
+
+    @Test
+    public void testColorNameTicket9191Alpha() throws Exception {
+        def e = new Environment(null, new MultiCascade(), Environment.DEFAULT_LAYER, null)
+        getParser("{color: testcolour2#12345678}").declaration().get(0).execute(e)
+        def expected = new Color(0x12, 0x34, 0x56, 0x78)
+        assert e.getCascade(Environment.DEFAULT_LAYER).get("color") == expected
+        assert Main.pref.getDefaultColor("mappaint.mapcss.testcolour2") == expected
+    }
+
+    @Test
+    public void testColorParsing() throws Exception {
+        assert ColorHelper.html2color("#12345678") == new Color(0x12, 0x34, 0x56, 0x78)
     }
 }
