Subversion Repositories Kolibri OS

Rev

Rev 7004 | Rev 7422 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6176 leency 1
#ifndef INCLUDE_RGB_H
2
#define INCLUDE_RGB_H
6020 leency 3
 
6271 leency 4
:struct _rgb
6020 leency 5
{
6266 leency 6
	byte b,g,r;
6020 leency 7
	void DwordToRgb();
7031 leency 8
	void SetRgb();
6020 leency 9
	dword RgbToDword();
6052 leency 10
} rgb;
6020 leency 11
 
6271 leency 12
:void _rgb::DwordToRgb(dword _dword)
6020 leency 13
{
6919 leency 14
	b = _dword & 0xFF; _dword >>= 8;
15
	g = _dword & 0xFF; _dword >>= 8;
6020 leency 16
	r = _dword & 0xFF; _dword >>= 8;
17
}
18
 
7031 leency 19
:void _rgb::SetRgb(dword _r, _g, _b)
20
{
21
	r = _r;
22
	g = _g;
23
	b = _b;
24
}
25
 
6271 leency 26
:dword _rgb::RgbToDword()
6020 leency 27
{
7004 leency 28
	dword _r, _g, _b;
29
	_r = r << 16;
6020 leency 30
	_g = g << 8;
7004 leency 31
	_b = b;
32
	return _r + _g + _b;
6020 leency 33
}
6050 leency 34
 
6052 leency 35
:dword MixColors(dword _base, _overlying, byte a)
6050 leency 36
{
6052 leency 37
	_rgb rgb1, rgb2, rgb_final;
6050 leency 38
	byte n_a;
39
 
40
	rgb1.DwordToRgb(_base);
41
	rgb2.DwordToRgb(_overlying);
42
 
43
	n_a = 255 - a;
44
 
6052 leency 45
	rgb_final.b = calc(rgb1.b*a/255) + calc(rgb2.b*n_a/255);
46
	rgb_final.g = calc(rgb1.g*a/255) + calc(rgb2.g*n_a/255);
47
	rgb_final.r = calc(rgb1.r*a/255) + calc(rgb2.r*n_a/255);
6050 leency 48
 
6052 leency 49
	return rgb_final.RgbToDword();
6050 leency 50
}
6176 leency 51
 
52
#endif