GRAPHICS: Fix computation of addA in darkenFill()
The old computation had rounding issues, causing alpha to leak into the red (usually) component. There's a much easier way to compute it that does not lead to such problems: What should really happen is that the two top bits of the A component should be set to 1 (thus adding 75% alpha). So compute it that way for speed and precision.
This commit is contained in:
parent
66ad9e76ee
commit
51d7405a7b
1 changed files with 1 additions and 2 deletions
|
@ -691,8 +691,7 @@ darkenFill(PixelType *ptr, PixelType *end) {
|
|||
// assuming at least 3 alpha bits
|
||||
|
||||
mask |= 3 << _format.aShift;
|
||||
PixelType addA = (PixelType)(255 >> _format.aLoss) << _format.aShift;
|
||||
addA -= (addA >> 2);
|
||||
PixelType addA = (PixelType)(3 << (_format.aShift + 6 - _format.aLoss));
|
||||
|
||||
while (ptr != end) {
|
||||
// Darken the colour, and increase the alpha
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue