Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Mapscript problem setting opacity on style object #4153

Closed
mapserver-bot opened this issue Apr 4, 2012 · 7 comments
Closed

C# Mapscript problem setting opacity on style object #4153

mapserver-bot opened this issue Apr 4, 2012 · 7 comments

Comments

@mapserver-bot
Copy link

Reporter: woodbri
Date: 2012/01/11 - 15:38
Trac URL: http://trac.osgeo.org/mapserver/ticket/4153
The mapfile STYLE block[1] has OPACITY [integer|attribute] but I do not see this attribute listed in the SWIG mapscript [2] styleObj Attributes list.

And I have a report that when trying to use this via .NET mapscript that it does not seem to work.

layerObj opacity seems to work just fine.

If I go the

my_style.opacity = 50

route, it looks like it's being completely ignored in the resulting map.

If I go the

my_style.updateFromString("STYLE OPACITY 50 END")

route, then this also is sometimes ignored. It is ignored if after having set the opacity I set the color with

my_style.color = New colorObj(0, 255, 0, 0)

but if I rearrange my statements such that the color is set before instead of after I set the opacity (opacity set with updateFromString) then all works just fine. The other properties I set (symbol, width, outlinecolor) don't seem to have any similar order dependency as the transparency works just fine with them occurring either before or after the updateFromString call.

Stepping through the following snippet of code

            Dim fieldStyle As New OSGeo.MapServer.styleObj(fieldClass)
            With fieldStyle
                .color = New colorObj(0, 255, 0, 0)
                .opacity = 50
                'set the opacity on the style
                .updateFromString("STYLE OPACITY 50 END")
                .color = New colorObj(0, 255, 0, 0)
                .symbol = 0
                .width = 1
                .outlinecolor = New colorObj(0, 0, 0, 0)
            End With

(see attached Stepping.png image for the below)
After the first .color = line, the alpha for color is set to 255.
After the .opacity = line, the alpha for color is still 255.
After the .updateFromString line, the alpha for color is 127 or approximately 50%.
After the second .color = line, the alpha for color is back at 255.
The .outlinecolor.alpha is always 255 and doesn't seem to affect the eventual appearance of the map, rather the outline is opaque if color.alpha = 255 but semi-transparent if color.alpha is less than 255.

So, if I had to guess as to what's going on under the covers I'd guess that style.alpha is being completely ignored and color.alpha is dictating the transparency of both the fill and the outline.

Testing using MS4W version 3.0.3 which I believe would be MapServer 6.0.1. 32-bit version.

@mapserver-bot
Copy link
Author

Author: woodbri
Date: 2012/01/11 - 15:49
Please assign this to Documentation afterwards with appropriate notes on what is the expected behavior. It seems that there are some potential subtle side effects between setting the color, adding a symbol and setting opacity. Setting a color overrides opacity, adding a symbol seems to also modify alpha, and setting opacity only changes the alpha, so any action after setting opacity the implicitly change the alpha destroys the explicitly set opacity.

@mapserver-bot
Copy link
Author

attachment http://trac.osgeo.org/mapserver/attachment/ticket/4153/Stepping.png :

   Output of stepping through the code.

@mapserver-bot
Copy link
Author

attachment http://trac.osgeo.org/mapserver/attachment/ticket/4153/ms-bug-4153.zip :

   Sample C# code that demonstrates the problem

@ghost ghost assigned szekerest Apr 5, 2012
@szekerest
Copy link
Member

Currently mapserver doesn't support setting alpha values for the color attributes, and alpha values are not written back to the mapfile. Setting the opacity value will override the style level color alpha values programatically.
It would however be reasonable to review this behaviour and allow setting alpha values for each color and deprecate the opacity setting.

@szekerest szekerest assigned szekerest and unassigned szekerest Mar 24, 2014
@szekerest
Copy link
Member

@tbonfort @dmorissette Could you provide further info how the opacity values should be handled or we can close this one?

@szekerest szekerest assigned tbonfort and unassigned szekerest Mar 24, 2014
@szekerest
Copy link
Member

reassigining

@mapserver-bot
Copy link
Author

This is an automated comment

This issue has been closed due to lack of activity. This doesn't mean the issue is invalid, it simply got no attention within the last year. Please reopen with missing/relevant information if still valid.

Typically, issues fall in this state for one of the following reasons:

  • Hard, impossible or not enough information to reproduce
  • Missing test case
  • Lack of a champion with interest and/or funding to address the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants