From 7c423903ff114bb81d6ba26692871d6df67139dc Mon Sep 17 00:00:00 2001 From: IgorA Date: Thu, 24 Mar 2016 15:54:52 +0000 Subject: [PATCH] add menu 'Filters', add icons for select zoom git-svn-id: svn://kolibrios.org@6371 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/media/animage/trunk/animage.asm | 21 ++- .../media/animage/trunk/events_of_keys.inc | 153 +++++++++--------- .../media/animage/trunk/events_of_mouse.inc | 1 + programs/media/animage/trunk/icons.inc | 63 ++++++-- .../media/animage/trunk/icons_instruments.inc | 6 +- .../animage/trunk/load_from_parameters.inc | 30 ++-- programs/media/animage/trunk/memory.inc | 39 +++-- programs/media/animage/trunk/menu.inc | 22 ++- .../media/animage/trunk/menu_instruments.inc | 8 + programs/media/animage/trunk/panel_zoom.png | Bin 0 -> 516 bytes 10 files changed, 218 insertions(+), 125 deletions(-) create mode 100644 programs/media/animage/trunk/panel_zoom.png diff --git a/programs/media/animage/trunk/animage.asm b/programs/media/animage/trunk/animage.asm index a47810aa8a..cb96692ae1 100644 --- a/programs/media/animage/trunk/animage.asm +++ b/programs/media/animage/trunk/animage.asm @@ -59,15 +59,16 @@ ci_wnd_min_siz_x equ 585 ;minimum size x ci_wnd_min_siz_y equ 400 ;minimum size y ; панель инструментов -ci_panel_x_pos equ 0 ;координата x для панели -ci_panel_y_pos equ 20 ;координата y для панели -ci_panel_but_y1 equ ci_panel_y_pos +5 ;координата y для 1-го ряда кнопок -ci_panel_but_y2 equ ci_panel_y_pos+30 ;координата y для 2-го ряда кнопок -ci_palete_y_pos equ ci_panel_y_pos+51 ;координата y для палитры цветов +ci_panel_x_pos equ 0 ;коорд. x для панели +ci_panel_y_pos equ 20 ;коорд. y для панели +ci_panel_but_y1 equ ci_panel_y_pos +5 ;коорд. y для 1-го ряда кнопок +ci_panel_but_y2 equ ci_panel_y_pos+30 ;коорд. y для 2-го ряда кнопок +ci_palete_y_pos equ ci_panel_y_pos+51 ;коорд. y для палитры цветов +ci_panel_zoom_x equ 178 ;коорд. x для кнопок панели масштаба ; окно редактора -ci_edit_wnd_x_pos equ 0 ;координата x для окна редактора -ci_edit_wnd_y_pos equ 71 ;координата y для окна редактора +ci_edit_wnd_x_pos equ 0 ;коорд. x для окна редактора +ci_edit_wnd_y_pos equ 71 ;коорд. y для окна редактора ci_edit_wnd_border equ 3 ;рамка вокруг окна редактора ; скроллинги @@ -195,7 +196,7 @@ include 'menu.inc' ;----------------------------------------------------------- ;------------variables and data of program------------------ ;----------------------------------------------------------- -sound_havent_memory db 150,64,0 +;sound_havent_memory db 150,64,0 include 'lib_data.inc' include 'panel_data.inc' @@ -210,6 +211,10 @@ align 4 panel_picture: file 'panel_buttons.png' .end: +align 4 +panel_zoom: +file 'panel_zoom.png' +.end: ;****************cursors****************** brush_cursor: file 'brush.cur' diff --git a/programs/media/animage/trunk/events_of_keys.inc b/programs/media/animage/trunk/events_of_keys.inc index d15eeecaa2..cad4dc54f1 100644 --- a/programs/media/animage/trunk/events_of_keys.inc +++ b/programs/media/animage/trunk/events_of_keys.inc @@ -3,87 +3,80 @@ ;------------------------------------------ align 4 keys: + mcall SF_GET_KEY + shr eax,8 - mcall SF_GET_KEY - shr eax,8 + cmp al,176 + jne @f + sub [PosX],20 + jmp change_screen +@@: + cmp al,179 + jne @f + add [PosX],20 + jmp change_screen +@@: + cmp al,177 + jne @f + add [PosY],20 + jmp change_screen +@@: + cmp al,178 + jne @f + sub [PosY],20 + jmp change_screen +@@: + cmp al,49 ;1 + jne @f + mov [k],1 + jmp zoom_ch +@@: + cmp al,50 ;2 + jne @f + mov [k],2 + jmp zoom_ch +@@: + cmp al,51 ;3 + jne @f + mov [k],3 + jmp zoom_ch +@@: + cmp al,52 ;4 + jne @f + mov [k],4 + jmp zoom_ch +@@: + cmp al,56 ;8 + jne @f + mov [k],8 + jmp zoom_ch +@@: + cmp al,48 ;0 + jne @f + mov [k],16 +zoom_ch: + call scrollbar_move_00 + call drawwin + jmp change_screen +@@: + cmp al,255 + jne @f + call analizing_picture_to_palette + call drawwin + jmp change_screen +@@: + jmp still - cmp al,176 - jne key2 - sub [PosX],20 - jmp change_screen - key2: - cmp al,179 - jne key3 - add [PosX],20 - jmp change_screen - key3: - cmp al,177 - jne key4 - add [PosY],20 - jmp change_screen - key4: - cmp al,178 - jne key5 - sub [PosY],20 - jmp change_screen - key5: - cmp al,49 ;1 - jne key6 - mov [k],1 - call scrollbar_move_00 - call drawwin - jmp change_screen - key6: - cmp al,50 ;2 - jne key7 - mov [k],2 - call scrollbar_move_00 - call drawwin - jmp change_screen - key7: - cmp al,52 ;4 - jne key8 - mov [k],4 - call scrollbar_move_00 - call drawwin - jmp change_screen - key8: - cmp al,56 ;8 - jne key9 - mov [k],8 - call scrollbar_move_00 - call drawwin - jmp change_screen - key9: - cmp al,48 ;0 - jne key10 - mov [k],16 - call scrollbar_move_00 - call drawwin - jmp change_screen - key10: - cmp al,255 - jne key11 - call analizing_picture_to_palette - call drawwin - jmp change_screen - key11: - ;cmp al,27 ;Esc - ;jne still - jmp still - - mov eax,CursorsID - call delete_cursors + ;cmp al,27 ;Esc + ;jne still + ;mov eax,CursorsID + ;call delete_cursors close: - mcall SF_TERMINATE_PROCESS + mcall SF_TERMINATE_PROCESS - jmp still - - change_screen: - - call CalculatePositionScreen - call MovePictureToWorkScreen - call draw_scrollers - call PrintMousePos - - jmp still \ No newline at end of file +change_screen: + call CalculatePositionScreen + call MovePictureToWorkScreen + call draw_scrollers + call PrintMousePos + jmp still \ No newline at end of file diff --git a/programs/media/animage/trunk/events_of_mouse.inc b/programs/media/animage/trunk/events_of_mouse.inc index 737c4ef334..6d84e7bd8a 100644 --- a/programs/media/animage/trunk/events_of_mouse.inc +++ b/programs/media/animage/trunk/events_of_mouse.inc @@ -210,6 +210,7 @@ mouse_in_work_arrea: ;--------------end copy for undo------------- no_undo___: call TakeButtonInstruments + jmp still no_use_instruments: diff --git a/programs/media/animage/trunk/icons.inc b/programs/media/animage/trunk/icons.inc index 6fd0861138..ada9ba03cb 100644 --- a/programs/media/animage/trunk/icons.inc +++ b/programs/media/animage/trunk/icons.inc @@ -8,26 +8,65 @@ load_icons: add edi,mem_screen stdcall [img_to_rgb2], ebx,edi ;╨┐╤А╨╡╨╛╨▒╤А╨░╨╖╤Г╨╡╨╝ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╨╡ ╨║ ╤Д╨╛╤А╨╝╨░╤В╤Г rgb stdcall [img_destroy], ebx ;╤Г╨┤╨░╨╗╤П╨╡╨╝ ╨▓╤А╨╡╨╝╨╡╨╜╨╜╤Л╨╣ ╨▒╤Г╤Д╨╡╤А ╤Б ╨┐╨░╤А╨░╨╝╨╡╤В╤А╨░╨╝╨╕ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╤П + + stdcall [img_decode], panel_zoom, panel_zoom.end-panel_zoom, 0 + mov ebx,eax + add edi,mem_panel_but + stdcall [img_to_rgb2], ebx,edi + stdcall [img_destroy], ebx ret draw_icons: mov [Icon_X],ci_panel_x_pos+2 mov [Icon_Y],ci_panel_y_pos+3 - ;draw panel picture - mov edx,[Icon_X] - shl edx,16 - add edx,[Icon_Y] - mov ebx,[ScreenPointer] - add ebx,mem_screen - mov ecx,417*65536+46 - mcall SF_PUT_IMAGE + ;draw panel picture + mov edx,[Icon_X] + shl edx,16 + add edx,[Icon_Y] + mov ebx,[ScreenPointer] + add ebx,mem_screen + mov ecx,417*65536+46 + mcall SF_PUT_IMAGE + ;draw active zoom button + add ebx,mem_panel_but + xor eax,eax + cmp [k],1 + je .end_calc + inc eax + cmp [k],2 + je @f + inc eax + cmp [k],3 + je @f + inc eax + cmp [k],4 + je @f + inc eax + cmp [k],8 + je @f + inc eax + cmp [k],16 + je @f + inc eax + @@: + mov edx,eax + imul edx,18*21*3 + add ebx,edx + .end_calc: + mov edx,eax + imul edx,18+1 + add edx,ci_panel_zoom_x-1 + shl edx,16 + add edx,ci_panel_but_y2-2 + mov ecx,18*65536+21 + mcall SF_PUT_IMAGE - ;main buttons of instrumnts + ;main buttons of instrumnts - and [counter],0 - mov [Icon_X],ci_panel_x_pos+4 + and [counter],0 + mov [Icon_X],ci_panel_x_pos+4 main_buttons: @@ -82,7 +121,7 @@ draw_icons: ;buttons of zoom and [counter],0 - mov [Icon_X],ci_panel_x_pos+178 + mov [Icon_X],ci_panel_x_pos+ci_panel_zoom_x next_button_zoom: diff --git a/programs/media/animage/trunk/icons_instruments.inc b/programs/media/animage/trunk/icons_instruments.inc index 2191f367a7..ce8e8c199c 100644 --- a/programs/media/animage/trunk/icons_instruments.inc +++ b/programs/media/animage/trunk/icons_instruments.inc @@ -23,7 +23,7 @@ local .horizontal_width_put mov [counter],5 .horizontal_width_put: - mov edx,[ebx+4807*4+ebp] + mov edx,[ebx+mem_offs_shape+ebp] ;and edx,0xffffff mov [edi],dx shr edx,16 @@ -73,9 +73,9 @@ local .horizontal_width_save mov eax,edi mov edx,[eax] ;and edx,0xffffff - mov [ebx+4807*4+ebp],dx + mov [ebx+mem_offs_shape+ebp],dx shr edx,16 - mov [ebx+4807*4+2+ebp],dl + mov [ebx+mem_offs_shape+2+ebp],dl add edi,3 add ebp,4 diff --git a/programs/media/animage/trunk/load_from_parameters.inc b/programs/media/animage/trunk/load_from_parameters.inc index acd18d4ca4..8ad5c62e74 100644 --- a/programs/media/animage/trunk/load_from_parameters.inc +++ b/programs/media/animage/trunk/load_from_parameters.inc @@ -1,7 +1,9 @@ ; load picture from file to memory align 4 open_b rb 560 +txt_not_memory db 'Cannot open image. Because there is not enough available memory.',0 +align 4 load_picture: mov [file_information.Function], SSF_GET_INFO mov [file_information.Position], 0 @@ -15,11 +17,11 @@ load_picture: jnz .end_open mov ecx,dword[open_b+32] ;+32 qword: ╤А╨░╨╖╨╝╨╡╤А ╤Д╨░╨╣╨╗╨░ ╨▓ ╨▒╨░╨╣╤В╨░╤Е - add ecx,mem_screen+mem_panel_b+mem_flood_f + add ecx,mem_screen+mem_panel_all+mem_flood_f mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[ScreenPointer] mov [ScreenPointer],eax - add eax,mem_screen+mem_panel_b - sub ecx,mem_screen+mem_panel_b+mem_flood_f + add eax,mem_screen+mem_panel_all + sub ecx,mem_screen+mem_panel_all+mem_flood_f mov [file_information.Function], SSF_READ_FILE mov [file_information.Position], 0 mov [file_information.Flags], 0 @@ -32,7 +34,7 @@ load_picture: je .end_open ;╨╛╨┐╤А╨╡╨┤╨╡╨╗╤П╨╡╨╝ ╨▓╨╕╨┤ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╤П ╨╕ ╨┐╨╕╤И╨╡╨╝ ╨╡╨│╨╛ ╨┐╨░╤А╨░╨╝╨╡╤В╤А╤Л mov eax,[ScreenPointer] - add eax,mem_screen+mem_panel_b + add eax,mem_screen+mem_panel_all stdcall [img_decode], eax,ebx,0 push eax ;╨╛╨┐╤А╨╡╨┤╨╡╨╗╤П╨╡╨╝ ╤А╨░╨╖╨╝╨╡╤А ╨┤╨╡╨║╨╛╨┤╨╕╤А╨╛╨▓╨░╨╜╨╜╨╛╨│╨╛ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╤П @@ -42,13 +44,21 @@ load_picture: mov dword[Picture_SizeY],eax imul ecx,eax imul ecx,15 - add ecx,mem_screen+mem_panel_b+mem_flood_f + add ecx,mem_screen+mem_panel_all+mem_flood_f mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[ScreenPointer] - mov [ScreenPointer],eax - call prepare_data_pointers - pop ebx - stdcall [img_to_rgb2], ebx,[PointerToPicture] ;╨┐╤А╨╡╨╛╨▒╤А╨░╨╖╤Г╨╡╨╝ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╨╡ ╨║ ╤Д╨╛╤А╨╝╨░╤В╤Г rgb + or eax,eax + jnz .have_new_memory + notify_window_run txt_not_memory + pop ebx + jmp @f + .have_new_memory: + ;notify_window_run sz_main_menu_File_Open + mov [ScreenPointer],eax + call prepare_data_pointers + pop ebx + stdcall [img_to_rgb2], ebx,[PointerToPicture] ;╨┐╤А╨╡╨╛╨▒╤А╨░╨╖╤Г╨╡╨╝ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╨╡ ╨║ ╤Д╨╛╤А╨╝╨░╤В╤Г rgb + mov [save_flag],1 + @@: stdcall [img_destroy], ebx ;╤Г╨┤╨░╨╗╤П╨╡╨╝ ╨▓╤А╨╡╨╝╨╡╨╜╨╜╤Л╨╣ ╨▒╤Г╤Д╨╡╤А ╤Б ╨┐╨░╤А╨░╨╝╨╡╤В╤А╨░╨╝╨╕ ╨╕╨╖╨╛╨▒╤А╨░╨╢╨╡╨╜╨╕╤П - mov [save_flag],1 .end_open: ret diff --git a/programs/media/animage/trunk/memory.inc b/programs/media/animage/trunk/memory.inc index 013fd9a2a5..978537450b 100644 --- a/programs/media/animage/trunk/memory.inc +++ b/programs/media/animage/trunk/memory.inc @@ -1,7 +1,25 @@ mem_screen equ 1200*1000*3 ;размер памяти для области экрана -mem_panel_b equ 50*(20*20*3) ;размер памяти для панели инструментов +mem_panel_but equ 50*(20*20*3) ;память для панели инструментов +mem_panel_zoom equ 6*(18*21*3) ;память для панели с кнопками масштабов +mem_panel_all equ mem_panel_but+mem_panel_zoom ;размер памяти для + ;всех панелей инструментов mem_flood_f equ 500000 ;размер буфера для заливки, а также для палитры +mem_offs_shape equ 4807*4 ;смещение для разделения массива ReserveArray + +; Формулы примерного вычисления памяти для редактирования: +; +; mem_flood_f примерно равно 4*((1200^2+1000^2)^0.5)*3*(1+5*5) +; Т.е. 4 диагонали экрана 1200 на 1000 умноженных на 26. +; На каждый пиксель рисуемой фигуры приходится также область +; памяти для запоминания фонового изображения, с учетом того +; что максимальный размер кисти 5*5 получаем 26 = 1 + 5*5. +; +; Память ReserveArray делится на 2 области: 1-я для точек +; рисуемой фигуры, 2-я для запоминания участков фона 5*5 +; прикрепленных к каждой точке рисуемой фигуры. +; Разделение этой памяти происходит в пропорции 1 к 26, +; что примерно равно: mem_flood_f / (1+5*5) или 4807*4. ;---------------------------------------------------------- ;--------change size of memory which use program----------- @@ -10,22 +28,23 @@ GetMemory: pusha mov ecx,[Picture_SizeX] mov edx,[Picture_SizeY] - imul ecx,edx + imul ecx,edx lea ecx,[ecx+ecx*2] lea ecx,[ecx+ecx*4] ;(Picture_SizeX*Picture_SizeY*3)*5 - add ecx,mem_screen+mem_panel_b+mem_flood_f + add ecx,mem_screen+mem_panel_all+mem_flood_f mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[ScreenPointer] test eax,eax - jnz have_new_memory - mov esi,sound_havent_memory - call sound + jnz .have_new_memory + ;mov esi,sound_havent_memory + ;call sound + notify_window_run txt_not_memory popa add esp,4 jmp still -have_new_memory: +.have_new_memory: mov [ScreenPointer],eax - call prepare_data_pointers + call prepare_data_pointers popa ret ;--------------------------------------------------------- @@ -35,7 +54,7 @@ prepare_data_pointers: imul eax,ebx lea eax,[eax+eax*2] mov ebx,[ScreenPointer] - add ebx,mem_screen+mem_panel_b+mem_flood_f + add ebx,mem_screen+mem_panel_all+mem_flood_f mov [PointerToPicture],ebx mov [PointerToCopyPicture],ebx @@ -56,7 +75,7 @@ prepare_data_pointers: add [PointerToSpriteBufer],eax mov eax,[ScreenPointer] - add eax,mem_screen+mem_panel_b + add eax,mem_screen+mem_panel_all mov [PointerToPalette],eax mov [ReserveArray],eax diff --git a/programs/media/animage/trunk/menu.inc b/programs/media/animage/trunk/menu.inc index 7e10a9d2bb..685cd59304 100644 --- a/programs/media/animage/trunk/menu.inc +++ b/programs/media/animage/trunk/menu.inc @@ -26,6 +26,8 @@ init_main_menu: mov [main_menu_edit], eax stdcall [ksubmenu_new] mov [main_menu_instr], eax + stdcall [ksubmenu_new] + mov [main_menu_filters], eax ; init 'File' menu stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_File_New, 0x71 @@ -67,7 +69,7 @@ init_main_menu: stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_main_menu_Edit, [main_menu_edit] stdcall [ksubmenu_add], [main_menu], eax - ; init 'Edit' menu + ; init 'Instruments' menu stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Instr_Pencil, 0x51 stdcall [ksubmenu_add], [main_menu_instr], eax stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Instr_Brush, 0x52 @@ -97,6 +99,15 @@ init_main_menu: stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_main_menu_Instr, [main_menu_instr] stdcall [ksubmenu_add], [main_menu], eax + ; init 'Reflection' menu + stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Filters_ReflectionLR, 0x41 + stdcall [ksubmenu_add], [main_menu_filters], eax + stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_main_menu_Filters_ReflectionTB, 0x42 + stdcall [ksubmenu_add], [main_menu_filters], eax + + ; add 'Reflection' menu to main + stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_main_menu_Filters, [main_menu_filters] + stdcall [ksubmenu_add], [main_menu], eax ret put_main_menu: @@ -126,6 +137,8 @@ button_handler_main_menu: menu_set 0x59, 5,9 menu_set 0x5a, 5,10 menu_set 0x5b, 5,11 + menu_set 0x41, 4,1 + menu_set 0x42, 4,2 .end_handler: ret @@ -133,6 +146,7 @@ main_menu dd 0 main_menu_file dd 0 main_menu_edit dd 0 main_menu_instr dd 0 +main_menu_filters dd 0 sz_main_menu_File db 'File', 0 sz_main_menu_File_New db 'New', 0 @@ -160,4 +174,8 @@ sz_main_menu_Instr_Line db 'Line', 0 sz_main_menu_Instr_Rectangle db 'Rectangle', 0 sz_main_menu_Instr_Circle db 'Circle', 0 sz_main_menu_Instr_Ellips db 'Ellips', 0 -sz_main_menu_Instr_Hard_contour db 'Hard contour', 0 \ No newline at end of file +sz_main_menu_Instr_Hard_contour db 'Hard contour', 0 + +sz_main_menu_Filters db 'Filters', 0 +sz_main_menu_Filters_ReflectionLR db 'Reflection |', 0 +sz_main_menu_Filters_ReflectionTB db 'Reflection -', 0 \ No newline at end of file diff --git a/programs/media/animage/trunk/menu_instruments.inc b/programs/media/animage/trunk/menu_instruments.inc index f0df91e384..055484a5e6 100644 --- a/programs/media/animage/trunk/menu_instruments.inc +++ b/programs/media/animage/trunk/menu_instruments.inc @@ -607,6 +607,14 @@ no_edit: instrument_set 11,20 ; draw hard contour no_instruments: +;|||||||||||||||||||||||||FILTERS|||||||||||||||||||||||||| + cmp [number_panel],4 + jne no_filters + + instrument_set 1,23 ; reflection from left to right + instrument_set 2,24 ; reflection from up to down + +no_filters: end_menu: and [number_panel],0 diff --git a/programs/media/animage/trunk/panel_zoom.png b/programs/media/animage/trunk/panel_zoom.png new file mode 100644 index 0000000000000000000000000000000000000000..72fb2a079ca7fef53e0a5fb17a6ebcfafcfee3b9 GIT binary patch literal 516 zcmeAS@N?(olHy`uVBq!ia0vp^LO@){!2~3i&AO%tq*&4&eH|GXHuiJ>Nn{1`ISV`@ ziy0XB4ude`@%$AjKtYKT*NBqf{Irtt#G+J&g2c?c61}|C5(N`I13k+e<2pYE2F4~& z7srqY_q#U^7Ctr*U=37#`CyK4aDa{xW0U;iX|CokC)wDM# z&EIonKm(qhKmCB4cXtKQc0Ii~>q8LV)NJ=ab!-{XQ%Te3NAlfIh~KyERD%7+|0m>E zLcIsJYs>%AL#Lo#13ENo&%X$x(wk4F98~+cgl%8A`ssyi`zD@AT-De=+0w`KL!nW- p=5nj`r*qg~zN*>I@jdk?lWWqMqlY@SiUMPd!PC{xWt~$(696-V>B9g3 literal 0 HcmV?d00001