2016-02-09 04:43:58 +03:00
|
|
|
#ifndef INCLUDE_RGB_H
|
|
|
|
#define INCLUDE_RGB_H
|
2016-01-01 19:35:53 +03:00
|
|
|
|
2016-02-21 01:09:50 +03:00
|
|
|
:struct _rgb
|
2016-01-01 19:35:53 +03:00
|
|
|
{
|
2016-02-20 19:15:35 +03:00
|
|
|
byte b,g,r;
|
2016-01-01 19:35:53 +03:00
|
|
|
void DwordToRgb();
|
|
|
|
dword RgbToDword();
|
2016-01-10 23:07:03 +03:00
|
|
|
} rgb;
|
2016-01-01 19:35:53 +03:00
|
|
|
|
2016-02-21 01:09:50 +03:00
|
|
|
:void _rgb::DwordToRgb(dword _dword)
|
2016-01-01 19:35:53 +03:00
|
|
|
{
|
|
|
|
b = _dword & 0xFF; _dword >>= 8;
|
2017-06-09 20:43:00 +03:00
|
|
|
g = _dword & 0xFF; _dword >>= 8;
|
|
|
|
r = _dword & 0xFF; _dword >>= 8;
|
2016-01-01 19:35:53 +03:00
|
|
|
}
|
|
|
|
|
2016-02-21 01:09:50 +03:00
|
|
|
:dword _rgb::RgbToDword()
|
2016-01-01 19:35:53 +03:00
|
|
|
{
|
2017-09-23 14:02:57 +03:00
|
|
|
dword _r, _g, _b;
|
|
|
|
_r = r << 16;
|
2016-01-01 19:35:53 +03:00
|
|
|
_g = g << 8;
|
2017-09-23 14:02:57 +03:00
|
|
|
_b = b;
|
|
|
|
return _r + _g + _b;
|
2016-01-01 19:35:53 +03:00
|
|
|
}
|
2016-01-10 23:02:47 +03:00
|
|
|
|
2016-01-10 23:07:03 +03:00
|
|
|
:dword MixColors(dword _base, _overlying, byte a)
|
2016-01-10 23:02:47 +03:00
|
|
|
{
|
2016-01-10 23:07:03 +03:00
|
|
|
_rgb rgb1, rgb2, rgb_final;
|
2016-01-10 23:02:47 +03:00
|
|
|
byte n_a;
|
|
|
|
|
|
|
|
rgb1.DwordToRgb(_base);
|
|
|
|
rgb2.DwordToRgb(_overlying);
|
|
|
|
|
|
|
|
n_a = 255 - a;
|
|
|
|
|
2016-01-10 23:07:03 +03:00
|
|
|
rgb_final.b = calc(rgb1.b*a/255) + calc(rgb2.b*n_a/255);
|
|
|
|
rgb_final.g = calc(rgb1.g*a/255) + calc(rgb2.g*n_a/255);
|
|
|
|
rgb_final.r = calc(rgb1.r*a/255) + calc(rgb2.r*n_a/255);
|
2016-01-10 23:02:47 +03:00
|
|
|
|
2016-01-10 23:07:03 +03:00
|
|
|
return rgb_final.RgbToDword();
|
2016-01-10 23:02:47 +03:00
|
|
|
}
|
2016-02-09 04:43:58 +03:00
|
|
|
|
|
|
|
#endif
|