Rev 5825 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5825 | Rev 6746 | ||
---|---|---|---|
1 | #define MEMSIZE 0xFFFFF |
1 | #define MEMSIZE 0xFFFFF |
2 | #include "../lib/kolibri.h" |
2 | #include "../lib/kolibri.h" |
3 | #include "../lib/strings.h" |
3 | #include "../lib/strings.h" |
4 | #include "../lib/mem.h" |
4 | #include "../lib/mem.h" |
5 | #include "../lib/gui.h" |
5 | #include "../lib/gui.h" |
6 | 6 | ||
7 | #ifndef AUTOBUILD |
7 | #ifndef AUTOBUILD |
8 | #include "lang.h--" |
8 | #include "lang.h--" |
9 | #endif |
9 | #endif |
10 | 10 | ||
11 | /* === DATA === */ |
11 | /* === DATA === */ |
12 | 12 | ||
13 | system_colors sc; |
13 | system_colors sc; |
14 | proc_info Form; |
14 | proc_info Form; |
15 | 15 | ||
16 | 16 | ||
17 | dword b_screen, |
17 | dword b_screen, |
18 | s_screen; |
18 | s_screen; |
19 | 19 | ||
20 | int b_screen_width, |
20 | int b_screen_width, |
21 | b_screen_height, |
21 | b_screen_height, |
22 | b_screen_length, |
22 | b_screen_length, |
23 | s_screen_width, |
23 | s_screen_width, |
24 | s_screen_height, |
24 | s_screen_height, |
25 | s_screen_length; |
25 | s_screen_length; |
26 | 26 | ||
27 | 27 | ||
28 | /* === CODE === */ |
28 | /* === CODE === */ |
29 | 29 | ||
30 | 30 | ||
31 | void main() |
31 | void main() |
32 | { |
32 | { |
33 | char id; |
33 | char id; |
34 | mem_Init(); |
34 | mem_Init(); |
35 | b_screen_width = GetScreenWidth()+1; |
35 | b_screen_width = GetScreenWidth()+1; |
36 | b_screen_height = GetScreenHeight()+1; |
36 | b_screen_height = GetScreenHeight()+1; |
37 | b_screen_length = b_screen_width*b_screen_height*3; |
37 | b_screen_length = b_screen_width*b_screen_height*3; |
38 | s_screen_width = b_screen_width / 2; |
38 | s_screen_width = b_screen_width / 2; |
39 | s_screen_height = b_screen_height / 2; |
39 | s_screen_height = b_screen_height / 2; |
40 | s_screen_length = b_screen_length / 2; |
40 | s_screen_length = b_screen_length / 2; |
41 | 41 | ||
42 | b_screen = malloc(b_screen_length); |
42 | b_screen = malloc(b_screen_length); |
43 | s_screen = malloc(b_screen_length/2); |
43 | s_screen = malloc(b_screen_length/2); |
44 | 44 | ||
45 | loop() |
45 | loop() |
46 | { |
46 | { |
47 | switch(WaitEvent()) |
47 | switch(WaitEvent()) |
48 | { |
48 | { |
49 | case evButton: |
49 | case evButton: |
50 | id = GetButtonID(); |
50 | id = GetButtonID(); |
51 | if (id==1) ExitProcess(); |
51 | if (id==1) ExitProcess(); |
52 | if (id==10) TakeScreenshot(); |
52 | if (id==10) TakeScreenshot(); |
53 | break; |
53 | break; |
54 | 54 | ||
55 | case evReDraw: |
55 | case evReDraw: |
56 | sc.get(); |
56 | sc.get(); |
57 | DefineAndDrawWindow(b_screen_width/4, b_screen_height/4, s_screen_width + 9, s_screen_height + GetSkinHeight() + 45,0x74, 0, "EasyShot v0.2",0); |
57 | DefineAndDrawWindow(b_screen_width/4, b_screen_height/4, s_screen_width + 9, s_screen_height + skin_height + 45,0x74, 0, "EasyShot v0.2",0); |
58 | GetProcessInfo(#Form, SelfInfo); |
58 | GetProcessInfo(#Form, SelfInfo); |
59 | if (Form.status_window>2) break; |
59 | if (Form.status_window>2) break; |
60 | DrawBar(0, 0, Form.cwidth, 41, sc.work); |
60 | DrawBar(0, 0, Form.cwidth, 41, sc.work); |
61 | DrawCaptButton(10, 10, 140, 20, 10, sc.work_button, sc.work_button_text, "Make screenshot"); |
61 | DrawCaptButton(10, 10, 140, 20, 10, sc.work_button, sc.work_button_text, "Make screenshot"); |
62 | _PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); |
62 | _PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); |
63 | if (ESDWORD[s_screen]==0) |
63 | if (ESDWORD[s_screen]==0) |
64 | WriteTextB(Form.cwidth/2 - 60, Form.cheight/2+10, 0x90, 0xFFFfff, "There will be preview"); |
64 | WriteTextB(Form.cwidth/2 - 60, Form.cheight/2+10, 0x90, 0xFFFfff, "There will be preview"); |
65 | else |
65 | else |
66 | DrawCaptButton(160, 10, 80, 20, 11, sc.work_button, sc.work_button_text, "Save"); |
66 | DrawCaptButton(160, 10, 80, 20, 11, sc.work_button, sc.work_button_text, "Save"); |
67 | } |
67 | } |
68 | } |
68 | } |
69 | } |
69 | } |
70 | 70 | ||
71 | void TakeScreenshot() { |
71 | void TakeScreenshot() { |
72 | MinimizeWindow(); |
72 | MinimizeWindow(); |
73 | pause(20); |
73 | pause(20); |
74 | CopyScreen(b_screen, 0, 0, b_screen_width, b_screen_height); |
74 | CopyScreen(b_screen, 0, 0, b_screen_width, b_screen_height); |
75 | ZoomImageTo50percent(); |
75 | ZoomImageTo50percent(); |
76 | ActivateWindow(GetProcessSlot(Form.ID)); |
76 | ActivateWindow(GetProcessSlot(Form.ID)); |
77 | //_PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); |
77 | //_PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); |
78 | } |
78 | } |
79 | 79 | ||
80 | void ZoomImageTo50percent() { |
80 | void ZoomImageTo50percent() { |
81 | dword point_x, |
81 | dword point_x, |
82 | item_h= b_screen_width * 3, |
82 | item_h= b_screen_width * 3, |
83 | s_off = s_screen + 3, |
83 | s_off = s_screen + 3, |
84 | b_off = b_screen + 6, |
84 | b_off = b_screen + 6, |
85 | b_off_r, |
85 | b_off_r, |
86 | b_off_g, |
86 | b_off_g, |
87 | b_off_b, |
87 | b_off_b, |
88 | rez_r, |
88 | rez_r, |
89 | rez_g, |
89 | rez_g, |
90 | rez_b; |
90 | rez_b; |
91 | 91 | ||
92 | while( (s_off < s_screen + s_screen_length) && (b_off < b_screen + b_screen_length ) ) { |
92 | while( (s_off < s_screen + s_screen_length) && (b_off < b_screen + b_screen_length ) ) { |
93 | 93 | ||
94 | if (b_off < b_screen + item_h) || (b_off > b_screen + b_screen_length - item_h) |
94 | if (b_off < b_screen + item_h) || (b_off > b_screen + b_screen_length - item_h) |
95 | { |
95 | { |
96 | ESBYTE[s_off] = ESBYTE[b_off]; |
96 | ESBYTE[s_off] = ESBYTE[b_off]; |
97 | ESBYTE[s_off+1] = ESBYTE[b_off+1]; |
97 | ESBYTE[s_off+1] = ESBYTE[b_off+1]; |
98 | ESBYTE[s_off+2] = ESBYTE[b_off+2]; |
98 | ESBYTE[s_off+2] = ESBYTE[b_off+2]; |
99 | } |
99 | } |
100 | else |
100 | else |
101 | { |
101 | { |
102 | // line[x].R = (line[x+1].R + line[x].R + line[x-1].R + line1[x].R + line2[x].R) / 5; |
102 | // line[x].R = (line[x+1].R + line[x].R + line[x-1].R + line1[x].R + line2[x].R) / 5; |
103 | // line[x].G = (line[x+1].G + line[x].G + line[x-1].G + line1[x].G + line2[x].G) / 5; |
103 | // line[x].G = (line[x+1].G + line[x].G + line[x-1].G + line1[x].G + line2[x].G) / 5; |
104 | // line[x].B = (line[x+1].B + line[x].B + line[x-1].B + line1[x].B + line2[x].B) / 5 |
104 | // line[x].B = (line[x+1].B + line[x].B + line[x-1].B + line1[x].B + line2[x].B) / 5 |
105 | b_off_r = b_off; |
105 | b_off_r = b_off; |
106 | b_off_g = b_off + 1; |
106 | b_off_g = b_off + 1; |
107 | b_off_b = b_off + 2; |
107 | b_off_b = b_off + 2; |
108 | rez_r = ESBYTE[b_off_r+3] + ESBYTE[b_off_r] + ESBYTE[b_off_r-3] + ESBYTE[b_off_r-item_h] + ESBYTE[b_off_r+item_h] / 5; |
108 | rez_r = ESBYTE[b_off_r+3] + ESBYTE[b_off_r] + ESBYTE[b_off_r-3] + ESBYTE[b_off_r-item_h] + ESBYTE[b_off_r+item_h] / 5; |
109 | rez_g = ESBYTE[b_off_g+3] + ESBYTE[b_off_g] + ESBYTE[b_off_g-3] + ESBYTE[b_off_g-item_h] + ESBYTE[b_off_g+item_h] / 5; |
109 | rez_g = ESBYTE[b_off_g+3] + ESBYTE[b_off_g] + ESBYTE[b_off_g-3] + ESBYTE[b_off_g-item_h] + ESBYTE[b_off_g+item_h] / 5; |
110 | rez_b = ESBYTE[b_off_b+3] + ESBYTE[b_off_b] + ESBYTE[b_off_b-3] + ESBYTE[b_off_b-item_h] + ESBYTE[b_off_b+item_h] / 5; |
110 | rez_b = ESBYTE[b_off_b+3] + ESBYTE[b_off_b] + ESBYTE[b_off_b-3] + ESBYTE[b_off_b-item_h] + ESBYTE[b_off_b+item_h] / 5; |
111 | ESBYTE[s_off] = rez_r; |
111 | ESBYTE[s_off] = rez_r; |
112 | ESBYTE[s_off+1] = rez_g; |
112 | ESBYTE[s_off+1] = rez_g; |
113 | ESBYTE[s_off+2] = rez_b; |
113 | ESBYTE[s_off+2] = rez_b; |
114 | 114 | ||
115 | } |
115 | } |
116 | 116 | ||
117 | s_off+=3; |
117 | s_off+=3; |
118 | b_off+=6; |
118 | b_off+=6; |
119 | 119 | ||
120 | point_x+=2; |
120 | point_x+=2; |
121 | if (point_x >= b_screen_width) |
121 | if (point_x >= b_screen_width) |
122 | { |
122 | { |
123 | b_off += item_h; |
123 | b_off += item_h; |
124 | point_x = 0; |
124 | point_x = 0; |
125 | } |
125 | } |
126 | } |
126 | } |
127 | } |
127 | } |
128 | 128 | ||
129 | 129 | ||
130 | stop:>>> |
130 | stop:>>> |