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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: