aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMarcus Comstedt2005-04-03 19:41:20 +0000
committerMarcus Comstedt2005-04-03 19:41:20 +0000
commitd2214dca9913011fb9f5f7545309d2d4042fc50c (patch)
treeab5a0e883087a215c13ad4d24af4f305abbdf027 /gui
parentac54a40ea26f43cc0051c71723d62f6aec6df920 (diff)
downloadscummvm-rg350-d2214dca9913011fb9f5f7545309d2d4042fc50c.tar.gz
scummvm-rg350-d2214dca9913011fb9f5f7545309d2d4042fc50c.tar.bz2
scummvm-rg350-d2214dca9913011fb9f5f7545309d2d4042fc50c.zip
Use alpha channel if available.
svn-id: r17354
Diffstat (limited to 'gui')
-rw-r--r--gui/newgui.cpp68
1 files changed, 50 insertions, 18 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 3bbbfc7ee1..232b4f8344 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -311,25 +311,57 @@ void NewGui::blendRect(int x, int y, int w, int h, OverlayColor color, int level
if (!rect.isValidRect())
return;
- int r, g, b;
- uint8 ar, ag, ab;
- _system->colorToRGB(color, ar, ag, ab);
- r = ar * level;
- g = ag * level;
- b = ab * level;
-
- OverlayColor *ptr = getBasePtr(rect.left, rect.top);
-
- h = rect.height();
- w = rect.width();
- while (h--) {
- for (int i = 0; i < w; i++) {
- _system->colorToRGB(ptr[i], ar, ag, ab);
- ptr[i] = _system->RGBToColor((ar + r) / (level+1),
- (ag + g) / (level+1),
- (ab + b) / (level+1));
+ if (_system->hasAlpha()) {
+
+ int a, r, g, b;
+ uint8 aa, ar, ag, ab;
+ _system->colorToARGB(color, aa, ar, ag, ab);
+ a = aa*level/(level+1);
+ if (a < 1)
+ return;
+ r = ar * a;
+ g = ag * a;
+ b = ab * a;
+
+ OverlayColor *ptr = getBasePtr(rect.left, rect.top);
+
+ h = rect.height();
+ w = rect.width();
+ while (h--) {
+ for (int i = 0; i < w; i++) {
+ _system->colorToARGB(ptr[i], aa, ar, ag, ab);
+ int a2 = aa + a - (a*aa)/255;
+ ptr[i] = _system->ARGBToColor(a2,
+ ((255-a)*aa*ar/255+r)/a2,
+ ((255-a)*aa*ag/255+g)/a2,
+ ((255-a)*aa*ab/255+b)/a2);
+ }
+ ptr += _screenPitch;
+ }
+
+ } else {
+
+ int r, g, b;
+ uint8 ar, ag, ab;
+ _system->colorToRGB(color, ar, ag, ab);
+ r = ar * level;
+ g = ag * level;
+ b = ab * level;
+
+ OverlayColor *ptr = getBasePtr(rect.left, rect.top);
+
+ h = rect.height();
+ w = rect.width();
+ while (h--) {
+ for (int i = 0; i < w; i++) {
+ _system->colorToRGB(ptr[i], ar, ag, ab);
+ ptr[i] = _system->RGBToColor((ar + r) / (level+1),
+ (ag + g) / (level+1),
+ (ab + b) / (level+1));
+ }
+ ptr += _screenPitch;
}
- ptr += _screenPitch;
+
}
#endif
}