GRAPHICS: Fix fully transparent pixel blit

In BLEND_NORMAL mode with color != 0xffffffff, blending fully
transparent pixel was resulted in slightly modifying some background
colors, because old value X was a bit different from new value (X*255>>8).

This fixes defect #10686 WME: Sprite background is not fully transparent
if AlphaColor is set
This commit is contained in:
lolbot-iichan 2019-06-15 23:21:48 +03:00 committed by Filippos Karapetis
parent 66bd815e04
commit c4dc251f2b

View File

@ -177,14 +177,17 @@ void doBlitAlphaBlend(byte *ino, byte *outo, uint32 width, uint32 height, uint32
for (uint32 j = 0; j < width; j++) {
uint32 ina = in[kAIndex] * ca >> 8;
out[kAIndex] = 255;
out[kBIndex] = (out[kBIndex] * (255 - ina) >> 8);
out[kGIndex] = (out[kGIndex] * (255 - ina) >> 8);
out[kRIndex] = (out[kRIndex] * (255 - ina) >> 8);
out[kBIndex] = out[kBIndex] + (in[kBIndex] * ina * cb >> 16);
out[kGIndex] = out[kGIndex] + (in[kGIndex] * ina * cg >> 16);
out[kRIndex] = out[kRIndex] + (in[kRIndex] * ina * cr >> 16);
if (ina != 0) {
out[kAIndex] = 255;
out[kBIndex] = (out[kBIndex] * (255 - ina) >> 8);
out[kGIndex] = (out[kGIndex] * (255 - ina) >> 8);
out[kRIndex] = (out[kRIndex] * (255 - ina) >> 8);
out[kBIndex] = out[kBIndex] + (in[kBIndex] * ina * cb >> 16);
out[kGIndex] = out[kGIndex] + (in[kGIndex] * ina * cg >> 16);
out[kRIndex] = out[kRIndex] + (in[kRIndex] * ina * cr >> 16);
}
in += inStep;
out += 4;