Skip to content

Commit

Permalink
Encode and decode alpha color component
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12908 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 9, 2010
1 parent dd39390 commit 023d98d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 023d98d

Please sign in to comment.