Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cpt] Fix invalid interpretation of SVG stops with no stop-color tag
Browse files Browse the repository at this point in the history
This resulted in CPT ramps having a green color present when there
should have been black!

(cherry picked from commit 708708f)
nyalldawson committed Aug 19, 2022
1 parent 66761c5 commit b3594c7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/core/symbology/qgscptcityarchive.cpp
Original file line number Diff line number Diff line change
@@ -387,9 +387,18 @@ QMap< double, QPair<QColor, QColor> >QgsCptCityArchive::gradientColorMap( const
else
offset = offsetStr.toDouble();

// QColor color( 255, 0, 0 ); // red color as a warning :)
QColor color = QgsSymbolLayerUtils::parseColor( colorStr );
if ( color != QColor() )
QColor color;
if ( colorStr.isEmpty() )
{
// SVG spec says that stops without color default to black!
color = QColor( 0, 0, 0 );
}
else
{
color = QgsSymbolLayerUtils::parseColor( colorStr );
}

if ( color.isValid() )
{
const int alpha = opacityStr.toDouble() * 255; // test
color.setAlpha( alpha );
@@ -400,7 +409,7 @@ QMap< double, QPair<QColor, QColor> >QgsCptCityArchive::gradientColorMap( const
}
else
{
QgsDebugMsg( QStringLiteral( "at offset=%1 invalid color" ).arg( offset ) );
QgsDebugMsg( QStringLiteral( "at offset=%1 invalid color \"%2\"" ).arg( offset ).arg( colorStr ) );
}
}
else

0 comments on commit b3594c7

Please sign in to comment.