Skip to content

Commit 0ab3105

Browse files
author
mhugent
committedFeb 9, 2010
Encode and decode alpha color component
git-svn-id: http://svn.osgeo.org/qgis/trunk@12908 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1f3f3ee commit 0ab3105

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
 

‎src/core/symbology-ng/qgssymbollayerv2utils.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@
1717

1818
QString QgsSymbolLayerV2Utils::encodeColor( QColor color )
1919
{
20-
return QString( "%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
20+
return QString( "%1,%2,%3,%4" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ).arg( color.alpha() );
2121
}
2222

2323
QColor QgsSymbolLayerV2Utils::decodeColor( QString str )
2424
{
2525
QStringList lst = str.split( "," );
26-
if ( lst.count() != 3 )
26+
if ( lst.count() < 3 )
27+
{
2728
return QColor();
28-
return QColor( lst[0].toInt(), lst[1].toInt(), lst[2].toInt() );
29+
}
30+
int red, green, blue, alpha;
31+
red = lst[0].toInt();
32+
green = lst[1].toInt();
33+
blue = lst[2].toInt();
34+
alpha = 255;
35+
if ( lst.count() > 3 )
36+
{
37+
alpha = lst[3].toInt();
38+
}
39+
return QColor( red, green, blue, alpha );
2940
}
3041

3142
QString QgsSymbolLayerV2Utils::encodePenStyle( Qt::PenStyle style )

0 commit comments

Comments
 (0)
Please sign in to comment.