Skip to content
Permalink
Browse files

Encode and decode alpha color component

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12908 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Feb 9, 2010
1 parent dd39390 commit 023d98d74f952aef26c1636980938551310a4256
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/core/symbology-ng/qgssymbollayerv2utils.cpp
@@ -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 )

0 comments on commit 023d98d

Please sign in to comment.
You can’t perform that action at this time.