aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorlolbot-iichan2019-06-15 23:21:48 +0300
committerFilippos Karapetis2019-06-24 11:27:44 +0300
commitc4dc251f2b3e1f8174136e2880561a6e64bf7411 (patch)
treeb1081411c2edff5e0ec87c4c23436e04b89b8303 /graphics
parent66bd815e044de2d0ca543a225ccc72bfe84021d1 (diff)
downloadscummvm-rg350-c4dc251f2b3e1f8174136e2880561a6e64bf7411.tar.gz
scummvm-rg350-c4dc251f2b3e1f8174136e2880561a6e64bf7411.tar.bz2
scummvm-rg350-c4dc251f2b3e1f8174136e2880561a6e64bf7411.zip
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
Diffstat (limited to 'graphics')
-rw-r--r--graphics/transparent_surface.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/graphics/transparent_surface.cpp b/graphics/transparent_surface.cpp
index 02611aa60f..b4d73d1078 100644
--- a/graphics/transparent_surface.cpp
+++ b/graphics/transparent_surface.cpp
@@ -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;