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

Confusion non-premultiplied/pre-multiplied with bilinear resampling #4993

Closed
rouault opened this issue Sep 12, 2014 · 1 comment
Closed

Confusion non-premultiplied/pre-multiplied with bilinear resampling #4993

rouault opened this issue Sep 12, 2014 · 1 comment
Assignees

Comments

@rouault
Copy link
Contributor

@rouault rouault commented Sep 12, 2014

msBilinearRasterResampler() uses msAlphaBlendPM() to do composition.
msAlphaBlendPM() assumes that the source pixel r,g,b,a is alpha pre-multiplied. But currently, a division padfPixelSum[i] /= dfWeightSum (dfWeightSum being the alpha channel) after merging the 4 source pixels make r,g,b effectively un-premultiplied. The result is then integer overflow in saveAsPNG(), because it assumes a pre-multiplied buffer and does un-premultiplication since libpng wants un-premultiplication. This can lead to completely wrong colors in areas where alpha is > 0 and < 255.
The issue is similar with GDAL output, but in msSaveImageGDAL() there's a test to avoid overflow above 255.

@tbonfort
Copy link
Member

@tbonfort tbonfort commented Feb 10, 2015

merged with #4994

@tbonfort tbonfort closed this Feb 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.