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

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

Comments

Projects
None yet
2 participants
@rouault
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Feb 10, 2015

Member

merged with #4994

Member

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