[QGIS Commit] r12908 - trunk/qgis/src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Feb 9 10:46:33 EST 2010


Author: mhugent
Date: 2010-02-09 10:46:32 -0500 (Tue, 09 Feb 2010)
New Revision: 12908

Modified:
   trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
Log:
Encode and decode alpha color component

Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp	2010-02-09 14:34:17 UTC (rev 12907)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp	2010-02-09 15:46:32 UTC (rev 12908)
@@ -17,15 +17,26 @@
 
 QString QgsSymbolLayerV2Utils::encodeColor( QColor color )
 {
-  return QString( "%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
+  return QString( "%1,%2,%3,%4" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ).arg( color.alpha() );
 }
 
 QColor QgsSymbolLayerV2Utils::decodeColor( QString str )
 {
   QStringList lst = str.split( "," );
-  if ( lst.count() != 3 )
+  if ( lst.count() < 3 )
+  {
     return QColor();
-  return QColor( lst[0].toInt(), lst[1].toInt(), lst[2].toInt() );
+  }
+  int red, green, blue, alpha;
+  red = lst[0].toInt();
+  green = lst[1].toInt();
+  blue = lst[2].toInt();
+  alpha = 255;
+  if ( lst.count() > 3 )
+  {
+    alpha = lst[3].toInt();
+  }
+  return QColor( red, green, blue, alpha );
 }
 
 QString QgsSymbolLayerV2Utils::encodePenStyle( Qt::PenStyle style )



More information about the QGIS-commit mailing list