Subversion Repositories Kolibri OS

Rev

Rev 7422 | 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
{
7450 leency 28
	/*
7004 leency 29
	dword _r, _g, _b;
30
	_r = r << 16;
6020 leency 31
	_g = g << 8;
7004 leency 32
	_b = b;
33
	return _r + _g + _b;
7450 leency 34
	*/
35
	EAX = r << 16;
36
	EAX += g << 8;
37
	EAX += b;
6020 leency 38
}
6050 leency 39
 
7422 leency 40
:dword MixColors(dword _base, _overlying, dword a)
6050 leency 41
{
6052 leency 42
	_rgb rgb1, rgb2, rgb_final;
7422 leency 43
	dword n_a;
6050 leency 44
 
45
	rgb1.DwordToRgb(_base);
46
	rgb2.DwordToRgb(_overlying);
47
 
48
	n_a = 255 - a;
49
 
6052 leency 50
	rgb_final.b = calc(rgb1.b*a/255) + calc(rgb2.b*n_a/255);
51
	rgb_final.g = calc(rgb1.g*a/255) + calc(rgb2.g*n_a/255);
52
	rgb_final.r = calc(rgb1.r*a/255) + calc(rgb2.r*n_a/255);
6050 leency 53
 
6052 leency 54
	return rgb_final.RgbToDword();
6050 leency 55
}
6176 leency 56
 
57
#endif