mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Encode and decode alpha color component
git-svn-id: http://svn.osgeo.org/qgis/trunk@12908 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1f3f3ee630
commit
0ab310575d
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user