Rev 7150 | Rev 7154 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7089 | leency | 1 | struct _colors |
2 | { |
||
7151 | leency | 3 | |
7089 | leency | 4 | unsigned rows, columns; |
7151 | leency | 5 | dword mas[32*32]; |
6 | dword img; |
||
7 | void set_pixel(); |
||
8 | dword get_pixel(); |
||
7089 | leency | 9 | dword get_image(); |
7096 | leency | 10 | void move(); |
7150 | leency | 11 | }; |
7089 | leency | 12 | |
7151 | leency | 13 | void _colors::set_pixel(int _r, _c, _color) |
7089 | leency | 14 | { |
7151 | leency | 15 | mas[columns*_r + _c] = _color; |
7089 | leency | 16 | } |
17 | |||
7151 | leency | 18 | dword _colors::get_pixel(int _r, _c) |
7089 | leency | 19 | { |
7151 | leency | 20 | return mas[columns*_r + _c]; |
7089 | leency | 21 | } |
22 | |||
23 | dword _colors::get_image() |
||
24 | { |
||
25 | int r=0, c=0; |
||
26 | dword i; |
||
27 | |||
7151 | leency | 28 | free(img); |
29 | i = img = malloc(rows*columns*3); |
||
7089 | leency | 30 | |
31 | for (r = 0; r < rows; r++) |
||
32 | { |
||
33 | for (c = 0; c < columns; c++) |
||
34 | { |
||
7151 | leency | 35 | rgb.DwordToRgb(get_pixel(r,c)); |
7089 | leency | 36 | ESBYTE[i] = rgb.b; |
37 | ESBYTE[i+1] = rgb.g; |
||
38 | ESBYTE[i+2] = rgb.r; |
||
39 | i += 3; |
||
40 | } |
||
41 | } |
||
7151 | leency | 42 | return img; |
7089 | leency | 43 | } |
44 | |||
7096 | leency | 45 | enum { |
7151 | leency | 46 | MOVE_LEFT, |
47 | MOVE_RIGHT, |
||
48 | MOVE_UP, |
||
49 | MOVE_DOWN, |
||
50 | FLIP_VER, |
||
51 | FLIP_HOR, |
||
52 | ROTE |
||
7096 | leency | 53 | }; |
7151 | leency | 54 | void _colors::move(int _direction) |
7096 | leency | 55 | { |
56 | int r, c; |
||
57 | dword first_element_data; |
||
58 | |||
7151 | leency | 59 | if (_direction == MOVE_LEFT) |
7096 | leency | 60 | { |
61 | for (r = 0; r < rows; r++) |
||
62 | { |
||
7151 | leency | 63 | first_element_data = get_pixel(r, 0); |
64 | for (c = 0; c < columns-1; c++) set_pixel(r, c, get_pixel(r, c+1)); |
||
65 | set_pixel(r, columns-1, first_element_data); |
||
7096 | leency | 66 | } |
67 | } |
||
7151 | leency | 68 | if (_direction == MOVE_RIGHT) |
7096 | leency | 69 | { |
70 | for (r = 0; r < rows; r++) |
||
71 | { |
||
7151 | leency | 72 | first_element_data = get_pixel(r, columns-1); |
73 | for (c = columns-1; c > 0; c--) set_pixel(r, c, get_pixel(r, c-1)); |
||
74 | set_pixel(r, 0, first_element_data); |
||
7096 | leency | 75 | } |
76 | } |
||
7151 | leency | 77 | if (_direction == MOVE_UP) |
7147 | leency | 78 | { |
79 | for (c = 0; c < columns; c++) |
||
80 | { |
||
7151 | leency | 81 | first_element_data = get_pixel(0, c); |
82 | for (r = 0; r < rows-1; r++) set_pixel(r, c, get_pixel(r+1, c)); |
||
83 | set_pixel(rows-1, c, first_element_data); |
||
7147 | leency | 84 | } |
85 | } |
||
7151 | leency | 86 | if (_direction == MOVE_DOWN) |
7147 | leency | 87 | { |
88 | for (c = 0; c < columns; c++) |
||
89 | { |
||
7151 | leency | 90 | first_element_data = get_pixel(rows-1, c); |
91 | for (r = rows-1; r > 0; r--) set_pixel(r, c, get_pixel(r-1, c)); |
||
92 | set_pixel(0, c, first_element_data); |
||
7147 | leency | 93 | } |
94 | } |
||
7096 | leency | 95 | |
7151 | leency | 96 | |
97 | if (_direction == FLIP_HOR) |
||
98 | { |
||
99 | for (r = 0; r < rows; r++) |
||
100 | { |
||
101 | for (c = 0; c < columns/2; c++) { |
||
102 | first_element_data = get_pixel(r, c); |
||
103 | set_pixel(r, c, get_pixel(r, columns-c)); |
||
104 | set_pixel(r, columns-c, first_element_data); |
||
105 | } |
||
106 | } |
||
107 | } |
||
7096 | leency | 108 | }>>>>>>>>>> |
7147 | leency | 109 |