Skip to content

Commit

Permalink
Styling - Fixes alpha value for hex colors (#6023)
Browse files Browse the repository at this point in the history
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 1e30f54
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 1 deletion.
6 changes: 5 additions & 1 deletion maputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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?) */
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions msautotest/renderers/polygon-hex-alpha.map
Original file line number Diff line number Diff line change
@@ -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
Binary file modified msautotest/sld/expected/size_sldbody.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_displacementx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_displacementy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_opacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_stroke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_point_literal_strokewidth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_expression_fontsize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_expression_rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_literal_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_literal_fontsize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_literal_halofill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_literal_rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_propertyname_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_propertyname_fontsize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_propertyname_halofill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/sld/expected/sld_text_propertyname_rotation.png
Loading
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.