Subversion Repositories Kolibri OS

Rev

Rev 9635 | Rev 9644 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9635 Rev 9643
Line 1... Line 1...
1
#define MEMSIZE 1024*100
1
#define MEMSIZE 1024*100
Line -... Line 2...
-
 
2
 
-
 
3
/*=====================================================
-
 
4
|                                                     |
-
 
5
|                         LIB                         |
-
 
6
|                                                     |
-
 
7
=====================================================*/
2
 
8
 
3
#include "../lib/gui.h"
9
#include "../lib/gui.h"
4
#include "../lib/random.h"
10
#include "../lib/random.h"
5
#include "../lib/mem.h"
11
#include "../lib/mem.h"
6
#include "../lib/cursor.h"
12
#include "../lib/cursor.h"
Line 13... Line 19...
13
 
19
 
14
#include "../lib/patterns/rgb.h"
20
#include "../lib/patterns/rgb.h"
15
#include "../lib/patterns/toolbar_button.h"
21
#include "../lib/patterns/toolbar_button.h"
Line 16... Line 22...
16
#include "../lib/patterns/simple_open_dialog.h"
22
#include "../lib/patterns/simple_open_dialog.h"
17
 
23
 
18
//===================================================//
24
/*=====================================================
19
//                                                   //
25
|                                                     |
20
//                       DATA                        //
26
|                        DATA                         |
21
//                                                   //
27
|                                                     |
22
//===================================================//
-
 
23
 
28
=====================================================*/
24
//Sizes
-
 
25
#define PAD 13
-
 
26
#define TOOLBAR_ITEM_H PAD + PAD
-
 
27
#define TOOLBAR_W 132
-
 
28
#define STATUSBAR_H 20
-
 
29
#define HEADERH TOOLBAR_ITEM_H + 14
-
 
30
#define HEADER_TEXTY HEADERH - 14 / 2
-
 
31
#define CANVASX TOOLBAR_W + PAD + PAD
-
 
32
#define CANVASY HEADERH + 2
-
 
33
 
-
 
34
// Colors
-
 
35
#define COL_WORK        0x242424
-
 
36
#define COL_WORK_TEXT   0xBEBEBE
-
 
37
#define COL_LIGHT       0x424242
-
 
38
#define COL_DARK        0x1D1D1D
-
 
39
#define COL_LINE        0x010101
-
 
40
#define COL_BUTTON      0x181818
-
 
41
#define COL_BUTTON_TEXT 0x18A2CC
-
 
42
 
-
 
43
block canvas = { CANVASX, CANVASY, NULL, NULL };
-
 
44
 
-
 
45
EVENTS button;
-
 
46
EVENTS key;
-
 
47
 
-
 
48
proc_info Form;
-
 
49
int pressed_button_id;
-
 
50
 
-
 
51
char default_dir[4096] = "/sys";
-
 
52
od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" };
-
 
53
 
-
 
54
libimg_image icons18;
-
 
55
libimg_image icons18a;
-
 
56
libimg_image pixie_skin;
-
 
57
libimg_image main_image;
-
 
58
 
-
 
59
scroll_bar scroll_v = { 15,NULL,NULL,HEADERH+1,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
-
 
60
scroll_bar scroll_h = { NULL,TOOLBAR_W+PAD+PAD,15,NULL,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
-
 
61
 
-
 
62
enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4 };
-
 
63
int saving_type=SAVE_AS_PNG;
-
 
64
 
-
 
65
char* libimg_bpp[] = { "-", "8pal", "24", "32", "15", "16",
-
 
66
"mono", "8gray", "2pal", "4pal", "8gr/a" };
-
 
67
 
-
 
68
enum {
-
 
69
	TOOL_CROP=1, 
-
 
70
	TOOL_RESIZE=2,
-
 
71
	TOOL_COLOR_DEPTH=4,
-
 
72
	TOOL_FLIP_ROTATE=8
-
 
73
};
29
 
74
int active_tool = NULL;
30
#include "data.h"
75
 
31
 
76
//===================================================//
32
/*=====================================================
77
//                                                   //
33
|                                                     |
78
//                       CODE                        //
34
|                        CODE                         |
79
//                                                   //
-
 
80
//===================================================//
-
 
81
 
-
 
82
void init_ui()
-
 
83
{
-
 
84
	icons18.load("/sys/icons16.png");
-
 
85
	icons18.replace_2colors(0xffFFFfff, COL_LIGHT, 0xffCACBD6, COL_LIGHT-0x080808);
-
 
86
	icons18a.load("/sys/icons16.png");
-
 
87
	icons18a.replace_2colors(0xffFFFfff, COL_BUTTON, 0xffCACBD6, 0);
-
 
88
 
-
 
Line 89... Line 35...
89
	pixie_skin.load("/sys/media/pixieskn.png");
35
|                                                     |
90
}
36
=====================================================*/
-
 
37
 
91
 
38
void main()
92
void main()
39
{
93
{
40
	/* Init external libraries */
94
	load_dll(libimg, #libimg_init, 1);
41
	load_dll(libimg, #libimg_init, 1);
Line -... Line 42...
-
 
42
	load_dll(boxlib, #box_lib_init,0);
-
 
43
	load_dll(Proc_lib, #OpenDialog_init,0);
-
 
44
	OpenDialog_init stdcall (#o_dialog);
-
 
45
 
-
 
46
	/* Init UI */
-
 
47
	icons18.load("/sys/icons16.png");
-
 
48
	icons18.replace_2colors(0xffFFFfff, COL_LIGHT, 0xffCACBD6, COL_LIGHT-0x080808);
-
 
49
	icons18a.load("/sys/icons16.png");
-
 
50
	icons18a.replace_2colors(0xffFFFfff, COL_BUTTON, 0xffCACBD6, 0);
-
 
51
	pixie_skin.load("/sys/media/pixieskn.png");
95
	load_dll(boxlib, #box_lib_init,0);
52
	Form.width = screen.w/6*5;
Line -... Line 53...
-
 
53
	Form.height = screen.h/6*5;
96
	load_dll(Proc_lib, #OpenDialog_init,0);
54
 
97
	OpenDialog_init stdcall (#o_dialog);
55
	/* Handle application parameters */
98
 
56
	//if (!param) open_image("/sys/home.png");
99
	open_image("/sys/home.png");
57
 
100
 
58
	/* Set event mask and go to main loop */
101
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
59
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
102
	loop() switch(WaitEvent())
60
	loop() switch(WaitEvent())
103
	{
61
	{
104
		case evMouse:
62
		case evMouse:
105
			mouse.get();
63
			mouse.get();
106
			scrollbar_v_mouse stdcall(#scroll_v);
64
			if (main_image.h > canvas.h) scrollbar_v_mouse stdcall(#scroll_v);
107
			scrollbar_h_mouse stdcall(#scroll_h);
65
			if (main_image.w > canvas.w) scrollbar_h_mouse stdcall(#scroll_h);
Line 136... Line 94...
136
	}
94
	}
137
}
95
}
Line 138... Line 96...
138
 
96
 
139
void draw_window()
97
void draw_window()
140
{
-
 
141
	Form.width = screen.w/6*5;
-
 
142
	Form.height = screen.h/6*5;
98
{
143
	DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x42, NULL, NULL, 0);
99
	DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x42, NULL, NULL, 0);
-
 
100
	GetProcessInfo(#Form, SelfInfo);
-
 
101
	/* Draw window borders */
-
 
102
	DrawRectangle(0,0,Form.width,Form.height,COL_LINE);
-
 
103
	DrawRectangle(1,1,Form.width-2,Form.height-2,COL_LIGHT);
144
	GetProcessInfo(#Form, SelfInfo);
104
	/* Check if the window is collapsed into header */
-
 
105
	if (Form.status_window&ROLLED_UP) {
-
 
106
		DrawBar(2, 2, Form.width-3, skin_h-4, COL_WORK);
-
 
107
		WriteText(5, skin_h-11/2, 0x90, COL_WORK_TEXT, "ImageEditor Pro [Collapsed]");
-
 
108
		draw_window_manipulation_buttons(skin_h-17/2);
-
 
109
		return;
145
	if (Form.status_window&ROLLED_UP) return;
110
	}
146
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
111
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
147
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
112
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
148
	scroll_v.all_redraw = scroll_h.all_redraw = 1;
113
	scroll_v.all_redraw = scroll_h.all_redraw = 1;
149
	draw_content();
114
	draw_content();
Line 153... Line 118...
153
{
118
{
154
	incn tx;
119
	incn tx;
155
	button.init(40);
120
	button.init(40);
156
	key.init(40);
121
	key.init(40);
Line 157... Line -...
157
 
-
 
158
	init_ui();
122
 
159
	canvas.w = Form.cwidth - CANVASX - 1;
123
	canvas.w = Form.cwidth - CANVASX - 1;
160
	canvas.h = Form.cheight - STATUSBAR_H - CANVASY - 1;
124
	canvas.h = Form.cheight - STATUSBAR_H - CANVASY - 1;
161
	if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1;
125
	if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1;
Line 162... Line 126...
162
	if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1;
126
	if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1;
163
 
-
 
164
	//window border and panel border
-
 
165
	DrawRectangle(0,0,Form.width,Form.height,COL_LINE);
127
 
Line 166... Line 128...
166
	DrawRectangle(1,1,Form.width-2,Form.height-2,COL_LIGHT);
128
	//draw panel border
167
	DrawBar(CANVASX, 0, 1, Form.cheight, COL_LINE);
129
	DrawBar(CANVASX, 0, 1, Form.cheight, COL_LINE);
168
 
130
 
Line 169... Line 131...
169
	//draw title
131
	//draw title
170
	DrawBar(2, 2, CANVASX-2, HEADERH-1, COL_DARK);
-
 
171
	WriteText(PAD+5, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "ImageEditor Pro");
132
	DrawBar(2, 2, CANVASX-2, HEADERH-1, COL_DARK);
172
 
-
 
173
	//draw header
-
 
174
	DrawBar(CANVASX+1, 2, Form.width-CANVASX-2, HEADERH-1, COL_WORK);
-
 
175
	DrawBar(CANVASX+1, CANVASY-1, Form.width-CANVASX-2, 1, COL_LINE);
133
	WriteText(PAD+5, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "ImageEditor Pro");
-
 
134
 
Line 176... Line 135...
176
	img_draw stdcall(pixie_skin.image, Form.width-63, 7, 57, 18, 265, 0);
135
	//draw header
177
	DefineHiddenButton(Form.width-63, 7, 28, 17, button.add(#MinimizeWindow));
136
	DrawBar(CANVASX+1, CANVASY-1, Form.width-CANVASX-2, 1, COL_LINE);
Line 178... Line 137...
178
	DefineHiddenButton(Form.width-35, 7, 28, 17, 1);
137
	draw_acive_panel();
Line 188... Line 147...
188
	#define GAP_S TOOLBAR_ITEM_H+8
147
	#define GAP_S TOOLBAR_ITEM_H+8
189
	#define GAP_B TOOLBAR_ITEM_H+23
148
	#define GAP_B TOOLBAR_ITEM_H+23
190
	tx.set(PAD-GAP_S+HEADERH);
149
	tx.set(PAD-GAP_S+HEADERH);
191
	//draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false);
150
	//draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false);
192
	draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image", false);
151
	draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image  ", false);
193
	//draw_tool_btn(13, ECTRL + SCAN_CODE_LEFT,  PAD, tx.inc(GAP_B), 30, false);
-
 
194
	//draw_tool_btn(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
-
 
195
	//draw_tool_btn(15, ECTRL + SCAN_CODE_UP,    PAD, tx.inc(GAP_S), 32, false);
-
 
196
	//draw_tool_btn(16, ECTRL + SCAN_CODE_DOWN,  PAD, tx.inc(GAP_S), 33, false);
-
 
197
	if (!main_image.image) goto _NO_IMAGE;
152
	if (main_image.image) {
198
 
-
 
199
 	draw_tool_btn(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save as", false);
153
	 	draw_tool_btn(#event_activate_export, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_S), 05, "Export image", active_tool & TOOL_EXPORT);
200
 	draw_tool_btn(#event_save_png, 0, PAD, tx.inc(GAP_S), -1, "PNG", saving_type & SAVE_AS_PNG);
-
 
201
	draw_tool_btn(#event_save_bmp, 0, PAD*2+34, tx.n,     -1, "BMP", saving_type & SAVE_AS_BMP);
-
 
202
	draw_tool_btn(#event_save_raw, 0, PAD*3+68, tx.n,     -1, "RAW", saving_type & SAVE_AS_RAW);
-
 
203
 
-
 
204
 	draw_tool_btn(#event_activate_crop,  0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
154
	 	//draw_tool_btn(#event_activate_crop,  0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
205
	draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_S), 06, "Resize", active_tool & TOOL_RESIZE);
155
		//draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_B), 06, "Resize      ", active_tool & TOOL_RESIZE);
206
	draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_S), 52, "Color depth", active_tool & TOOL_COLOR_DEPTH);
156
		draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_B), 52, "Color depth ", active_tool & TOOL_COLOR_DEPTH);
207
	draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate", active_tool & TOOL_FLIP_ROTATE);
157
		draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate ", active_tool & TOOL_FLIP_ROTATE);		
208
	_NO_IMAGE:
-
 
209
 
158
	}
210
	draw_status_bar();
159
	draw_status_bar();
211
	draw_canvas();
160
	draw_canvas();
212
}
161
}
Line -... Line 162...
-
 
162
 
-
 
163
void draw_window_manipulation_buttons(int y)
-
 
164
{
-
 
165
	DrawBar(Form.width-65, 2, 63, HEADERH-1, COL_WORK);
-
 
166
	img_draw stdcall(pixie_skin.image, Form.width-63, y, 57, 18, 265, 0);
-
 
167
	DefineHiddenButton(Form.width-63, y, 28, 17, button.add(#MinimizeWindow));
-
 
168
	DefineHiddenButton(Form.width-35, y, 28, 17, 1);
-
 
169
}
213
 
170
 
214
void draw_status_bar()
171
void draw_status_bar()
215
{
172
{
216
	char img_info[24];
173
	char img_info[24];
217
	sprintf(#img_info, "%i\01%i\02%s", main_image.w, main_image.h, libimg_bpp[main_image.type]);
174
	sprintf(#img_info, "%i\01%i\02%s", main_image.w, main_image.h, libimg_bpp[main_image.type]);
Line 226... Line 183...
226
	$int 64
183
	$int 64
227
}
184
}
Line 228... Line 185...
228
 
185
 
229
int draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active)
186
int draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active)
230
{
-
 
231
	int w = TOOLBAR_W;
187
{
-
 
188
	dword img_ptr = icons18.image;
-
 
189
 
232
	dword img_ptr = icons18.image;
190
	int w = 32; //default width: icon only
233
	if (!_text) w = PAD + PAD + 6;
191
	if (_text) {
-
 
192
		w = strlen(_text) * 8 + 15;
-
 
193
		if (_icon_n!=-1) w += 26;
-
 
194
	}
234
	if (_icon_n==-1) w = strlen(_text) * 8 + 14;
195
 
235
	if (_active==-1) {
196
	if (_active==-1) {
236
		$push COL_LIGHT
197
		$push COL_LIGHT
237
		EDX = COL_LINE;
198
		EDX = COL_LINE;
238
	} else if (_active) {
199
	} else if (_active) {
Line 300... Line 261...
300
	set_file_path(_path);
261
	set_file_path(_path);
301
	scroll_v.position = 0;
262
	scroll_v.position = 0;
302
	scroll_h.position = 0;
263
	scroll_h.position = 0;
303
}
264
}
Line 304... Line -...
304
 
-
 
305
int color_depth_id;
265
 
306
void event_set_color_depth() {
266
void event_set_color_depth() {
307
	img_convert stdcall(main_image.image, 0, pressed_button_id-color_depth_id, 0, 0);
267
	img_convert stdcall(main_image.image, 0, pressed_button_id-color_depth_btnid_1, 0, 0);
308
	if (!EAX) {
268
	if (!EAX) {
309
		notify("'ImageEdit Pro\nConvertation error' -Et");
269
		notify("'ImageEdit Pro\nNot possible to convert into specified color depth' -Et");
310
	} else {
270
	} else {
311
		$push eax
271
		$push eax
312
		img_destroy stdcall(main_image.image);
272
		img_destroy stdcall(main_image.image);
313
		$pop eax
273
		$pop eax
Line 317... Line 277...
317
		draw_status_bar();
277
		draw_status_bar();
318
		draw_canvas();
278
		draw_canvas();
319
	}
279
	}
320
}
280
}
Line -... Line 281...
-
 
281
 
321
 
282
void WritePanelText(int _x, _text) { WriteTextWithBg(_x, HEADER_TEXTY, 0xD0, COL_WORK_TEXT, _text, COL_WORK); }
322
void draw_acive_panel()
283
void draw_acive_panel()
-
 
284
{
-
 
285
	char edit_width_text[8];
323
{
286
	edit_box edit_width;
324
	int i, x = CANVASX + PAD;
287
	int i, x = CANVASX + PAD;
-
 
288
	bool a;
325
	bool a;
289
	DrawBar(CANVASX+1, 2, Form.width-CANVASX-64, HEADERH-1, COL_WORK);
-
 
290
	switch(active_tool) {
-
 
291
		case TOOL_EXPORT:
-
 
292
			WritePanelText(CANVASX+PAD, "Format");
-
 
293
			x += 6*8 + PAD;
-
 
294
		 	x += draw_tool_btn(#event_save_png, 0, x, 7, -1, "PNG", saving_type & SAVE_AS_PNG) + PAD;
-
 
295
			x += draw_tool_btn(#event_save_pnm, 0, x, 7, -1, "PNM", saving_type & SAVE_AS_PNM) + PAD;
-
 
296
			x += draw_tool_btn(#event_save_bmp, 0, x, 7, -1, "BMP", saving_type & SAVE_AS_BMP) + PAD + PAD;
-
 
297
			if (saving_type) draw_tool_btn(#event_save,     0, x, 7, 53, "Export", false);
326
	switch(active_tool) {
298
			break;
327
		case TOOL_CROP:
299
		case TOOL_CROP:
328
			WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Crop tool");
300
			WritePanelText(CANVASX+PAD, "Crop tool");
329
			break;
301
			break;
330
		case TOOL_RESIZE:
302
		case TOOL_RESIZE:
331
			WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "New width");
303
			WritePanelText(CANVASX+PAD, "New width");
332
			WriteText(CANVASX+PAD+150, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "New height");
304
			WritePanelText(CANVASX+PAD+150, "New height");
-
 
305
			draw_tool_btn(#event_rotate_left, SCAN_CODE_ENTER, CANVASX + PAD + 300, 7, -1, "Apply", false);
-
 
306
			EditBox_Create(#edit_width, 9*8+CANVASX+PAD+PAD, HEADER_TEXTY-3, 50, sizeof(edit_width_text), #edit_width_text, 0b);
333
			draw_tool_btn(#event_rotate_left, SCAN_CODE_ENTER, CANVASX + PAD + 300, 7, -1, "Apply", false);
307
			edit_box_draw stdcall (#edit_width);
334
			break;
308
			break;
335
		case TOOL_COLOR_DEPTH:
309
		case TOOL_COLOR_DEPTH:
336
			WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Color depth");
310
			WritePanelText(CANVASX+PAD, "Color depth");
337
			x += 11*8 + PAD;
311
			x += 11*8 + PAD;
338
			color_depth_id = button.new_id;
312
			color_depth_btnid_1 = button.new_id;
-
 
313
			for (i=1; i<11; i++) {
339
			for (i=1; i<11; i++) {
314
				DeleteButton(color_depth_btnid_1+i);
340
				if (main_image.type == i) {
315
				if (main_image.type == i) {
341
					//this is current image depth
-
 
342
					a = true; 
316
					a = true; //this is current image depth
343
				} else {
317
				} else {
344
					//this is image ve san set
-
 
345
					a = false;
318
					a = false; //this is image depth we can set
346
					//probe does libimg support converting current image gepth to i-one
319
					//probe does libimg support converting current image gepth to i-one
347
					img_create stdcall(1, 1, main_image.type);
320
					img_create stdcall(1, 1, main_image.type);
348
					img_convert stdcall(EAX, 0, i, 0, 0);
321
					img_convert stdcall(EAX, 0, i, 0, 0);
349
					if (EAX) {
322
					if (EAX) {
350
						img_destroy stdcall(EAX); 
323
						img_destroy stdcall(EAX); 
351
					} else {
324
					} else {
-
 
325
						a = -1;
-
 
326
						if (Form.width-CANVASX-64 < 652) {
-
 
327
							button.add(1);
-
 
328
							continue;							
352
						a = -1;
329
						}
353
					}
330
					}
354
				}
331
				}
355
				x += draw_tool_btn(#event_set_color_depth, SCAN_CODE_ENTER, x, 7, -1, libimg_bpp[i], a) + PAD;			
332
				x += draw_tool_btn(#event_set_color_depth, SCAN_CODE_ENTER, x, 7, -1, libimg_bpp[i], a) + PAD;			
356
			}
333
			}
357
			break;
334
			break;
358
		case TOOL_FLIP_ROTATE:
335
		case TOOL_FLIP_ROTATE:
359
			WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Flip");
336
			WritePanelText(CANVASX+PAD, "Flip");
360
			draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, CANVASX + PAD + 040, 7, 34, NULL, false);
337
			draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, CANVASX + PAD + 040, 7, 34, NULL, false);
361
			draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, CANVASX + PAD + 080, 7, 35, NULL, false);
338
			draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, CANVASX + PAD + 080, 7, 35, NULL, false);
362
			WriteText(CANVASX+PAD + 142, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Rotate");
339
			WritePanelText(CANVASX+PAD + 142, "Rotate");
363
			draw_tool_btn(#event_rotate_left,   ECTRL + SCAN_CODE_KEY_L, CANVASX + PAD + 200, 7, 37, NULL, false);
340
			draw_tool_btn(#event_rotate_left,  ECTRL + SCAN_CODE_KEY_L, CANVASX + PAD + 200, 7, 37, NULL, false);
364
			draw_tool_btn(#event_rotate_right,   ECTRL + SCAN_CODE_KEY_R, CANVASX + PAD + 240, 7, 36, NULL, false);
341
			draw_tool_btn(#event_rotate_right, ECTRL + SCAN_CODE_KEY_R, CANVASX + PAD + 240, 7, 36, NULL, false);
365
			// WriteText(CANVASX+PAD + 142, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Move");
342
			// WritePanelText(CANVASX+PAD + 142, "Move");
366
			// DrawTopPanelButton1(#EventMoveLeft,       ECTRL + SCAN_CODE_LEFT,  tx.inc(GAP_B), 30);
343
			//draw_tool_btn(#event_move_left,  ECTRL + SCAN_CODE_LEFT,  PAD, tx.inc(GAP_B), 30, false);
367
			// DrawTopPanelButton1(#EventMoveRight,      ECTRL + SCAN_CODE_RIGHT, tx.inc(GAP_S), 31);
344
			//draw_tool_btn(#event_move_right, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
368
			// DrawTopPanelButton1(#EventMoveUp,         ECTRL + SCAN_CODE_UP,    tx.inc(GAP_S), 32);
345
			//draw_tool_btn(#event_move_up,    ECTRL + SCAN_CODE_UP,    PAD, tx.inc(GAP_S), 32, false);
369
			// DrawTopPanelButton1(#EventMoveDown,       ECTRL + SCAN_CODE_DOWN,  tx.inc(GAP_S), 33);
346
			//draw_tool_btn(#event_move_down,  ECTRL + SCAN_CODE_DOWN,  PAD, tx.inc(GAP_S), 33, false);
370
			break;
347
			break;
371
		default:
348
		default:
372
			WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Welcome to ImageEditor Pro! Try to open a file.");
349
			if (!param) WritePanelText(CANVASX+PAD, "Welcome to ImageEditor Pro! Try to open a file.");
373
	}
350
	}
Line 374... Line 351...
374
}
351
}
375
 
352
 
376
//===================================================//
353
//===================================================//
377
//                                                   //
354
//                                                   //
378
//                      EVENTS                       //
355
//                      EVENTS                       //
Line -... Line 356...
-
 
356
//                                                   //
-
 
357
//===================================================//
-
 
358
 
-
 
359
void event_save_png() { saving_type = SAVE_AS_PNG; draw_acive_panel(); }
-
 
360
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_acive_panel(); }
-
 
361
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_acive_panel(); }
-
 
362
void event_save_pnm() { saving_type = SAVE_AS_PNM; draw_acive_panel(); }
-
 
363
void event_activate_export() { active_tool = TOOL_EXPORT; draw_content(); }
-
 
364
void event_activate_crop() { active_tool = TOOL_CROP; draw_content(); }
-
 
365
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_content(); }
379
//                                                   //
366
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_content(); }
380
//===================================================//
367
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
381
 
368
 
382
void event_open()
369
void event_open()
383
{
370
{
Line 413... Line 400...
413
	img_rotate stdcall (main_image.image, ROTATE_90_CW);
400
	img_rotate stdcall (main_image.image, ROTATE_90_CW);
414
	main_image.w >< main_image.h;
401
	main_image.w >< main_image.h;
415
	draw_content();
402
	draw_content();
416
}
403
}
Line 417... Line -...
417
 
-
 
418
void event_save_png() { saving_type = SAVE_AS_PNG; draw_content(); }
-
 
419
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_content(); }
-
 
420
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_content(); }
-
 
421
 
-
 
422
void event_activate_crop() { active_tool = TOOL_CROP; draw_content(); }
-
 
423
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_content(); }
-
 
424
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_content(); }
-
 
425
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
-
 
426
 
404
 
427
void event_save()
405
void event_save()
428
{
406
{
-
 
407
	dword _image_format, _image_depth;
-
 
408
	strcpy(#filename_area, #param + strrchr(#param, '/'));
429
	o_dialog.type = 1; //save file
409
	if (EAX = strrchr(#filename_area, '.'))	filename_area[EAX-1] = '\0';
430
	switch (saving_type) {
410
	switch (saving_type) {
431
		case SAVE_AS_PNG:
411
		case SAVE_AS_PNG:
432
				strcpy(#filename_area, "image.png");
412
				strcat(#filename_area, "_IEP.png");
433
				OpenDialog_start stdcall (#o_dialog);
-
 
434
				if (o_dialog.status) {
413
				_image_format = LIBIMG_FORMAT_PNG;
435
					set_file_path(#openfile_path);
-
 
436
					img_to_rgb stdcall (main_image.image);
-
 
437
					save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path);
-
 
438
				}
414
				_image_depth = IMAGE_BPP24;
439
				break;
415
				break;
-
 
416
		case SAVE_AS_BMP:
-
 
417
				strcat(#filename_area, "_IEP.bmp");
-
 
418
				_image_format = LIBIMG_FORMAT_BMP;
-
 
419
				_image_depth = IMAGE_BPP24;
-
 
420
				break;
440
		case SAVE_AS_BMP:
421
		case SAVE_AS_PNM:
-
 
422
				strcat(#filename_area, "_IEP.pnm");
-
 
423
				_image_format = LIBIMG_FORMAT_PNM;
441
				notify("Not implemented yet.");
424
				_image_depth = IMAGE_BPP24;
442
				break;
425
				break;
443
		case SAVE_AS_RAW:
426
		case SAVE_AS_RAW:
444
				notify("Not implemented yet.");
427
				notify("Not implemented yet.");
-
 
428
				return;
-
 
429
	}
-
 
430
	o_dialog.type = 1; //save file
-
 
431
	OpenDialog_start stdcall (#o_dialog);
-
 
432
	if (o_dialog.status) {
-
 
433
		set_file_path(#openfile_path);
-
 
434
		img_convert stdcall(main_image.image, 0, _image_depth, 0, 0);
-
 
435
		if (!EAX) {
-
 
436
			notify("'ImageEdit Pro\nCan not convert image into specified color depth' -Et");
-
 
437
		} else {
-
 
438
			$push eax //converted data
-
 
439
			img_encode stdcall(EAX, _image_format, 0); //<=EAX data, ECX size
-
 
440
			$push eax //encoded data
-
 
441
			CreateFile(ECX, EAX, #openfile_path);
-
 
442
			$pop ecx
-
 
443
			free(ECX);
-
 
444
			$pop eax
-
 
445
			img_destroy stdcall(EAX);
445
				break;
446
		}
446
	}
447
	}
Line 447... Line 448...
447
}
448
}
448
 
449