aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-08-25 23:20:14 +0200
committerWillem Jan Palenstijn2013-08-25 23:21:19 +0200
commite9cbda135bbc822009ff311cad6e420fb23cff82 (patch)
tree522fc6e09cc7c5bec44c89aa259652f133fdb280 /engines
parent18c648c9374e951f308ce930228fddbbdbc21096 (diff)
downloadscummvm-rg350-e9cbda135bbc822009ff311cad6e420fb23cff82.tar.gz
scummvm-rg350-e9cbda135bbc822009ff311cad6e420fb23cff82.tar.bz2
scummvm-rg350-e9cbda135bbc822009ff311cad6e420fb23cff82.zip
WINTERMUTE: Fix alpha blending with colormod
This fixes numerous transparency effects in J.U.L.I.A.
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 249d30f7d9..00a3db83fd 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -299,14 +299,6 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
int cg = (color >> 8) & 0xff;
int cb = (color >> 0) & 0xff;
- // Compensate for transparency. Since we're coming
- // down to 255 alpha, we just compensate for the colors here
- if (ca != 255) {
- cr = cr * ca >> 8;
- cg = cg * ca >> 8;
- cb = cb * ca >> 8;
- }
-
// Create an encapsulating surface for the data
TransparentSurface srcImage(*this, false);
// TODO: Is the data really in the screen format?
@@ -443,7 +435,6 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
if (ca != 255) {
a = a * ca >> 8;
}
-
switch (a) {
case 0: // Full transparency
out += 4;
@@ -473,27 +464,27 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
default: // alpha blending
outa = 255;
- outb = (o_pix >> bShiftTarget) & 0xff;
- outg = (o_pix >> gShiftTarget) & 0xff;
- outr = (o_pix >> rShiftTarget) & 0xff;
+ outb = ((o_pix >> bShiftTarget) & 0xff) * (255 - a);
+ outg = ((o_pix >> gShiftTarget) & 0xff) * (255 - a);
+ outr = ((o_pix >> rShiftTarget) & 0xff) * (255 - a);
if (cb == 0)
outb = 0;
else if (cb != 255)
- outb += ((b - outb) * a * cb) >> 16;
+ outb = ((outb + b * a) * cb) >> 16;
else
- outb += ((b - outb) * a) >> 8;
+ outb = (outb + b * a) >> 8;
if (cg == 0)
outg = 0;
else if (cg != 255)
- outg += ((g - outg) * a * cg) >> 16;
+ outg = ((outg + g * a) * cg) >> 16;
else
- outg += ((g - outg) * a) >> 8;
+ outg = (outg + g * a) >> 8;
if (cr == 0)
outr = 0;
else if (cr != 255)
- outr += ((r - outr) * a * cr) >> 16;
+ outr = ((outr + r * a) * cr) >> 16;
else
- outr += ((r - outr) * a) >> 8;
+ outr = (outr + r * a) >> 8;
out[aIndex] = outa;
out[bIndex] = outb;
out[gIndex] = outg;