Use alpha channel if available.
svn-id: r17354
This commit is contained in:
parent
ac54a40ea2
commit
d2214dca99
1 changed files with 48 additions and 16 deletions
|
@ -311,25 +311,57 @@ void NewGui::blendRect(int x, int y, int w, int h, OverlayColor color, int level
|
||||||
if (!rect.isValidRect())
|
if (!rect.isValidRect())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int r, g, b;
|
if (_system->hasAlpha()) {
|
||||||
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);
|
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;
|
||||||
|
|
||||||
h = rect.height();
|
OverlayColor *ptr = getBasePtr(rect.left, rect.top);
|
||||||
w = rect.width();
|
|
||||||
while (h--) {
|
h = rect.height();
|
||||||
for (int i = 0; i < w; i++) {
|
w = rect.width();
|
||||||
_system->colorToRGB(ptr[i], ar, ag, ab);
|
while (h--) {
|
||||||
ptr[i] = _system->RGBToColor((ar + r) / (level+1),
|
for (int i = 0; i < w; i++) {
|
||||||
(ag + g) / (level+1),
|
_system->colorToARGB(ptr[i], aa, ar, ag, ab);
|
||||||
(ab + b) / (level+1));
|
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;
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue