2016-01-01 17:35:53 +01:00
|
|
|
|
|
|
|
struct _rgb
|
|
|
|
{
|
|
|
|
byte r,g,b;
|
|
|
|
void DwordToRgb();
|
|
|
|
dword RgbToDword();
|
2016-01-10 21:02:47 +01:00
|
|
|
};
|
2016-01-01 17:35:53 +01:00
|
|
|
|
|
|
|
void _rgb::DwordToRgb(dword _dword)
|
|
|
|
{
|
|
|
|
r = _dword & 0xFF; _dword >>= 8;
|
|
|
|
g = _dword & 0xFF; _dword >>= 8;
|
|
|
|
b = _dword & 0xFF; _dword >>= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
dword _rgb::RgbToDword()
|
|
|
|
{
|
|
|
|
dword _b, _g;
|
|
|
|
_b = b << 16;
|
|
|
|
_g = g << 8;
|
|
|
|
return _b + _g + r;
|
|
|
|
}
|
2016-01-10 21:02:47 +01:00
|
|
|
|
|
|
|
dword MixColors(dword _base, _overlying, byte a)
|
|
|
|
{
|
|
|
|
_rgb rgb1, rgb2, rgb;
|
|
|
|
byte n_a;
|
|
|
|
|
|
|
|
rgb1.DwordToRgb(_base);
|
|
|
|
rgb2.DwordToRgb(_overlying);
|
|
|
|
|
|
|
|
n_a = 255 - a;
|
|
|
|
|
|
|
|
rgb.b = calc(rgb1.b*a/255) + calc(rgb2.b*n_a/255);
|
|
|
|
rgb.g = calc(rgb1.g*a/255) + calc(rgb2.g*n_a/255);
|
|
|
|
rgb.r = calc(rgb1.r*a/255) + calc(rgb2.r*n_a/255);
|
|
|
|
|
|
|
|
return rgb.RgbToDword();
|
|
|
|
}
|