Rev 7444 | Rev 7450 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7089 | leency | 1 | /* |
7154 | leency | 2 | * Icon Editor for KolibriOS |
7187 | leency | 3 | * Authors: Leency, Nicolas |
7089 | leency | 4 | * Licence: GPL v2 |
5 | */ |
||
6 | |||
7267 | leency | 7 | #define MEMSIZE 4096*500 |
7089 | leency | 8 | |
9 | #include "../lib/gui.h" |
||
7151 | leency | 10 | #include "../lib/random.h" |
11 | #include "../lib/mem.h" |
||
7262 | leency | 12 | #include "../lib/cursor.h" |
7447 | leency | 13 | #include "../lib/list_box.h" |
7255 | leency | 14 | |
7096 | leency | 15 | #include "../lib/obj/libimg.h" |
7255 | leency | 16 | #include "../lib/obj/box_lib.h" |
17 | |||
7089 | leency | 18 | #include "../lib/patterns/rgb.h" |
7253 | leency | 19 | #include "../lib/patterns/libimg_load_skin.h" |
7089 | leency | 20 | |
7151 | leency | 21 | #include "colors_mas.h" |
22 | |||
7359 | leency | 23 | #ifndef AUTOBUILD |
7358 | leency | 24 | #include "lang.h--" |
7359 | leency | 25 | #endif |
7358 | leency | 26 | |
7089 | leency | 27 | //===================================================// |
28 | // // |
||
29 | // DATA // |
||
30 | // // |
||
31 | //===================================================// |
||
32 | |||
7358 | leency | 33 | #ifdef LANG_RUS |
7447 | leency | 34 | char image_menu_items[] = |
35 | "Количество использованных цветов |
||
36 | Заменить все цвета 1 на 2"; |
||
37 | ?define T_MENU_IMAGE "Иконка" |
||
38 | ?define T_TEST_ICON "Проверить иконку" |
||
39 | ?define T_TITLE "Icon Editor 0.59 Alpha" |
||
7358 | leency | 40 | #else |
7447 | leency | 41 | char image_menu_items[] = |
42 | "Count colors used |
||
43 | Replace all colors equal to 1 by 2"; |
||
44 | ?define T_MENU_IMAGE "Icon" |
||
45 | ?define T_TEST_ICON "Test Icon" |
||
46 | ?define T_TITLE "Редактор иконок 0.59 Alpha" |
||
7358 | leency | 47 | #endif |
48 | |||
49 | |||
7096 | leency | 50 | |
7271 | leency | 51 | #define TOPBAR_H 24+8 |
52 | #define LEFTBAR_W 16+5+5+3+3 |
||
7096 | leency | 53 | #define PALLETE_SIZE 116 |
7089 | leency | 54 | |
7194 | leency | 55 | #define PAL_ITEMS_X_COUNT 13 |
56 | #define COLSIZE 18 |
||
7200 | leency | 57 | #define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE |
7187 | leency | 58 | |
7253 | leency | 59 | #define TO_CANVAS_X(xval) xval - canvas.x/zoom.value |
60 | #define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value |
||
61 | |||
7200 | leency | 62 | block canvas = { NULL, NULL, NULL, NULL }; |
7271 | leency | 63 | block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL }; |
64 | block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL }; |
||
7447 | leency | 65 | block image_menu_btn = { NULL, 4, NULL, 22 }; |
7200 | leency | 66 | |
7422 | leency | 67 | dword linear_gradient[RIGHT_BAR_W]; |
68 | block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 25}; |
||
69 | //block b_opacity_gradient = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, 15}; |
||
70 | block b_last_colors = {NULL, 75+TOPBAR_H, RIGHT_BAR_W, COLSIZE}; |
||
71 | block b_default_palette = {NULL, COLSIZE+10+75+TOPBAR_H, RIGHT_BAR_W, COLSIZE*9}; |
||
7200 | leency | 72 | |
7422 | leency | 73 | dword transparent = 0xBFCAD2; |
7207 | leency | 74 | dword color1 = 0x000000; |
7255 | leency | 75 | dword color2 = 0xBFCAD2; |
7207 | leency | 76 | dword tool_color; |
7089 | leency | 77 | |
7257 | leency | 78 | signed hoverX; |
79 | signed hoverY; |
||
80 | signed priorHoverX; |
||
81 | signed priorHoverY; |
||
82 | bool canvasMouseMoved = false; |
||
83 | |||
7089 | leency | 84 | enum { |
7096 | leency | 85 | BTN_NEW = 40, |
86 | BTN_OPEN, |
||
87 | BTN_SAVE, |
||
88 | BTN_MOVE_LEFT, |
||
89 | BTN_MOVE_RIGHT, |
||
90 | BTN_MOVE_UP, |
||
91 | BTN_MOVE_DOWN, |
||
92 | BTN_FLIP_HOR, |
||
93 | BTN_FLIP_VER, |
||
94 | BTN_ROTATE_LEFT, |
||
95 | BTN_ROTATE_RIGHT, |
||
7265 | leency | 96 | BTN_TEST_ICON, |
7187 | leency | 97 | BTN_PENCIL, |
7096 | leency | 98 | BTN_PICK, |
7156 | leency | 99 | BTN_FILL, |
7186 | leency | 100 | BTN_LINE, |
101 | BTN_RECT, |
||
7259 | leency | 102 | BTN_BAR, |
7253 | leency | 103 | BTN_SELECT, |
7260 | leency | 104 | BTN_SCREEN_COPY, |
7253 | leency | 105 | BTN_ZOOM_IN, |
106 | BTN_ZOOM_OUT, |
||
7274 | leency | 107 | BTN_CANVAS_RESIZE, |
7275 | leency | 108 | BTN_CROP, |
7447 | leency | 109 | BTN_IMAGE_MENU, |
7155 | leency | 110 | BTNS_PALETTE_COLOR_MAS = 100, |
111 | BTNS_LAST_USED_COLORS = 400 |
||
7089 | leency | 112 | }; |
113 | |||
114 | proc_info Form; |
||
7255 | leency | 115 | dword semi_white; |
7422 | leency | 116 | bool bg_dark=false; |
7089 | leency | 117 | |
7243 | leency | 118 | more_less_box zoom = { 11, 1, 40, "Zoom" }; |
7150 | leency | 119 | |
7152 | leency | 120 | dword default_palette[] = { |
7190 | leency | 121 | 0x330000,0x331900,0x333300,0x193300,0x003300,0x003319,0x003333,0x001933,0x000033,0x190033, |
122 | 0x330033,0x330019,0x000000,0x660000,0x663300,0x666600,0x336600,0x006600,0x006633,0x006666, |
||
123 | 0x003366,0x000066,0x330066,0x660066,0x660033,0x202020,0x990000,0x994C00,0x999900,0x4C9900, |
||
124 | 0x009900,0x00994C,0x009999,0x004C99,0x000099,0x4C0099,0x990099,0x99004C,0x404040,0xCC0000, |
||
125 | 0xCC6600,0xCCCC00,0x66CC00,0x00CC00,0x00CC66,0x00CCCC,0x0066CC,0x0000CC,0x6600CC,0xCC00CC, |
||
126 | 0xCC0066,0x606060,0xFF0000,0xFF8000,0xFFFF00,0x80FF00,0x00FF00,0x00FF80,0x00FFFF,0x0080FF, |
||
127 | 0x0000FF,0x7F00FF,0xFF00FF,0xFF007F,0x808080,0xFF3333,0xFF9933,0xFFFF33,0x99FF33,0x33FF33, |
||
128 | 0x33FF99,0x33FFFF,0x3399FF,0x3333FF,0x9933FF,0xFF33FF,0xFF3399,0xA0A0A0,0xFF6666,0xFFB266, |
||
129 | 0xFFFF66,0xB2FF66,0x66FF66,0x66FFB2,0x66FFFF,0x66B2FF,0x6666FF,0xB266FF,0xFF66FF,0xFF66B2, |
||
130 | 0xC0C0C0,0xFF9999,0xFFCC99,0xFFFF99,0xCCFF99,0x99FF99,0x99FFCC,0x99FFFF,0x99CCFF,0x9999FF, |
||
131 | 0xCC99FF,0xFF99FF,0xFF99CC,0xE0E0E0,0xFFCCCC,0xFFE5CC,0xFFFFCC,0xE5FFCC,0xCCFFCC,0xCCFFE5, |
||
132 | 0xCCFFFF,0xCCE5FF,0xCCCCFF,0xE5CCFF,0xFFCCFF,0xFFCCE5,0xFFFFFF |
||
7089 | leency | 133 | }; |
7422 | leency | 134 | |
135 | #define LAST_USED_MAX 13 |
||
136 | dword last_used_colors[LAST_USED_MAX] = { |
||
7190 | leency | 137 | 0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF, |
7422 | leency | 138 | 0xFFFFFF,0xFFFFFF,0xFFFFFF |
7155 | leency | 139 | }; |
7089 | leency | 140 | |
7262 | leency | 141 | CustomCursor Cursor; |
142 | dword CursorBar = FROM "cursors/bar.cur"; |
||
143 | dword CursorFill = FROM "cursors/fill.cur"; |
||
144 | dword CursorLine = FROM "cursors/line.cur"; |
||
145 | dword CursorPencil = FROM "cursors/pencil.cur"; |
||
146 | dword CursorPipette = FROM "cursors/pipette.cur"; |
||
147 | dword CursorRectangle = FROM "cursors/rectangle.cur"; |
||
148 | dword CursorSelect = FROM "cursors/select.cur"; |
||
149 | |||
7155 | leency | 150 | _image image; |
7148 | leency | 151 | |
7204 | leency | 152 | #include "actions_history.h" |
153 | |||
154 | _ActionsHistory actionsHistory; |
||
7151 | leency | 155 | |
7254 | leency | 156 | #include "tools.h" |
7274 | leency | 157 | #include "canvas_resize.h" |
7156 | leency | 158 | |
7089 | leency | 159 | //===================================================// |
160 | // // |
||
161 | // CODE // |
||
162 | // // |
||
163 | //===================================================// |
||
164 | |||
7266 | leency | 165 | libimg_image top_icons; |
166 | libimg_image left_icons; |
||
167 | |||
7089 | leency | 168 | void main() |
169 | { |
||
170 | word btn; |
||
7257 | leency | 171 | libimg_image open_image; |
7444 | leency | 172 | dword bg_col; |
7089 | leency | 173 | |
7096 | leency | 174 | load_dll(libio, #libio_init, 1); |
175 | load_dll(libimg, #libimg_init, 1); |
||
7255 | leency | 176 | load_dll(boxlib, #box_lib_init,0); |
177 | |||
7266 | leency | 178 | Libimg_LoadImage(#top_icons, "/sys/icons16.png"); |
179 | Libimg_LoadImage(#left_icons, "/sys/icons16.png"); |
||
180 | |||
7255 | leency | 181 | system.color.get(); |
7444 | leency | 182 | bg_col = system.color.work; |
183 | if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false; |
||
7422 | leency | 184 | |
7444 | leency | 185 | semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96); |
7266 | leency | 186 | Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white); |
187 | Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220)); |
||
7089 | leency | 188 | |
7266 | leency | 189 | Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffFFFfff, system.color.work); |
190 | Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200)); |
||
191 | |||
7422 | leency | 192 | //fix line and rectandle color for dark skins |
193 | if (bg_dark) Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xff545454, 0xffD3D3D4); |
||
194 | |||
195 | EventSetActiveColor(1, color1); |
||
196 | |||
7254 | leency | 197 | if (!param[0]) { |
198 | image.create(32, 32); |
||
199 | } |
||
200 | else |
||
201 | { |
||
7151 | leency | 202 | Libimg_LoadImage(#open_image, #param); |
7254 | leency | 203 | |
204 | if (open_image.w*open_image.h>MAX_CELL_SIZE*MAX_CELL_SIZE) { |
||
205 | notify("'Hey, this is just an icon editor,\nselected image is too big to open!' -E"); |
||
206 | ExitProcess(); |
||
7151 | leency | 207 | } |
208 | else { |
||
7422 | leency | 209 | image.create(open_image.h, open_image.w); |
7254 | leency | 210 | image.set_image(open_image.imgsrc); |
7151 | leency | 211 | } |
212 | } |
||
213 | |||
7204 | leency | 214 | actionsHistory.init(); |
215 | |||
7186 | leency | 216 | initTools(); |
217 | setCurrentTool(TOOL_PENCIL); |
||
218 | |||
7096 | leency | 219 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
220 | |||
7089 | leency | 221 | loop() switch(WaitEvent()) |
222 | { |
||
7096 | leency | 223 | case evMouse: |
7274 | leency | 224 | if (Window_CanvasReSize.thread_exists()) break; |
7096 | leency | 225 | mouse.get(); |
7186 | leency | 226 | |
7207 | leency | 227 | if (mouse.lkm) tool_color = color1; |
228 | if (mouse.pkm) tool_color = color2; |
||
229 | if (mouse.mkm) break; |
||
230 | |||
7257 | leency | 231 | hoverX = mouse.x - canvas.x / zoom.value; |
232 | hoverY = mouse.y - canvas.y / zoom.value; |
||
233 | if (hoverX<0) hoverX = 0; |
||
234 | if (hoverY<0) hoverY = 0; |
||
235 | if (hoverX>image.columns-1) hoverX = image.columns-1; |
||
236 | if (hoverY>image.rows-1) hoverY = image.rows-1; |
||
237 | canvasMouseMoved = false; |
||
238 | if (priorHoverX != hoverX) canvasMouseMoved = true; |
||
239 | if (priorHoverY != hoverY) canvasMouseMoved = true; |
||
240 | priorHoverX = hoverX; |
||
241 | priorHoverY = hoverY; |
||
242 | //DrawBar(Form.cwidth-100, 3, 80, 12, 0xFFFfff); |
||
243 | //WriteText(Form.cwidth-100, 3, 0x80, 0x000000, |
||
244 | // sprintf(#param, "%i %i", hoverX, hoverY)); |
||
245 | |||
7186 | leency | 246 | if (currentTool != TOOL_NONE) |
247 | tools[currentTool].onMouseEvent(mouse.x, mouse.y, mouse.lkm, mouse.pkm); |
||
248 | |||
7156 | leency | 249 | if (mouse.vert) { |
7243 | leency | 250 | if (mouse.vert==65535) zoom.inc(); |
251 | if (mouse.vert==1) zoom.dec(); |
||
7152 | leency | 252 | DrawEditArea(); |
253 | } |
||
7186 | leency | 254 | |
7262 | leency | 255 | if (wrapper.hovered()) SetCursor(); |
256 | else Cursor.Restore(); |
||
257 | |||
7200 | leency | 258 | if (mouse.down) { |
259 | if (b_color_gradient.hovered()) |
||
260 | || (b_last_colors.hovered()) |
||
261 | || (b_default_palette.hovered()) { |
||
262 | if (mouse.key&MOUSE_LEFT) EventSetActiveColor(1, GetPixelUnderMouse()); |
||
263 | if (mouse.key&MOUSE_RIGHT) EventSetActiveColor(2, GetPixelUnderMouse()); |
||
264 | } |
||
265 | } |
||
266 | |||
7148 | leency | 267 | break; |
7096 | leency | 268 | |
7089 | leency | 269 | case evButton: |
7274 | leency | 270 | if (Window_CanvasReSize.thread_exists()) break; |
7148 | leency | 271 | btn = GetButtonID(); |
7253 | leency | 272 | |
7255 | leency | 273 | if (zoom.click(btn)) DrawEditArea(); |
274 | |||
7096 | leency | 275 | switch(btn) |
276 | { |
||
7151 | leency | 277 | case BTN_NEW: |
7274 | leency | 278 | EventCreateNewIcon(); |
7151 | leency | 279 | break; |
280 | case BTN_OPEN: |
||
7422 | leency | 281 | EventOpenIcon(); |
7151 | leency | 282 | break; |
283 | case BTN_SAVE: |
||
7257 | leency | 284 | EventSaveIconToFile(); |
7151 | leency | 285 | break; |
7096 | leency | 286 | case BTN_MOVE_LEFT: |
7267 | leency | 287 | EventMove(MOVE_LEFT); |
7096 | leency | 288 | break; |
289 | case BTN_MOVE_RIGHT: |
||
7267 | leency | 290 | EventMove(MOVE_RIGHT); |
7096 | leency | 291 | break; |
7147 | leency | 292 | case BTN_MOVE_UP: |
7267 | leency | 293 | EventMove(MOVE_UP); |
7147 | leency | 294 | break; |
295 | case BTN_MOVE_DOWN: |
||
7267 | leency | 296 | EventMove(MOVE_DOWN); |
7147 | leency | 297 | break; |
7151 | leency | 298 | case BTN_FLIP_VER: |
7267 | leency | 299 | EventMove(FLIP_VER); |
7151 | leency | 300 | break; |
301 | case BTN_FLIP_HOR: |
||
7267 | leency | 302 | EventMove(FLIP_HOR); |
7151 | leency | 303 | break; |
7444 | leency | 304 | case BTN_ROTATE_LEFT: |
305 | EventMove(ROTATE_LEFT); |
||
306 | break; |
||
307 | case BTN_ROTATE_RIGHT: |
||
308 | EventMove(ROTATE_RIGHT); |
||
309 | break; |
||
7265 | leency | 310 | case BTN_TEST_ICON: |
311 | EventTestIcon(); |
||
312 | break; |
||
7187 | leency | 313 | case BTN_PENCIL: |
314 | setCurrentTool(TOOL_PENCIL); |
||
315 | break; |
||
7096 | leency | 316 | case BTN_PICK: |
7186 | leency | 317 | setCurrentTool(TOOL_PIPETTE); |
7096 | leency | 318 | break; |
7156 | leency | 319 | case BTN_FILL: |
7186 | leency | 320 | setCurrentTool(TOOL_FILL); |
7156 | leency | 321 | break; |
7186 | leency | 322 | case BTN_LINE: |
323 | setCurrentTool(TOOL_LINE); |
||
324 | break; |
||
325 | case BTN_RECT: |
||
326 | setCurrentTool(TOOL_RECT); |
||
327 | break; |
||
7259 | leency | 328 | case BTN_BAR: |
329 | setCurrentTool(TOOL_BAR); |
||
330 | break; |
||
7253 | leency | 331 | case BTN_SELECT: |
332 | setCurrentTool(TOOL_SELECT); |
||
333 | break; |
||
7260 | leency | 334 | case BTN_SCREEN_COPY: |
335 | setCurrentTool(TOOL_SCREEN_COPY); |
||
336 | break; |
||
7274 | leency | 337 | case BTN_CANVAS_RESIZE: |
338 | notify("Sorry, not implemented yet."); |
||
339 | break; |
||
7275 | leency | 340 | case BTN_CROP: |
341 | EventCrop(); |
||
342 | break; |
||
7447 | leency | 343 | case BTN_IMAGE_MENU: |
344 | EventShowImageMenu(); |
||
345 | break; |
||
7152 | leency | 346 | case CLOSE_BTN: |
7257 | leency | 347 | EventExitIconEdit(); |
7152 | leency | 348 | break; |
7089 | leency | 349 | } |
350 | break; |
||
351 | |||
352 | case evKey: |
||
353 | GetKeys(); |
||
7253 | leency | 354 | |
7422 | leency | 355 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) |
356 | { |
||
357 | switch(key_scancode) |
||
358 | { |
||
359 | case SCAN_CODE_KEY_S: |
||
360 | EventSaveIconToFile(); |
||
361 | break; |
||
362 | case SCAN_CODE_KEY_O: |
||
363 | EventOpenIcon(); |
||
364 | break; |
||
7444 | leency | 365 | case SCAN_CODE_LEFT: |
366 | EventMove(MOVE_LEFT); |
||
367 | break; |
||
368 | case SCAN_CODE_RIGHT: |
||
369 | EventMove(MOVE_RIGHT); |
||
370 | break; |
||
371 | case SCAN_CODE_UP: |
||
372 | EventMove(MOVE_UP); |
||
373 | break; |
||
374 | case SCAN_CODE_DOWN: |
||
375 | EventMove(MOVE_DOWN); |
||
376 | break; |
||
377 | case SCAN_CODE_KEY_R: |
||
378 | EventMove(BTN_ROTATE_RIGHT); |
||
379 | break; |
||
380 | case SCAN_CODE_KEY_L: |
||
381 | EventMove(BTN_ROTATE_LEFT); |
||
382 | break; |
||
7422 | leency | 383 | } |
384 | } |
||
385 | |||
386 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
||
387 | if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas(); |
||
388 | } |
||
389 | |||
7253 | leency | 390 | if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0) |
391 | tools[currentTool].onKeyEvent(key_scancode); |
||
392 | |||
7187 | leency | 393 | if (key_scancode == SCAN_CODE_KEY_P) setCurrentTool(TOOL_PENCIL); |
7186 | leency | 394 | if (key_scancode == SCAN_CODE_KEY_I) setCurrentTool(TOOL_PIPETTE); |
7187 | leency | 395 | if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL); |
396 | if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE); |
||
397 | if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT); |
||
7260 | leency | 398 | if (key_scancode == SCAN_CODE_KEY_B) setCurrentTool(TOOL_BAR); |
399 | if (key_scancode == SCAN_CODE_KEY_S) setCurrentTool(TOOL_SELECT); |
||
7204 | leency | 400 | |
7265 | leency | 401 | if (key_scancode == SCAN_CODE_KEY_T) EventTestIcon(); |
402 | |||
7267 | leency | 403 | if (key_scancode == SCAN_CODE_KEY_Z) actionsHistory.undoLastAction(); |
404 | if (key_scancode == SCAN_CODE_KEY_Y) actionsHistory.redoLastAction(); |
||
7204 | leency | 405 | |
7253 | leency | 406 | if (key_scancode == SCAN_CODE_MINUS) {zoom.dec(); DrawEditArea();} |
7274 | leency | 407 | if (key_scancode == SCAN_CODE_PLUS) {zoom.inc(); DrawEditArea();} |
7253 | leency | 408 | |
7089 | leency | 409 | break; |
410 | |||
411 | case evReDraw: |
||
7274 | leency | 412 | Window_CanvasReSize.thread_exists(); |
7447 | leency | 413 | EventCheckMenuItemSelected(); |
7275 | leency | 414 | DrawWindow(); |
7089 | leency | 415 | break; |
416 | } |
||
417 | } |
||
418 | |||
7266 | leency | 419 | void DrawTopPanelButton(dword _id, _x, _icon_n) |
7096 | leency | 420 | { |
7255 | leency | 421 | DrawWideRectangle(_x, 4, 22, 22, 3, semi_white); |
7271 | leency | 422 | PutPixel(_x,4,system.color.work); |
423 | PutPixel(_x,4+21,system.color.work); |
||
424 | PutPixel(_x+21,4,system.color.work); |
||
425 | PutPixel(_x+21,4+21,system.color.work); |
||
7152 | leency | 426 | DefineHiddenButton(_x, 4, 21, 21, _id); |
7266 | leency | 427 | img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16); |
7096 | leency | 428 | } |
429 | |||
7447 | leency | 430 | int DrawFlatPanelButton(dword _id, _x, _y, _text) |
431 | { |
||
432 | #define P 10 |
||
433 | int w = strlen(_text)*6 + P + P; |
||
434 | DrawBar(_x, _y, w, 22, semi_white); |
||
435 | PutPixel(_x,_y,system.color.work); |
||
436 | PutPixel(_x,_y+21,system.color.work); |
||
437 | PutPixel(_x+w-1,_y,system.color.work); |
||
438 | PutPixel(_x+w-1,_y+21,system.color.work); |
||
439 | DefineHiddenButton(_x, _y, w, 21, _id); |
||
440 | WriteText(_x+P, _y+7, 0x80, system.color.work_text, _text); |
||
441 | return w; |
||
442 | } |
||
443 | |||
7187 | leency | 444 | void DrawLeftPanelButton(dword _id, _y, _icon_n) |
445 | { |
||
446 | int x = 5; |
||
7266 | leency | 447 | DrawRectangle(x, _y, 22-1, 22-1, system.color.work); |
7187 | leency | 448 | DefineHiddenButton(x, _y, 21, 21, _id); |
7266 | leency | 449 | img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16); |
7187 | leency | 450 | } |
451 | |||
7148 | leency | 452 | void DrawStatusBar() |
453 | { |
||
7243 | leency | 454 | zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6); |
7150 | leency | 455 | |
7275 | leency | 456 | sprintf(#param,"%i x %i", image.columns, image.rows); |
7274 | leency | 457 | DrawCaptButton( |
7275 | leency | 458 | wrapper.x+wrapper.w-calc(strlen(#param)*8) -6 - 1, |
7274 | leency | 459 | zoom.y, |
7275 | leency | 460 | calc(strlen(#param)*8)+6, |
7274 | leency | 461 | 18, |
462 | BTN_CANVAS_RESIZE, |
||
463 | system.color.work_button, |
||
464 | system.color.work_button_text, |
||
7275 | leency | 465 | #param |
7274 | leency | 466 | ); |
7148 | leency | 467 | } |
468 | |||
7275 | leency | 469 | void DrawWindow() |
7089 | leency | 470 | { |
7266 | leency | 471 | #define GAP 27 |
472 | #define BLOCK_SPACE 10 |
||
7096 | leency | 473 | incn tx; |
7089 | leency | 474 | system.color.get(); |
7271 | leency | 475 | DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0); |
7089 | leency | 476 | GetProcessInfo(#Form, SelfInfo); |
7152 | leency | 477 | if (Form.status_window>2) return; |
478 | if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; } |
||
479 | if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; } |
||
480 | |||
7150 | leency | 481 | right_bar.x = Form.cwidth - right_bar.w; |
7200 | leency | 482 | b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x; |
7271 | leency | 483 | DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, system.color.work); |
484 | DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph); |
||
7089 | leency | 485 | |
7266 | leency | 486 | tx.n = 5-GAP; |
7444 | leency | 487 | DrawTopPanelButton(BTN_NEW, tx.inc(GAP), 2); |
7266 | leency | 488 | DrawTopPanelButton(BTN_OPEN, tx.inc(GAP), 0); //not implemented |
489 | DrawTopPanelButton(BTN_SAVE, tx.inc(GAP), 5); |
||
490 | DrawTopPanelButton(BTN_MOVE_LEFT, tx.inc(GAP+BLOCK_SPACE), 30); |
||
491 | DrawTopPanelButton(BTN_MOVE_RIGHT, tx.inc(GAP), 31); |
||
492 | DrawTopPanelButton(BTN_MOVE_UP, tx.inc(GAP), 32); |
||
493 | DrawTopPanelButton(BTN_MOVE_DOWN, tx.inc(GAP), 33); |
||
7147 | leency | 494 | |
7266 | leency | 495 | DrawTopPanelButton(BTN_FLIP_HOR, tx.inc(GAP+BLOCK_SPACE), 34); |
496 | DrawTopPanelButton(BTN_FLIP_VER, tx.inc(GAP), 35); |
||
7444 | leency | 497 | DrawTopPanelButton(BTN_ROTATE_LEFT, tx.inc(GAP), 37); |
498 | DrawTopPanelButton(BTN_ROTATE_RIGHT, tx.inc(GAP), 36); |
||
7265 | leency | 499 | |
7266 | leency | 500 | DrawTopPanelButton(BTN_TEST_ICON, tx.inc(GAP+BLOCK_SPACE), 12); |
7275 | leency | 501 | |
502 | DrawTopPanelButton(BTN_CROP, tx.inc(GAP+BLOCK_SPACE), 46); |
||
7447 | leency | 503 | |
504 | image_menu_btn.x = tx.n; |
||
505 | image_menu_btn.w = DrawFlatPanelButton(BTN_IMAGE_MENU, image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE); |
||
506 | //tx.inc(image_menu_btn.w + BLOCK_SPACE); |
||
7186 | leency | 507 | |
7150 | leency | 508 | DrawEditArea(); |
7096 | leency | 509 | |
7271 | leency | 510 | DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, system.color.work); |
7274 | leency | 511 | DrawLeftPanel(); |
512 | |||
7271 | leency | 513 | DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w, |
514 | Form.cheight - TOPBAR_H, system.color.work); |
||
7274 | leency | 515 | DrawActiveColor(right_bar.y); |
516 | DrawColorPallets(); |
||
517 | DrawPreview(); |
||
518 | |||
7271 | leency | 519 | DrawBar(LEFTBAR_W-1, wrapper.y + wrapper.h, wrapper.w+1, |
520 | Form.cheight - wrapper.y - wrapper.h, system.color.work); |
||
7148 | leency | 521 | DrawStatusBar(); |
7089 | leency | 522 | } |
523 | |||
7187 | leency | 524 | void DrawLeftPanel() |
525 | { |
||
7266 | leency | 526 | #define GAP 28 |
7187 | leency | 527 | incn ty; |
7266 | leency | 528 | ty.n = right_bar.y - GAP - 2; |
529 | DrawLeftPanelButton(BTN_PENCIL, ty.inc(GAP), 38); |
||
530 | DrawLeftPanelButton(BTN_PICK, ty.inc(GAP), 39); |
||
531 | DrawLeftPanelButton(BTN_FILL, ty.inc(GAP), 40); |
||
532 | DrawLeftPanelButton(BTN_LINE, ty.inc(GAP), 41); |
||
533 | DrawLeftPanelButton(BTN_RECT, ty.inc(GAP), 42); |
||
534 | DrawLeftPanelButton(BTN_BAR, ty.inc(GAP), 43); |
||
535 | DrawLeftPanelButton(BTN_SELECT, ty.inc(GAP), 44); |
||
536 | DrawLeftPanelButton(BTN_SCREEN_COPY, ty.inc(GAP), 45); |
||
537 | DrawRectangle3D(5, currentTool*GAP+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777); |
||
7187 | leency | 538 | } |
539 | |||
7151 | leency | 540 | void DrawEditArea() |
7089 | leency | 541 | { |
7150 | leency | 542 | dword color1=0xC0C0C0; |
7155 | leency | 543 | int top_side; |
544 | int left_side; |
||
7089 | leency | 545 | |
7194 | leency | 546 | wrapper.w = Form.cwidth - right_bar.w - 10 - wrapper.x; |
7271 | leency | 547 | wrapper.h = Form.cheight - TOPBAR_H - 35; |
7148 | leency | 548 | |
7150 | leency | 549 | //canvas{ |
7151 | leency | 550 | canvas.w = image.columns * zoom.value; |
551 | canvas.h = image.rows * zoom.value; |
||
552 | if (canvas.w+2 > wrapper.w) || (canvas.h+2 > wrapper.h) { |
||
7254 | leency | 553 | zoom.value--; |
7422 | leency | 554 | if (zoom.x) zoom.redraw(); |
7151 | leency | 555 | DrawEditArea(); |
556 | return; |
||
557 | } |
||
558 | canvas.x = -zoom.value*image.columns+wrapper.w/2 + wrapper.x; |
||
559 | canvas.y = -zoom.value*image.rows+wrapper.h/2 + wrapper.y; |
||
560 | DrawCanvas(); |
||
7150 | leency | 561 | //} |
7089 | leency | 562 | |
7155 | leency | 563 | left_side = canvas.x-wrapper.x-1; |
564 | top_side = canvas.y-wrapper.y-1; |
||
7148 | leency | 565 | |
7155 | leency | 566 | DrawRectangle(wrapper.x-1, wrapper.y-1, wrapper.w, wrapper.h, system.color.work_graph); |
7150 | leency | 567 | |
7155 | leency | 568 | if (left_side>0) |
7150 | leency | 569 | { |
7155 | leency | 570 | DrawBar(wrapper.x, wrapper.y, wrapper.w-1, top_side, color1); //top |
571 | DrawBar(wrapper.x, wrapper.y+wrapper.h-top_side-1, wrapper.w-1, top_side, color1); //bottom |
||
7150 | leency | 572 | } |
7155 | leency | 573 | if (top_side>0) |
7150 | leency | 574 | { |
7190 | leency | 575 | //left |
576 | DrawBar(wrapper.x, wrapper.y+top_side, left_side, |
||
577 | wrapper.h-top_side-top_side, color1); |
||
578 | //right |
||
579 | DrawBar(wrapper.x+wrapper.w-left_side-1, wrapper.y+top_side, left_side, |
||
580 | wrapper.h-top_side-top_side, color1); |
||
7150 | leency | 581 | } |
7194 | leency | 582 | DrawRectangle(canvas.x-1, canvas.y-1, canvas.w+1, canvas.h+1, 0x808080); |
7089 | leency | 583 | } |
584 | |||
585 | void DrawActiveColor(dword iny) |
||
586 | { |
||
7255 | leency | 587 | #define CELL 20 |
7089 | leency | 588 | static dword outy; |
589 | if (iny != NULL) outy = iny; |
||
7255 | leency | 590 | DrawFrame(right_bar.x, outy, CELL, CELL, NULL); |
591 | DrawBar(right_bar.x+2, outy+2, CELL-4, CELL-4, color1); |
||
7151 | leency | 592 | |
7422 | leency | 593 | DrawFrame(right_bar.x+CELL+5, outy, CELL, CELL, NULL); |
594 | DrawBar(right_bar.x+CELL+5+2, outy+2, CELL-4, CELL-4, color2); |
||
595 | |||
596 | //sprintf(#param, "%A", color1); |
||
597 | //WriteTextWithBg(right_bar.x+30, outy+3, 0xD0, system.color.work_text, #param+4, system.color.work); |
||
598 | DrawCurrentColorGradient(); |
||
7089 | leency | 599 | } |
600 | |||
7422 | leency | 601 | int lmax; |
602 | void GenerateCurrentColorGradient() |
||
7194 | leency | 603 | { |
7422 | leency | 604 | int i, avg, rmax; |
605 | |||
606 | rgb.DwordToRgb(color1); |
||
607 | avg = 255 - calc(rgb.r + rgb.g + rgb.b / 3); |
||
608 | |||
609 | lmax = b_color_gradient.w *avg/255 | 1; |
||
610 | rmax = b_color_gradient.w - lmax | 1; |
||
611 | if (lmax == 0) lmax=1; |
||
612 | if (rmax == 0) rmax=1; |
||
613 | |||
614 | for (i=0; i |
||
615 | linear_gradient[i] = MixColors(color1,0xFFFfff,255*i/lmax); |
||
616 | } |
||
617 | |||
618 | for (i=0 ; i<=rmax; i++) { |
||
619 | linear_gradient[lmax+rmax - i] = MixColors(color1,0x000000,255*i/rmax); |
||
620 | } |
||
621 | } |
||
622 | |||
7444 | leency | 623 | int DrawGradientMarker(dword marker_x, marker_color) |
624 | { |
||
625 | if (marker_x > b_color_gradient.w - 1) marker_x = b_color_gradient.w - 1; |
||
626 | DrawBar(b_color_gradient.x + marker_x-2, b_color_gradient.y-3, 5, 1, marker_color); |
||
627 | DrawBar(b_color_gradient.x + marker_x-1, b_color_gradient.y-2, 3, 1, marker_color); |
||
628 | PutPixel(b_color_gradient.x + marker_x, b_color_gradient.y-1, marker_color); |
||
629 | return marker_x; |
||
630 | } |
||
631 | |||
632 | int old_marker_pos; |
||
7422 | leency | 633 | void DrawCurrentColorGradient() |
634 | { |
||
7194 | leency | 635 | int i; |
7422 | leency | 636 | for (i=0 ; i |
637 | DrawBar(b_color_gradient.x+i, b_color_gradient.y, 1, b_color_gradient.h, linear_gradient[i]); |
||
638 | } |
||
7444 | leency | 639 | DrawGradientMarker(old_marker_pos, system.color.work); |
640 | old_marker_pos = DrawGradientMarker(lmax, 0xFFFfff * bg_dark); |
||
7194 | leency | 641 | } |
642 | |||
7200 | leency | 643 | void DrawColorPallets() |
7089 | leency | 644 | { |
7155 | leency | 645 | int r, c, i=0; |
646 | //Last used colors |
||
7422 | leency | 647 | for (r = 0; r < LAST_USED_MAX/PAL_ITEMS_X_COUNT; r++) |
7155 | leency | 648 | { |
7194 | leency | 649 | for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++) |
7155 | leency | 650 | { |
7200 | leency | 651 | DrawBar(c*COLSIZE + b_last_colors.x, r*COLSIZE + b_last_colors.y, |
652 | COLSIZE, COLSIZE, last_used_colors[i]); |
||
7155 | leency | 653 | } |
654 | } |
||
655 | i=0; |
||
656 | //Default colors |
||
7089 | leency | 657 | for (r = 0; r < 9; r++) |
658 | { |
||
7194 | leency | 659 | for (c = 0; c < PAL_ITEMS_X_COUNT; c++, i++) |
7089 | leency | 660 | { |
7200 | leency | 661 | DrawBar(c*COLSIZE + b_default_palette.x, r*COLSIZE + b_default_palette.y, |
662 | COLSIZE, COLSIZE, default_palette[PALLETE_SIZE-i]); |
||
7089 | leency | 663 | } |
664 | } |
||
665 | } |
||
666 | |||
7257 | leency | 667 | void DrawCanvasPixel(dword _r,_c,_color) |
668 | { |
||
669 | DrawBar(_c*zoom.value + canvas.x, _r*zoom.value + canvas.y, |
||
670 | zoom.value, zoom.value, _color); |
||
671 | } |
||
672 | |||
7155 | leency | 673 | void DrawCanvas() |
674 | { |
||
675 | int r, c; |
||
7257 | leency | 676 | dword color; |
677 | |||
678 | if ((currentTool != TOOL_NONE) && (tools[currentTool].onCanvasDraw != 0)) |
||
679 | { |
||
680 | tools[currentTool].onCanvasDraw(); |
||
681 | } |
||
682 | |||
7155 | leency | 683 | for (r = 0; r < image.rows; r++) |
684 | { |
||
685 | for (c = 0; c < image.columns; c++) |
||
686 | { |
||
7257 | leency | 687 | if (image.pixel_state.is_drawable(r,c)) |
688 | DrawCanvasPixel(r, c, image.get_pixel(r,c)); |
||
7155 | leency | 689 | } |
690 | } |
||
7257 | leency | 691 | image.pixel_state.reset_and_set_all_drawable(); |
7186 | leency | 692 | |
7200 | leency | 693 | DrawPreview(); |
7155 | leency | 694 | } |
695 | |||
7200 | leency | 696 | void DrawPreview() |
697 | { |
||
698 | int x = right_bar.x; |
||
7444 | leency | 699 | int y = b_default_palette.y + b_default_palette.h + 6; |
700 | int preview_h = Form.cheight - y; |
||
701 | |||
702 | if (image.columns > right_bar.w) return; |
||
703 | if (image.rows > preview_h) return; |
||
704 | |||
705 | _PutImage(right_bar.w - image.columns / 2 + x - 3, |
||
706 | preview_h - image.rows / 2 + y, |
||
707 | image.columns, image.rows, image.get_image() |
||
708 | ); |
||
7200 | leency | 709 | } |
7155 | leency | 710 | |
7200 | leency | 711 | dword GetPixelUnderMouse() |
712 | { |
||
713 | return GetPixelColorFromScreen(mouse.x + Form.left + 5, mouse.y + Form.top + skin_height); |
||
714 | } |
||
715 | |||
7265 | leency | 716 | int preview_size = 128; |
717 | void DrawImageWithBg(dword _x, _y, _col_to) |
||
718 | { |
||
719 | _x *= preview_size; |
||
720 | _y *= preview_size; |
||
721 | DrawWideRectangle(_x,_y, preview_size, preview_size, preview_size-image.columns/2, _col_to); |
||
722 | _PutImage(preview_size - image.columns / 2 + _x, preview_size - image.rows / 2 + _y, |
||
723 | image.columns, image.rows, image.get_image_with_replaced_color(color2, _col_to)); |
||
724 | } |
||
725 | |||
726 | void ShowWindow_TestIcon() |
||
727 | { |
||
7422 | leency | 728 | if (image.rows>=preview_size) || (image.columns>=preview_size) { |
729 | notify("'IconEdit\nImage is too big for preview!' -tE"); |
||
730 | return; |
||
731 | } |
||
7265 | leency | 732 | loop() switch(WaitEvent()) |
733 | { |
||
734 | case evButton: |
||
735 | if (GetButtonID()) ExitProcess(); |
||
736 | break; |
||
737 | |||
738 | case evKey: |
||
739 | GetKeys(); |
||
740 | if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
||
741 | break; |
||
742 | |||
743 | case evReDraw: |
||
744 | DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9, |
||
7447 | leency | 745 | preview_size*2+skin_height+4, 0x74, NULL, T_TEST_ICON, 0); |
7265 | leency | 746 | DrawImageWithBg(0, 0, 0x000000); |
747 | DrawImageWithBg(1, 0, 0xFFFfff); |
||
748 | DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0)); |
||
749 | DrawImageWithBg(1, 1, system.color.work); |
||
750 | break; |
||
751 | } |
||
752 | } |
||
753 | |||
7089 | leency | 754 | //===================================================// |
755 | // // |
||
756 | // EVENTS // |
||
757 | // // |
||
758 | //===================================================// |
||
759 | |||
7274 | leency | 760 | void EventCreateNewIcon() |
761 | { |
||
762 | EventSaveIconToFile(); |
||
763 | Window_CanvasReSize.create(); |
||
764 | } |
||
765 | |||
7422 | leency | 766 | void EventOpenIcon() |
767 | { |
||
768 | RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path)); |
||
769 | } |
||
770 | |||
7257 | leency | 771 | void EventSaveIconToFile() |
7150 | leency | 772 | { |
7257 | leency | 773 | int i=0; |
774 | char save_file_name[4096]; |
||
775 | char save_path_stable[4096]; |
||
776 | strcpy(#save_path_stable, "/tmp0/1"); |
||
777 | do { |
||
778 | i++; |
||
779 | sprintf(#save_file_name, "%s/saved_icon_%i.png", #save_path_stable, i); |
||
780 | } while (file_exists(#save_file_name)); |
||
781 | save_image(image.get_image(), image.columns, image.rows, #save_file_name); |
||
7150 | leency | 782 | } |
7151 | leency | 783 | |
7257 | leency | 784 | void EventCleanCanvas() |
785 | { |
||
7274 | leency | 786 | image.create(image.rows, image.columns); |
787 | actionsHistory.saveCurrentState(); |
||
7257 | leency | 788 | DrawCanvas(); |
789 | } |
||
790 | |||
791 | void EventExitIconEdit() |
||
792 | { |
||
793 | EventSaveIconToFile(); |
||
794 | ExitProcess(); |
||
795 | } |
||
796 | |||
7155 | leency | 797 | void EventSetActiveColor(int _number, _color) |
7151 | leency | 798 | { |
799 | int i; |
||
7422 | leency | 800 | if (last_used_colors[0] == _color) return; |
801 | for (i=LAST_USED_MAX-1; i>0; i--) { |
||
7155 | leency | 802 | last_used_colors[i] = last_used_colors[i-1]; |
803 | } |
||
804 | last_used_colors[0] = _color; |
||
7151 | leency | 805 | |
7207 | leency | 806 | if (_number == 1) color1 = _color; |
807 | if (_number == 2) color2 = _color; |
||
7155 | leency | 808 | |
7422 | leency | 809 | if (b_color_gradient.hovered()) { |
810 | lmax = mouse.x - b_color_gradient.x; |
||
811 | } |
||
812 | else { |
||
813 | GenerateCurrentColorGradient(); |
||
814 | } |
||
7155 | leency | 815 | DrawActiveColor(NULL); |
7200 | leency | 816 | DrawColorPallets(); |
7156 | leency | 817 | } |
7257 | leency | 818 | |
7265 | leency | 819 | void EventTestIcon() |
820 | { |
||
821 | CreateThread(#ShowWindow_TestIcon, #test_icon_stak+4092); |
||
822 | } |
||
823 | |||
7267 | leency | 824 | void EventMove(dword _action) |
825 | { |
||
7273 | leency | 826 | if (selection.state) { |
827 | selection.buf.move(_action); |
||
7271 | leency | 828 | SelectTool_onCanvasDraw(); |
7267 | leency | 829 | } |
830 | else { |
||
831 | image.move(_action); |
||
832 | DrawCanvas(); |
||
7271 | leency | 833 | } |
834 | actionsHistory.saveCurrentState(); |
||
7267 | leency | 835 | } |
836 | |||
7275 | leency | 837 | void EventCrop() |
838 | { |
||
839 | if (selection.state) { |
||
840 | EventSaveIconToFile(); |
||
841 | image.create(selection.buf.rows, selection.buf.columns); |
||
842 | selection.move_to_point(0,0); |
||
843 | selection.apply_to_image(); |
||
844 | selection.reset(); |
||
845 | actionsHistory.init(); |
||
846 | DrawWindow(); |
||
847 | } |
||
848 | else { |
||
7447 | leency | 849 | notify("'You need to select something before using crop tool.' -W"); |
7275 | leency | 850 | } |
851 | } |
||
852 | |||
7447 | leency | 853 | void EventShowImageMenu() |
854 | { |
||
855 | menu.selected = 0; |
||
856 | menu.show(Form.left+5 + image_menu_btn.x, |
||
857 | Form.top+skin_height + image_menu_btn.y + image_menu_btn.h, |
||
858 | 240, |
||
859 | #image_menu_items, |
||
860 | 20); |
||
861 | } |
||
862 | |||
863 | void EventCheckMenuItemSelected() |
||
864 | { |
||
865 | if (menu.list.cur_y) { |
||
866 | if (20 == menu.list.cur_y) EventCountColorsUsed(); |
||
867 | if (21 == menu.list.cur_y) EventReplaceImageColors(color1, color2); |
||
868 | menu.list.cur_y = 0; |
||
869 | } |
||
870 | } |
||
871 | |||
872 | void EventCountColorsUsed() |
||
873 | { |
||
874 | char res_str[64]; |
||
875 | int cur, prev; |
||
876 | int max = image.rows*image.columns; |
||
877 | int resi=0; |
||
878 | bool unic; |
||
879 | for (cur=0; cur |
||
880 | unic = true; |
||
881 | for (prev=0; prev |
||
882 | if (image.mas[prev] == image.mas[cur]) {unic=false; break;} |
||
883 | } |
||
884 | if (unic) resi++; |
||
885 | } |
||
886 | notify( sprintf(#res_str, "'Image has %i unique colors.' -I", resi) ); |
||
887 | } |
||
888 | |||
889 | void EventReplaceImageColors(dword c1, c2) |
||
890 | { |
||
891 | int max = image.rows*image.columns; |
||
892 | int cur; |
||
893 | for (cur=0; cur |
||
894 | if (image.mas[cur] == color1) image.mas[cur] = color2; |
||
895 | } |
||
896 | } |
||
897 | |||
7265 | leency | 898 | stop: |
899 | |||
900 | char test_icon_stak[4096];>>>>>>=rmax;>>>0)>0)>65)> |