Skip to content
Permalink
Browse files
Styling - Fixes alpha value for hex colors (#6023)
Fixes #5882. The issue was introduced by the following commit:

4fbd7ae

This commit changes back to the old behavior so that opacity is only
applied if the style have any bindings. A test case to test this
has also been added.
  • Loading branch information
ravhed authored and jmckenna committed Apr 5, 2020
1 parent 14a9c9f commit 1e30f54aab4c7894160cdd72d266ae5aebc6a0d2
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 1 deletion.
@@ -134,8 +134,10 @@ static int bindColorAttribute(colorObj *attribute, const char *value)

static void bindStyle(layerObj *layer, shapeObj *shape, styleObj *style, int drawmode)
{
int applyOpacity = MS_FALSE;
assert(MS_DRAW_FEATURES(drawmode));
if(style->numbindings > 0) {
applyOpacity = MS_TRUE;
if(style->bindings[MS_STYLE_BINDING_SYMBOL].index != -1) {
style->symbol = msGetSymbolIndex(&(layer->map->symbolset), shape->values[style->bindings[MS_STYLE_BINDING_SYMBOL].index], MS_TRUE);
if(style->symbol == -1) style->symbol = 0; /* a reasonable default (perhaps should throw an error?) */
@@ -187,6 +189,7 @@ static void bindStyle(layerObj *layer, shapeObj *shape, styleObj *style, int dra
}
if (style->nexprbindings > 0)
{
applyOpacity = MS_TRUE;
if (style->exprBindings[MS_STYLE_BINDING_OFFSET_X].type == MS_EXPRESSION)
{
style->offsetx = msEvalDoubleExpression(
@@ -238,7 +241,8 @@ static void bindStyle(layerObj *layer, shapeObj *shape, styleObj *style, int dra
msFree(txt);
}
}
if(style->opacity < 100 || style->color.alpha != 255 ) {

if(applyOpacity == MS_TRUE && (style->opacity < 100 || style->color.alpha != 255) ) {
int alpha;
alpha = MS_NINT(style->opacity*2.55);
style->color.alpha = alpha;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,31 @@
# RUN_PARMS: polygon-hex-alpha.png [SHP2IMG] -m [MAPFILE] -i png -o [RESULT]
#
#
# REQUIRES: OUTPUT=PNG
#
MAP

STATUS ON
EXTENT -125.549477 -69.508628 101.670954 15.840339
SIZE 200 150
FONTSET "../misc/fonts.lst"
IMAGETYPE png24
symbolset "symbolset"
shapepath "../misc/data"

CONFIG MS_ERRORFILE "stderr"

LAYER
NAME "world"
TYPE polygon
STATUS default
DATA "world_testpoly"
CLASS
NAME "hexalpha"
STYLE
COLOR "#ee990033"
END
END
END

END
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1e30f54

Please sign in to comment.