[Scummvm-cvs-logs] scummvm master -> 4591bd6eb6bd5b4dccaab67bbfb8875f7fffd2d4

wjp wjp at usecode.org
Sun Sep 29 20:20:30 CEST 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4591bd6eb6 SWORD25: Fix alpha/colormod blitting


Commit: 4591bd6eb6bd5b4dccaab67bbfb8875f7fffd2d4
    https://github.com/scummvm/scummvm/commit/4591bd6eb6bd5b4dccaab67bbfb8875f7fffd2d4
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2013-09-29T11:18:54-07:00

Commit Message:
SWORD25: Fix alpha/colormod blitting

This is a backport to sword25 of the wintermute commits
e9cbda135bbc822009ff311cad6e420fb23cff82 and 2141ad285e0200f4773726a13504f960e382f13e

Thanks to eriktorbjorn for noticing and testing.

Changed paths:
    engines/sword25/gfx/image/renderedimage.cpp



diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 346b46f..b359fc6 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -240,14 +240,6 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
 	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
 	Graphics::Surface srcImage;
 	// TODO: Is the data really in the screen format?
@@ -400,52 +392,52 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
 						} else {
 #if defined(SCUMM_LITTLE_ENDIAN)
 							pix = *(uint32 *)out;
-							int outb = (pix >> 0) & 0xff;
-							int outg = (pix >> 8) & 0xff;
-							int outr = (pix >> 16) & 0xff;
+							int outb = ((pix >> 0) & 0xff) * (255 - a);
+							int outg = ((pix >> 8) & 0xff) * (255 - a);
+							int outr = ((pix >> 16) & 0xff) * (255 - a);
 							if (cb == 0)
-								outb = 0;
+								outb = outb >> 8;
 							else if (cb != 255)
-								outb += ((b - outb) * a * cb) >> 16;
+								outb = ((outb << 8) + b * a * cb) >> 16;
 							else
-								outb += ((b - outb) * a) >> 8;
+								outb = (outb + b * a) >> 8;
 							if (cg == 0)
-								outg = 0;
+								outg = outg >> 8;
 							else if (cg != 255)
-								outg += ((g - outg) * a * cg) >> 16;
+								outg = ((outg << 8) + g * a * cg) >> 16;
 							else
-								outg += ((g - outg) * a) >> 8;
+								outg = (outg + g * a) >> 8;
 							if (cr == 0)
-								outr = 0;
+								outr = outr >> 8;
 							else if (cr != 255)
-								outr += ((r - outr) * a * cr) >> 16;
+								outr = ((outr << 8) + r * a * cr) >> 16;
 							else
-								outr += ((r - outr) * a) >> 8;
+								outr = (outr + r * a) >> 8;
 							*(uint32 *)out = (255 << 24) | (outr << 16) | (outg << 8) | outb;
 							out += 4;
 #else
 							*out = 255;
 							out++;
 							if (cr == 0)
-								*out = 0;
+								*out = (*out * (255-a)) >> 8;
 							else if (cr != 255)
-								*out += ((r - *out) * a * cr) >> 16;
+								*out = (((*out * (255-a)) << 8) + r * a * cr) >> 16;
 							else
-								*out += ((r - *out) * a) >> 8;
+								*out = ((*out * (255-a)) + r * a) >> 8;
 							out++;
 							if (cg == 0)
-								*out = 0;
+								*out = (*out * (255-a)) >> 8;
 							else if (cg != 255)
-								*out += ((g - *out) * a * cg) >> 16;
+								*out = (((*out * (255-a)) << 8) + g * a * cg) >> 16;
 							else
-								*out += ((g - *out) * a) >> 8;
+								*out = ((*out * (255-a)) + g * a) >> 8;
 							out++;
 							if (cb == 0)
-								*out = 0;
+								*out = (*out * (255-a)) >> 8;
 							else if (cb != 255)
-								*out += ((b - *out) * a * cb) >> 16;
+								*out = (((*out * (255-a)) << 8) + b * a * cb) >> 16;
 							else
-								*out += ((b - *out) * a) >> 8;
+								*out = ((*out * (255-a)) + b * a) >> 8;
 							out++;
 #endif
 						}






More information about the Scummvm-git-logs mailing list