Correct implementation of "msAlphaBlendPM".#7358
Open
ThomasCusson wants to merge 1 commit intoMapServer:mainfrom
Open
Correct implementation of "msAlphaBlendPM".#7358ThomasCusson wants to merge 1 commit intoMapServer:mainfrom
ThomasCusson wants to merge 1 commit intoMapServer:mainfrom
Conversation
…tiplied, no need to multiply them again. Compliance with the optimized approach of msAlphaBlend (using 256 instead of 255)
Member
|
thanks @ThomasCusson . Please also include a test for this as part of your pull request (you can see a few other COMPOP tests in /msautotest/renderers/). Find more info about msautotest at https://mapserver.org/development/tests/autotest.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

At our company we noticed, using the composite "src-over" blending mode (default), that some darkening is happening when opacity is not 0% or 100%. This is a typical problem of pre-multiplied alpha, so I looked into it.
It seems that the
msAlphaBlendPM(PM stands for Pre-Multiplied) acts as if the bands were not pre-multiplied already, in a fashion similar tomsAlphaBlend.It results in a double multiplication by alpha channel, producing colors that are too dark on half-transparent areas. This issue probably arise only when using a change of projection, as it is only called in
mapresample.c.I also used "256" values instead of 255, to match the implementation from
msAlphaBlend, but maybe it's not useful, I'll leave that up to your judgement.