diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm index b5c7c65e83..96df0441f8 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm @@ -1,5 +1,5 @@ use32 - org 0x0 + org 0 db 'MENUET01' dd 1,start,i_end,mem,stacktop,0,cur_dir_path @@ -112,7 +112,7 @@ draw_window: add ebx,IMAGE_TOOLBAR_ICON_SIZE mcall ,,,(95 shl 16)+5 ;масштаб - - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] mcall SF_REDRAW,SSF_END_DRAW popad ret @@ -146,7 +146,7 @@ key: mov byte[txt_angle_y.v],0 stdcall str_cat, txt_angle_y.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,177 ;Down jne @f @@ -160,7 +160,7 @@ key: mov byte[txt_angle_y.v],0 stdcall str_cat, txt_angle_y.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,176 ;Left jne @f @@ -174,7 +174,7 @@ key: mov byte[txt_angle_z.v],0 stdcall str_cat, txt_angle_z.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,179 ;Right jne @f @@ -188,7 +188,7 @@ key: mov byte[txt_angle_z.v],0 stdcall str_cat, txt_angle_z.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: jmp still @@ -227,14 +227,14 @@ align 4 but_dr_0: mov dword[dr_figure],0 call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 but_dr_1: mov dword[dr_figure],1 call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 @@ -257,7 +257,7 @@ but_zoom_p: mov byte[txt_scale.v],0 stdcall str_cat, txt_scale.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 @@ -280,14 +280,11 @@ but_zoom_m: mov byte[txt_scale.v],0 stdcall str_cat, txt_scale.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0 -align 4 -ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext -;sizeof.TinyGLContext = 28 align 4 draw_3d: @@ -387,13 +384,6 @@ stdcall [glPopMatrix] stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_y,5,25,0xffff00 ret -dr_figure dd 0 -qObj dd 0 -TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.) -texture dd 0 ;указатель на память с текстурой -text_w dd 0 -text_h dd 0 - scale dd 0.4 ;начальный масштаб sc_delt dd 0.05 ;изменение масштаба при нажатии sc_min dd 0.1 ;минимальный масштаб @@ -534,14 +524,14 @@ system_dir_1 db '/sys/lib/' lib_name_1 db 'buf2d.obj',0 system_dir_2 db '/sys/lib/' lib_name_2 db 'libimg.obj',0 -err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,0 -err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,0 -err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,0 +err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0 +err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,'" -tE',0 +err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,'" -tE',0 head_f_i: -head_f_l db 'System error',0 -err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,0 -err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,0 -err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,0 +head_f_l db '"System error',0 +err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0 +err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,'" -tE',0 +err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0 ;-------------------------------------------------- txt_scale: @@ -589,6 +579,14 @@ l_libs_end: align 4 i_end: + ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext + ;sizeof.TinyGLContext = 28 + dr_figure dd 0 + qObj dd 0 + TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.) + texture dd 0 ;указатель на память с текстурой + text_w dd 0 + text_h dd 0 run_file_70 FileInfoBlock sc system_colors align 16 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm index 030ad78761..ed111fe428 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm @@ -1,5 +1,5 @@ use32 - org 0x0 + org 0 db 'MENUET01' dd 1,start,i_end,mem,stacktop,0,cur_dir_path @@ -114,7 +114,7 @@ draw_window: add ebx,IMAGE_TOOLBAR_ICON_SIZE mcall ,,,(95 shl 16)+5 ;масштаб - - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] mcall SF_REDRAW,SSF_END_DRAW popad ret @@ -148,7 +148,7 @@ key: mov byte[txt_angle_y.v],0 stdcall str_cat, txt_angle_y.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,179 ;Right jne @f @@ -162,7 +162,7 @@ key: mov byte[txt_angle_y.v],0 stdcall str_cat, txt_angle_y.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,178 ;Up jne @f @@ -176,7 +176,7 @@ key: mov byte[txt_angle_x.v],0 stdcall str_cat, txt_angle_x.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: cmp ah,177 ;Down jne @f @@ -190,7 +190,7 @@ key: mov byte[txt_angle_x.v],0 stdcall str_cat, txt_angle_x.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] @@: jmp still @@ -229,14 +229,14 @@ align 4 but_dr_0: mov dword[dr_figure],0 call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 but_dr_1: mov dword[dr_figure],1 call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 @@ -259,7 +259,7 @@ but_zoom_p: mov byte[txt_scale.v],0 stdcall str_cat, txt_scale.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 @@ -282,14 +282,11 @@ but_zoom_m: mov byte[txt_scale.v],0 stdcall str_cat, txt_scale.v,Data_String call draw_3d - stdcall [kosglSwapBuffers] + call [kosglSwapBuffers] ret align 4 caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0 -align 4 -ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext -;sizeof.TinyGLContext = 28 align 4 draw_3d: @@ -324,13 +321,6 @@ stdcall [glPopMatrix] stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_x,5,25,0xffff00 ret -dr_figure dd 0 -qObj dd 0 -TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.) -texture dd 0 ;указатель на память с текстурой -text_w dd 0 -text_h dd 0 - scale dd 0.95 ;начальный масштаб sc_delt dd 0.05 ;изменение масштаба при нажатии sc_min dd 0.1 ;минимальный масштаб @@ -464,14 +454,14 @@ system_dir_1 db '/sys/lib/' lib_name_1 db 'buf2d.obj',0 system_dir_2 db '/sys/lib/' lib_name_2 db 'libimg.obj',0 -err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,0 -err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,0 -err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,0 +err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0 +err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,'" -tE',0 +err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,'" -tE',0 head_f_i: -head_f_l db 'System error',0 -err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,0 -err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,0 -err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,0 +head_f_l db '"System error',0 +err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0 +err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,'" -tE',0 +err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0 ;-------------------------------------------------- txt_scale: @@ -525,6 +515,14 @@ l_libs_end: align 4 i_end: + ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext + ;sizeof.TinyGLContext = 28 + dr_figure dd 0 + qObj dd 0 + TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.) + texture dd 0 ;указатель на память с текстурой + text_w dd 0 + text_h dd 0 run_file_70 FileInfoBlock sc system_colors align 16 diff --git a/programs/develop/libraries/TinyGL/asm_fork/init.asm b/programs/develop/libraries/TinyGL/asm_fork/init.asm index a16046934e..b680d44128 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/init.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/init.asm @@ -25,7 +25,8 @@ proc endSharedState uses eax ebx, context:dword endp align 4 -proc glInit uses eax ebx ecx edx, zbuffer1:dword +proc glInit, zbuffer1:dword +pushad stdcall gl_zalloc,sizeof.GLContext mov dword[gl_ctx],eax mov edx,eax @@ -174,7 +175,7 @@ proc glInit uses eax ebx ecx edx, zbuffer1:dword ; depth test mov dword[edx+GLContext.depth_test],0 - +popad ret endp diff --git a/programs/media/img_transform/Tupfile.lua b/programs/media/img_transform/Tupfile.lua new file mode 100644 index 0000000000..55d5813f68 --- /dev/null +++ b/programs/media/img_transform/Tupfile.lua @@ -0,0 +1,3 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en" or tup.getconfig("LANG")) .. " > lang.inc", {"lang.inc"}) +tup.rule({"img_transform.asm", extra_inputs = {"lang.inc"}}, "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "img_transform") diff --git a/programs/media/img_transform/build_en.bat b/programs/media/img_transform/build_en.bat new file mode 100644 index 0000000000..d103db725e --- /dev/null +++ b/programs/media/img_transform/build_en.bat @@ -0,0 +1,6 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm img_transform.asm img_transform.kex +@kpack img_transform.kex +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/media/img_transform/build_ru.bat b/programs/media/img_transform/build_ru.bat new file mode 100644 index 0000000000..ab4c3fc880 --- /dev/null +++ b/programs/media/img_transform/build_ru.bat @@ -0,0 +1,6 @@ +@erase lang.inc +@echo lang fix ru >lang.inc +@fasm img_transform.asm img_transform.kex +@kpack img_transform.kex +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/media/img_transform/doc/about.htm b/programs/media/img_transform/doc/about.htm new file mode 100644 index 0000000000..93a7b5f414 --- /dev/null +++ b/programs/media/img_transform/doc/about.htm @@ -0,0 +1,89 @@ + + +Image transform + + + + + +

Image transform 16.05.20

+ +

+ + +

+

Image transform - .

+ +

+

. 1.

+ +

:

+

() , .. 4 , . 1 4, . , .

+ +

+

. 2.

+ +

+

. 3.

+ +

+

.

+

.

+

. 2- : .

+

. 2- : .

+

.

+ +

+

Ctrl+O - .

+

Ctrl+S - .

+

1, 2, 3, 4 - .

+

, , , - .

+ +

+

IgorA

+ + \ No newline at end of file diff --git a/programs/media/img_transform/doc/but_01.png b/programs/media/img_transform/doc/but_01.png new file mode 100644 index 0000000000..0a74dce7bf Binary files /dev/null and b/programs/media/img_transform/doc/but_01.png differ diff --git a/programs/media/img_transform/doc/but_02.png b/programs/media/img_transform/doc/but_02.png new file mode 100644 index 0000000000..f269a05771 Binary files /dev/null and b/programs/media/img_transform/doc/but_02.png differ diff --git a/programs/media/img_transform/doc/but_03.png b/programs/media/img_transform/doc/but_03.png new file mode 100644 index 0000000000..3b4fa179e9 Binary files /dev/null and b/programs/media/img_transform/doc/but_03.png differ diff --git a/programs/media/img_transform/doc/but_04.png b/programs/media/img_transform/doc/but_04.png new file mode 100644 index 0000000000..3773988e6a Binary files /dev/null and b/programs/media/img_transform/doc/but_04.png differ diff --git a/programs/media/img_transform/doc/but_05.png b/programs/media/img_transform/doc/but_05.png new file mode 100644 index 0000000000..d723b1ec27 Binary files /dev/null and b/programs/media/img_transform/doc/but_05.png differ diff --git a/programs/media/img_transform/doc/img_01.png b/programs/media/img_transform/doc/img_01.png new file mode 100644 index 0000000000..ee6b382fae Binary files /dev/null and b/programs/media/img_transform/doc/img_01.png differ diff --git a/programs/media/img_transform/doc/img_02.png b/programs/media/img_transform/doc/img_02.png new file mode 100644 index 0000000000..5566b72156 Binary files /dev/null and b/programs/media/img_transform/doc/img_02.png differ diff --git a/programs/media/img_transform/doc/img_03.png b/programs/media/img_transform/doc/img_03.png new file mode 100644 index 0000000000..b897e28b49 Binary files /dev/null and b/programs/media/img_transform/doc/img_03.png differ diff --git a/programs/media/img_transform/img_transform.asm b/programs/media/img_transform/img_transform.asm new file mode 100644 index 0000000000..cbdc85fb5d --- /dev/null +++ b/programs/media/img_transform/img_transform.asm @@ -0,0 +1,1349 @@ +use32 + org 0 + db 'MENUET01' + dd 1,start,i_end,mem,stacktop,openfile_path,sys_path + +include 'lang.inc' +include '../../../programs/macros.inc' +include '../../../programs/proc32.inc' +include '../../../programs/KOSfuncs.inc' +include '../../../programs/load_img.inc' +include '../../../programs/develop/libraries/TinyGL/asm_fork/opengl_const.inc' +include '../../../programs/develop/libraries/libs-dev/libimg/libimg.inc' +include '../../../programs/develop/info3ds/info_fun_float.inc' + +txt_buf rb 8 + +@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load +caption db 'Image transform 16.05.20',0 ; + +offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc' + +BUF_STRUCT_SIZE equ 21 +buf2d_data equ dword[edi] ; ࠦ +buf2d_w equ dword[edi+8] ;ਭ +buf2d_h equ dword[edi+12] ; +buf2d_l equ word[edi+4] +buf2d_t equ word[edi+6] ; ᢥ +buf2d_size_lt equ dword[edi+4] ; ᫥ ࠢ +buf2d_color equ dword[edi+16] ;梥 䮭 +buf2d_bits equ byte[edi+20] ;⢮ 1- 窥 ࠦ + +include 'select_points.inc' + +IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3 +image_data_toolbar dd 0 + +align 4 +start: + load_libraries l_libs_start,l_libs_end + ;஢ઠ ᪮쪮 㤠筮 㧨 ⥪ + mov ebp,lib_0 + cmp dword [ebp+ll_struc_size-4],0 + jz @f + mcall SF_TERMINATE_PROCESS + @@: + mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors + mcall SF_SET_EVENTS_MASK,0xC0000027 + stdcall [OpenDialog_Init],OpenDialog_data ;⮢ + + stdcall [buf2d_create], buf_0 ;ᮧ + + include_image_file '../../../programs/fs/kfar/trunk/font6x9.bmp', image_data_toolbar, buf_font.w,buf_font.h + stdcall [buf2d_create_f_img], buf_font,[image_data_toolbar] ;ᮧ + stdcall mem.Free,[image_data_toolbar] ;᢮ + stdcall [buf2d_conv_24_to_8], buf_font,1 ; ஧筮 8 + stdcall [buf2d_convert_text_matrix], buf_font + + include_image_file 'toolbar.png', image_data_toolbar + + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov [last_time],eax + + ;ன 祪 + call points_init + + ;open file from cmd line + cmp dword[openfile_path],0 + je @f + call but_open_file.no_dlg + @@: + +align 4 +red_win: + call draw_window + +align 16 +still: + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov ebx,[last_time] + add ebx,10 ;প + cmp ebx,eax + jge @f + mov ebx,eax + @@: + sub ebx,eax + mcall SF_WAIT_EVENT_TIMEOUT + cmp eax,0 + je timer_funct + + cmp al,1 + jz red_win + cmp al,2 + jz key + cmp al,3 + jz button + cmp al,6 + jne @f + mcall SF_THREAD_INFO,procinfo,-1 + cmp ax,word[procinfo.window_stack_position] + jne @f ; ⨢ + call mouse + @@: + jmp still + +align 4 +timer_funct: + push eax ebx + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov [last_time],eax + pop ebx eax + cmp byte[calc],0 + je still + call draw_buffers + jmp still + +align 16 +draw_window: +pushad + mcall SF_REDRAW,SSF_BEGIN_DRAW + + ; *** ᮢ (믮 1 ࠧ ᪥) *** + mov edx,[sc.work] + or edx,(3 shl 24)+0x30000000 + mcall SF_CREATE_WINDOW,(20 shl 16)+410,(20 shl 16)+520,,,caption + + mcall SF_THREAD_INFO,procinfo,-1 + mov eax,dword[procinfo.box.height] + cmp eax,120 + jge @f + mov eax,120 ;min size + @@: + sub eax,65 + mov ebx,dword[procinfo.box.width] + cmp ebx,270 + jge @f + mov ebx,270 + @@: + sub ebx,19 + cmp eax,dword[buf_0.h] ;ᬮਬ ࠧ + jne @f + cmp ebx,dword[buf_0.w] + jne @f + jmp .end0 + @@: + stdcall [buf2d_resize],buf_0,ebx,eax,1 + call calc_nav_params + mov byte[calc],1 + .end0: + + ; *** ᮧ *** + mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(5 shl 16)+20,3, [sc.work_button] + + add ebx,25 shl 16 + mcall ,,,4 + add ebx,30 shl 16 + mcall ,,,5 + add ebx,25 shl 16 + mcall ,,,6 + add ebx,25 shl 16 + mcall ,,,7 + + ; *** ᮢ *** + mov edx,(7 shl 16)+7 ;icon open + mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16 + + add ebx,IMAGE_TOOLBAR_ICON_SIZE + add edx,(25 shl 16) ;icon save + int 0x40 + add ebx,IMAGE_TOOLBAR_ICON_SIZE + add edx,(30 shl 16) ;icon view + int 0x40 + add ebx,IMAGE_TOOLBAR_ICON_SIZE + add edx,(25 shl 16) ;icon mode + int 0x40 + add ebx,IMAGE_TOOLBAR_ICON_SIZE + add edx,(25 shl 16) ; + int 0x40 + + call draw_buffers + + mcall SF_REDRAW,SSF_END_DRAW +popad + ret + +align 4 +proc draw_buffers +pushad + cmp byte[calc],0 + je .end0 + ; *** *** + bt dword[nav_x_min],31 + jnc .beg0 + bt dword[nav_y_min],31 + jc @f + .beg0: + stdcall [buf2d_clear], buf_0, [buf_0.color] ;⨬ + @@: + cmp byte[view_b],1 + je .end1 + push buf_i0 + jmp .end2 + .end1: + push buf_ogl + ;call [kosglSwapBuffers] + .end2: + stdcall [buf2d_bit_blt], buf_0, [nav_x],[nav_y] ;,... + + call points_draw + + ; *** ࠧ 䠩 *** + mov edi,txt_f_size.size + mov eax,[open_file_size] + mov ebx,txt_pref + .cycle: + cmp eax,1024 + jl @f + shr eax,10 + add ebx,4 + jmp .cycle + @@: + stdcall convert_int_to_str, 16 + stdcall str_cat, edi,ebx + stdcall str_cat, edi,txt_space ;騩 ஡ + mov byte[calc],0 + .end0: + ; *** ᮢ *** + stdcall [buf2d_draw], buf_0 + ; *** ᮢ ࠧ 䠩 *** + mov ecx,[sc.work_text] + or ecx,0x80000000 or (1 shl 30) + mov edi,[sc.work] ;梥 䮭 + mcall SF_DRAW_TEXT,(275 shl 16)+7,,txt_f_size +popad + ret +endp + +align 16 +key: + push eax ebx ecx + mcall SF_GET_KEY + cmp byte[view_b],1 + je .end1 + cmp ah,49 ;1 + jne @f + mov edi,sel_pt + call set_point_coords + jmp .end0 + @@: + cmp ah,50 ;2 + jne @f + mov edi,sel_pt+sizeof.point2d + call set_point_coords + jmp .end0 + @@: + cmp ah,51 ;3 + jne @f + mov edi,sel_pt+sizeof.point2d*2 + call set_point_coords + jmp .end0 + @@: + cmp ah,52 ;4 + jne @f + mov edi,sel_pt+sizeof.point2d*3 + call set_point_coords + jmp .end0 + @@: + .end1: + + cmp ah,178 ;Up + jne @f + call but_img_move_up + jmp .end0 + @@: + cmp ah,177 ;Down + jne @f + call but_img_move_down + jmp .end0 + @@: + cmp ah,176 ;Left + jne @f + call but_img_move_left + jmp .end0 + @@: + cmp ah,179 ;Right + jne @f + call but_img_move_right + jmp .end0 + @@: + + mov ecx,eax + mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS + bt eax,2 ;left Ctrl + jc .key_Ctrl + bt eax,3 ;right Ctrl + jc .key_Ctrl + jmp .end0 + .key_Ctrl: + cmp ch,15 ;Ctrl+O + jne @f + call but_open_file + @@: + cmp ch,19 ;Ctrl+S + jne @f + call but_save_file + @@: + + .end0: + pop ecx ebx eax + jmp still + +;input: +; edi - 㪠⥫ point2d +align 4 +set_point_coords: + call buf_get_mouse_coord + cmp eax,-1 + je .end0 + sub eax,[nav_x] + cmp eax,0 + jge @f + xor eax,eax + @@: + cmp eax,[buf_i0.w] + jle @f + mov eax,[buf_i0.w] + @@: + mov [edi+point2d.x],eax + sub ebx,[nav_y] + cmp ebx,0 + jge @f + xor ebx,ebx + @@: + cmp ebx,[buf_i0.h] + jle @f + mov ebx,[buf_i0.h] + @@: + mov [edi+point2d.y],ebx + call points_update_prop + mov byte[calc],1 + .end0: + ret + +align 16 +button: + mcall SF_GET_BUTTON + cmp ah,3 + jne @f + call but_open_file + jmp still + @@: + cmp ah,4 + jne @f + call but_save_file + jmp still + @@: + cmp ah,5 + jne @f + call but_2 + jmp still + @@: + cmp ah,6 + jne @f + call but_3 + jmp still + @@: + cmp ah,7 + jne @f + call but_about + jmp still + @@: + cmp ah,1 + jne still +.exit: + stdcall [buf2d_delete],buf_0 + stdcall [buf2d_delete],buf_i0 + ;stdcall [buf2d_delete],buf_ogl + stdcall mem.Free,[image_data_toolbar] + stdcall mem.Free,[open_file_img] + mcall SF_TERMINATE_PROCESS + +align 4 +mouse: + push eax ebx ecx + mcall SF_MOUSE_GET,SSF_BUTTON_EXT + bt eax,8 + jnc @f + ;mouse l. but. press + call mouse_left_d + jmp .end_l + @@: + ;bt eax,0 + ;jnc @f + ;mouse l. but. move + ;call mouse_left_m + ;jmp .end_l + ;@@: + bt eax,16 + jnc .end_l + ;mouse l. but. up + call mouse_left_u + ;jmp .end_l + .end_l: + ;bt eax,9 + ;jnc @f + ;mouse r. but. press + ;call mouse_right_d + ;jmp .end_r + ;@@: + ;bt eax,1 + ;jnc @f + ;mouse r. but. move + ;call mouse_right_m + ;jmp .end_r + ;@@: + ;.end_r: + + pop ecx ebx eax + ret + +;output: +; eax - buffer coord X (᫨ ஬ -1) +; ebx - buffer coord Y (᫨ ஬ -1) +align 4 +proc buf_get_mouse_coord + mcall SF_MOUSE_GET,SSF_WINDOW_POSITION + cmp ax,word[buf_0.t] + jl .no_buf ; y + mov ebx,eax + shr ebx,16 + cmp bx,word[buf_0.l] + jl .no_buf ; x + + and eax,0xffff ;⠢塞 न y + sub ax,word[buf_0.t] + cmp eax,[buf_0.h] + jg .no_buf + sub bx,word[buf_0.l] + cmp ebx,[buf_0.w] + jg .no_buf + xchg eax,ebx + jmp .end_f + .no_buf: + xor eax,eax + not eax + xor ebx,ebx + not ebx + .end_f: + ret +endp + +align 4 +mouse_left_d: +pushad + call buf_get_mouse_coord + cmp eax,-1 + je .end0 + mov [mouse_down_x],eax + mov [mouse_down_y],ebx + sub eax,[nav_x] + sub ebx,[nav_y] + + mov edi,sel_pt + xor ecx,ecx + .cycle0: + mov edx,[edi+point2d.x] + sub edx,eax + bt edx,31 + jnc @f + neg edx + @@: + cmp edx,5 ;ࠧ 뤥 窨 x + jg .end1 + mov edx,[edi+point2d.y] + sub edx,ebx + bt edx,31 + jnc @f + neg edx + @@: + cmp edx,5 ;ࠧ 뤥 窨 y + jg .end1 + mov [sel_act],ecx + jmp .end0 + .end1: + add edi,sizeof.point2d + inc ecx + cmp ecx,4 + jl .cycle0 + mov dword[sel_act],-1 + .end0: +popad + ret + +align 4 +proc mouse_left_u uses eax + call buf_get_mouse_coord + cmp eax,-1 + je .end0 + sub [mouse_down_x],eax + sub [mouse_down_y],ebx + + mov eax,[nav_y] + sub eax,[mouse_down_y] + cmp eax,[nav_y_min] + jge @f + mov eax,[nav_y_min] + @@: + cmp eax,[nav_y_max] + jle @f + mov eax,[nav_y_max] + @@: + mov [nav_y],eax + + mov eax,[nav_x] + sub eax,[mouse_down_x] + cmp eax,[nav_x_min] + jge @f + mov eax,[nav_x_min] + @@: + cmp eax,[nav_x_max] + jle @f + mov eax,[nav_x_max] + @@: + mov [nav_x],eax + + mov byte[calc],1 + + .end0: + ret +endp + +align 4 +proc but_new_file uses eax edi esi + xor eax,eax + mov [open_file_size],eax + mov edi,[open_file_img] + stosd + ret +endp + +align 4 +open_file_img dd 0 ;㪠⥫ ⥪ +open_file_size dd 0 ;ࠧ + +;᫥ ࠬ஢ 樨 ࠦ +align 4 +proc calc_nav_params uses eax edi + mov dword[nav_x_max],0 + mov edi,buf_0 + mov eax,buf2d_w + mov [nav_sx],eax + mov edi,buf_i0 + sub eax,buf2d_w + bt eax,31 + jc @f + mov [nav_x_max],eax + xor eax,eax + @@: + mov [nav_x_min],eax + mov edi,buf2d_w + cmp [nav_sx],edi + jle @f + mov [nav_sx],edi + @@: + shr dword[nav_sx],1 + + mov dword[nav_y_max],0 + mov edi,buf_0 + mov eax,buf2d_h + mov [nav_sy],eax + mov edi,buf_i0 + sub eax,buf2d_h + bt eax,31 + jc @f + mov [nav_y_max],eax + xor eax,eax + @@: + mov [nav_y_min],eax + mov edi,buf2d_h + cmp [nav_sy],edi + jle @f + mov [nav_sy],edi + @@: + shr dword[nav_sy],1 + ret +endp + +align 4 +proc but_open_file + copy_path open_dialog_name,communication_area_default_path,file_name,0 + pushad + mov [OpenDialog_data.type],0 + stdcall [OpenDialog_Start],OpenDialog_data + cmp [OpenDialog_data.status],2 + je .end_open_file + jmp .end0 +.no_dlg: ;᫨ 㥬 䠩 + pushad + mov esi,openfile_path + stdcall str_len,esi + add esi,eax + @@: ;横 ᪠ 砫 䠩 + dec esi + cmp byte[esi],'/' + je @f + cmp byte[esi],0x5c ;'\' + je @f + cmp esi,openfile_path + jg @b + @@: + inc esi + stdcall [OpenDialog_Set_file_name],OpenDialog_data,esi ;㥬 䠩 ࠭ + .end0: + + mov [run_file_70.Function], SSF_GET_INFO + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + mov dword[run_file_70.Count], 0 + mov dword[run_file_70.Buffer], open_b + mov byte[run_file_70+20], 0 + mov dword[run_file_70.FileName], openfile_path + mcall SF_FILE,run_file_70 + + ;mov eax,dword[open_b+32] + ;mov edi,txt_buf + ;stdcall convert_int_to_str,20 + ;notify_window_run txt_buf + + mov ecx,dword[open_b+32] ;+32 qword: ࠧ 䠩 + mov [open_file_size],ecx + stdcall mem.ReAlloc,[open_file_img],ecx ;뤥塞 ࠦ + mov [open_file_img],eax + + mov [run_file_70.Function], SSF_READ_FILE + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + m2m [run_file_70.Count], dword[open_file_size] + m2m [run_file_70.Buffer],dword[open_file_img] + mov byte[run_file_70+20], 0 + mov [run_file_70.FileName], openfile_path + mcall SF_FILE,run_file_70 + cmp ebx,0xffffffff + je .end_0 + ;।塞 ࠦ + stdcall [img_decode], [open_file_img],ebx,0 + or eax,eax + jz .end_0 ;᫨ 襭 ଠ 䠩 + mov ebx,eax + + mov ecx,[ebx+4] ;+4 = image width + mov dword[buf_cop.w],ecx + imul ecx,[ebx+8] ;+8 = image height + lea ecx,[ecx+ecx*2] + mov [open_file_size],ecx + stdcall mem.ReAlloc,[open_file_img],ecx + mov [open_file_img],eax + mov dword[buf_cop],eax + mov dword[buf_cop.l],0 ;left = 0, top = 0 + m2m dword[buf_cop.h],dword[ebx+8] + + ;८ࠧ㥬 ࠦ ଠ rgb + stdcall [img_to_rgb2], ebx,[open_file_img] + mov edi,buf_i0 + cmp buf2d_data,0 + jne .end3 + stdcall getNextPowerOfTwo,[ebx+4] + mov buf2d_w,eax + m2m buf2d_h,dword[ebx+8] ;+8 = image height + cmp eax,[ebx+4] + jg @f + m2m buf2d_w,dword[ebx+4] + stdcall [buf2d_create_f_img], edi,[open_file_img] + jmp .end_1 + @@: + sub eax,[ebx+4] + shr eax,1 + mov esi,eax + stdcall [buf2d_create], edi + mov [buf_cop.l],si + stdcall [buf2d_bit_blt], edi, esi,0, buf_cop + jmp .end_1 + .end3: + stdcall getNextPowerOfTwo,[ebx+4] + cmp eax,[ebx+4] + jg @f + mov eax,[ebx+4] + @@: + mov ecx,eax + mov edx,[ebx+8] + stdcall [buf2d_resize], edi, ecx,edx,1 ;塞 ࠧ + sub ecx,[ebx+4] + shr ecx,1 + mov [buf_cop.l],cx + stdcall [buf2d_bit_blt], edi, ecx,0, buf_cop + .end_1: + + ;ᮧ ८ࠧ ࠦ + mov edi,buf_ogl + mov eax,[buf_i0.w] + and eax, not 3 + mov buf2d_w,eax + mov eax,[buf_i0.h] + and eax, not 3 + mov buf2d_h,eax + cmp buf2d_data,0 + jne @f + stdcall [kosglMakeCurrent], 0,35,buf2d_w,buf2d_h,ctx1 + stdcall [glEnable], GL_DEPTH_TEST + stdcall [glEnable], GL_NORMALIZE ; ଠ 稭 䠪⮢ + stdcall [glShadeModel], GL_SMOOTH + stdcall [glScalef], 2.0, -2.0, 1.0 + stdcall [glTranslatef], -0.5, -0.5, 0.0 + jmp .end_2 + @@: + stdcall reshape, buf2d_w,buf2d_h ;塞 ࠧ buf_ogl + .end_2: + mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext + mov eax,[eax] ;eax -> ZBuffer + mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf + mov buf2d_data,eax + + stdcall [buf2d_bit_blt], edi, 0,0, buf_i0 ;㥬 ࠦ ⠭ + + ;* Setup texturing * + stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL + + ;* generate texture object IDs * + stdcall [glGenTextures], 1, TexObj + stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj] + stdcall [glTexImage2D], GL_TEXTURE_2D, 0, 3, [buf_i0.w], [buf_i0.h],\ + 0, GL_RGB, GL_UNSIGNED_BYTE, [buf_i0] ; ⥪ ᭮ , ᠬ ࠦ ᯮ ࠧ஢ ⥪ + + stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST + stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST + stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT + stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT + stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj] + stdcall [glEnable], GL_TEXTURE_2D + + stdcall [buf2d_bit_blt], buf_i0, 0,0, edi ;⠭ ࠦ ᯮ祭 ⠭ ⥪ + + ;㤠塞 ६ ebx + stdcall [img_destroy], ebx + + movzx eax,word[buf_cop.l] + stdcall points_init_2,eax + + call calc_nav_params + xor eax,eax + mov [nav_x],eax + mov ebx,[nav_x_max] + cmp ebx,0 + jle @f + ;᫨ 쪮 ࠦ ⠢ 業 + shr ebx,1 + mov [nav_x],ebx + @@: + mov [nav_y],eax + mov ebx,[nav_y_max] + cmp ebx,0 + jle @f + ;᫨ 쪮 ࠦ ⠢ 業 + shr ebx,1 + mov [nav_y],ebx + @@: + mov byte[view_b],0 + mov dword[sel_act],-1 ;᭨ 뤥 祪 + mov byte[calc],1 + .end_0: + + .end_open_file: + popad + ret +endp + +align 4 +proc getNextPowerOfTwo uses ebx, n:dword + mov ebx,[n] + mov eax,8 ;min size + cmp ebx,eax + jle .set + @@: + shl eax,1 + cmp ebx,eax + jg @b + cmp eax,4096 ;max size + jle .set + mov eax,4096 + .set: + ret +endp + +; new window size or exposure +align 4 +proc reshape uses ebx ecx, width:dword, height:dword + stdcall [glViewport], 0, 0, [width], [height] + stdcall [glMatrixMode], GL_MODELVIEW + stdcall [glLoadIdentity] + stdcall [glScalef], 2.0, -2.0, 1.0 + stdcall [glTranslatef], -0.5, -0.5, 0.0 + ret +endp + +align 4 +proc but_save_file +locals + png_data dd 0 + png_size dd 0 +endl + pushad + copy_path open_dialog_name,communication_area_default_path,file_name,0 + mov [OpenDialog_data.type],1 + stdcall [OpenDialog_Set_file_ext],OpenDialog_data,Filter.1 ;.png + stdcall [OpenDialog_Start],OpenDialog_data + cmp [OpenDialog_data.status],1 + jne .end_save_file + ; 㤠筮 ⨨ + mov dword[png_data],0 + + ;create image struct + stdcall [img_create], [buf_ogl.w], [buf_ogl.h], Image.bpp24 + mov ebx,eax + test eax,eax + jz @f + ;copy foto to image buffer + mov edi,[eax+Image.Data] + mov esi,[buf_ogl] + mov ecx,[buf_ogl.w] + mov edx,[buf_ogl.h] + imul ecx,edx + imul ecx,3 + shr ecx,2 ;OpenGL buffer align to 4 + rep movsd + + ;encode image + stdcall [img_encode], eax, LIBIMG_FORMAT_PNG, 0 + test eax,eax + jz @f + mov [png_data],eax + mov [png_size],ecx + @@: + stdcall [img_destroy],ebx + + ; 塞 ࠭ 䠩 + mov ebx,run_file_70 + mov dword[ebx],SSF_CREATE_FILE + mov eax,[png_size] + mov [ebx+12],eax ;file size + mov eax,[png_data] + mov [ebx+16],eax + mov dword[ebx+FileInfoBlock.FileName], openfile_path + + mcall SF_FILE,run_file_70 + test eax,eax + jnz .save_error + ;notify_window_run openfile_path + jmp @f + .save_error: + ;ᮮ饭 㤠筮 ࠭ + notify_window_run txt_err_save_img_file + @@: + mcall SF_SYS_MISC, SSF_MEM_FREE, [png_data] + .end_save_file: + popad + ret +endp + +align 4 +but_2: + xor byte[view_b],1 + mov byte[calc],1 + ret + +align 4 +but_3: + xor byte[trans_a],1 + call points_update_prop + mov byte[calc],1 + ret + +align 4 +but_about: + notify_window_run txt_about + ret + +align 4 +calc db 0 +view_b db 0 ;0 - 室 , 1 - ᬮ १ +trans_a db 0 ;0 - ८ࠧ ࠧ, 1 - ८ࠧ + +align 4 +proc but_img_move_up uses eax + cmp dword[sel_act],-1 + je .end0 + mov eax,[sel_act] + imul eax,sizeof.point2d + add eax,sel_pt + cmp dword[eax+point2d.y],0 + je .end2 + dec dword[eax+point2d.y] + call points_update_prop + jmp .end1 + .end0: + mov eax,[nav_y] + sub eax,[nav_sy] + cmp eax,[nav_y_min] + jge @f + mov eax,[nav_y_min] + @@: + mov [nav_y],eax + .end1: + mov byte[calc],1 + .end2: + ret +endp + +align 4 +proc but_img_move_down uses eax edi + cmp dword[sel_act],-1 + je .end0 + mov eax,[sel_act] + imul eax,sizeof.point2d + add eax,sel_pt + mov edi,buf_ogl + mov edi,buf2d_h + cmp dword[eax+point2d.y],edi + jge .end2 + inc dword[eax+point2d.y] + call points_update_prop + jmp .end1 + .end0: + mov eax,[nav_y] + add eax,[nav_sy] + cmp eax,[nav_y_max] + jle @f + mov eax,[nav_y_max] + @@: + mov [nav_y],eax + .end1: + mov byte[calc],1 + .end2: + ret +endp + +align 4 +proc but_img_move_left uses eax + cmp dword[sel_act],-1 + je .end0 + mov eax,[sel_act] + imul eax,sizeof.point2d + add eax,sel_pt + cmp dword[eax+point2d.x],0 + je .end2 + dec dword[eax+point2d.x] + call points_update_prop + jmp .end1 + .end0: + mov eax,[nav_x] + sub eax,[nav_sx] + cmp eax,[nav_x_min] + jge @f + mov eax,[nav_x_min] + @@: + mov [nav_x],eax + .end1: + mov byte[calc],1 + .end2: + ret +endp + +align 4 +proc but_img_move_right uses eax edi + cmp dword[sel_act],-1 + je .end0 + mov eax,[sel_act] + imul eax,sizeof.point2d + add eax,sel_pt + mov edi,buf_ogl + mov edi,buf2d_w + cmp dword[eax+point2d.x],edi + jge .end2 + inc dword[eax+point2d.x] + call points_update_prop + jmp .end1 + .end0: + mov eax,[nav_x] + add eax,[nav_sx] + cmp eax,[nav_x_max] + jle @f + mov eax,[nav_x_max] + @@: + mov [nav_x],eax + .end1: + mov byte[calc],1 + .end2: + ret +endp + +;input: +; eax - ᫮ +; edi - ப +; len - +;output: +align 4 +proc convert_int_to_str, len:dword +pushad + mov esi,[len] + add esi,edi + dec esi + bt eax,31 + jae @f + ;᫨ ᫮ ⥫쭮 + neg eax + mov byte[edi],'-' + inc edi + @@: + call .str +popad + ret +endp + +align 4 +.str: + mov ecx,10 + cmp eax,ecx + jb @f + xor edx,edx + div ecx + push edx + ;dec edi ;ᬥ饭 室 ப + call .str + pop eax + @@: + cmp edi,esi + jge @f + or al,0x30 + stosb + mov byte[edi],0 ; ப ⠢ 0, - 뫠 + @@: + ret + +; 䠩 +align 4 +OpenDialog_data: +.type dd 0 ;0 - , 1 - ࠭, 2 - ४ +.procinfo dd procinfo ;+4 +.com_area_name dd communication_area_name ;+8 +.com_area dd 0 ;+12 +.opendir_path dd plugin_path ;+16 +.dir_default_path dd default_dir ;+20 +.start_path dd file_name ;+24 䠩 +.draw_window dd draw_window ;+28 +.status dd 0 ;+32 +.openfile_path dd openfile_path ;+36 뢠 䠩 +.filename_area dd filename_area ;+40 +.filter_area dd Filter +.x: +.x_size dw 420 ;+48 ; Window X size +.x_start dw 10 ;+50 ; Window X position +.y: +.y_size dw 320 ;+52 ; Window y size +.y_start dw 10 ;+54 ; Window Y position + +default_dir db '/rd/1',0 + +communication_area_name: + db 'FFFFFFFF_open_dialog',0 +open_dialog_name: + db 'opendial',0 +communication_area_default_path: + db '/rd/1/File managers/',0 + +Filter: +dd Filter.end - Filter ;.1 +.1: +db 'PNG',0 +db 'JPG',0 +db 'JPEG',0 +db 'BMP',0 +db 'GIF',0 +.end: +db 0 + +txt_space db ' ',0 + +if lang eq ru + txt_err_save_img_file db ' ࠭ *.png 䠩.',0 + txt_about db '" ணࠬ',13,10,\ + ' ணࠬ ᤥ ८ࠧ ࠦ.',13,10,\ + '᫥ 䠩 ࠦ 㦭 㪠 4 窨,',13,10,\ + ' ⠭ 㣫 ८ࠧ ࠦ." -tI',0 + txt_pref db ' ',0,' ',0,' ',0,' ',0 ;⠢: , , + txt_f_size db ': ' +else + txt_err_save_img_file db 'Can',39,'t save *.png file.',0 + txt_about db '"About',13,10,\ + 'This program is designed to convert images.',13,10,\ + 'After opening the image file, you need to specify 4 points',13,10,\ + 'that will become the corners of the converted image." -tI',0 + txt_pref db ' b ',0,' Kb',0,' Mb',0,' Gb',0 ;⠢: , , + txt_f_size db 'Size: ' +end if +.size: rb 16 + + +system_dir_0 db '/sys/lib/' +lib_name_0 db 'proc_lib.obj',0 +system_dir_1 db '/sys/lib/' +lib_name_1 db 'libimg.obj',0 +system_dir_2 db '/sys/lib/' +lib_name_2 db 'buf2d.obj',0 +system_dir_3 db '/sys/lib/' +lib_name_3 db 'tinygl.obj',0 + +align 4 +head_f_i: +if lang eq ru +head_f_l db '"⥬ 訡',0 +err_message_found_lib_0 db ' ⥪ ',39,'proc_lib.obj',39,'" -tE',0 +err_message_import_0 db '訡 ⥪ ',39,'proc_lib.obj',39,'" -tE',0 +err_message_found_lib_1 db ' ⥪ ',39,'libimg.obj',39,'" -tE',0 +err_message_import_1 db '訡 ⥪ ',39,'libimg.obj',39,'" -tE',0 +err_msg_found_lib_2 db ' ⥪ ',39,'buf2d.obj',39,'" -tE',0 +err_msg_import_2 db '訡 ⥪ ',39,'buf2d',39,'" -tE',0 +err_msg_found_lib_3 db ' ⥪ ',39,'tinygl.obj',39,'" -tE',0 +err_msg_import_3 db '訡 ⥪ ',39,'tinygl',39,'" -tE',0 +else +head_f_l db '"System error',0 +err_message_found_lib_0 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,'" -tE',0 +err_message_import_0 db 'Error on load import library ',39,'proc_lib.obj',39,'" -tE',0 +err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,'" -tE',0 +err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0 +err_msg_found_lib_2 db 'Sorry I cannot found library ',39,'buf2d.obj',39,'" -tE',0 +err_msg_import_2 db 'Error on load import library ',39,'buf2d',39,'" -tE',0 +err_msg_found_lib_3 db 'Sorry I cannot found library ',39,'tinygl.obj',39,'" -tE',0 +err_msg_import_3 db 'Error on load import library ',39,'tinygl',39,'" -tE',0 +end if + +align 4 +l_libs_start: + lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\ + err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i + lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\ + err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i + lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\ + err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i + lib_3 l_libs lib_name_3, sys_path, library_path, system_dir_3,\ + err_msg_found_lib_3,head_f_l,import_lib_tinygl,err_msg_import_3,head_f_i +l_libs_end: + +align 4 +import_libimg: + dd alib_init1 + img_is_img dd aimg_is_img + img_info dd aimg_info + img_from_file dd aimg_from_file + img_to_file dd aimg_to_file + img_from_rgb dd aimg_from_rgb + img_to_rgb dd aimg_to_rgb + img_to_rgb2 dd aimg_to_rgb2 + img_decode dd aimg_decode + img_encode dd aimg_encode + img_create dd aimg_create + img_destroy dd aimg_destroy + img_destroy_layer dd aimg_destroy_layer + img_count dd aimg_count + img_lock_bits dd aimg_lock_bits + img_unlock_bits dd aimg_unlock_bits + img_flip dd aimg_flip + img_flip_layer dd aimg_flip_layer + img_rotate dd aimg_rotate + img_rotate_layer dd aimg_rotate_layer + img_draw dd aimg_draw + + dd 0,0 + alib_init1 db 'lib_init',0 + aimg_is_img db 'img_is_img',0 ;। , ⥪ ᤥ ࠦ + aimg_info db 'img_info',0 + aimg_from_file db 'img_from_file',0 + aimg_to_file db 'img_to_file',0 + aimg_from_rgb db 'img_from_rgb',0 + aimg_to_rgb db 'img_to_rgb',0 ;८ࠧ ࠦ RGB + aimg_to_rgb2 db 'img_to_rgb2',0 + aimg_decode db 'img_decode',0 ;⮬᪨ । ଠ ᪨ + aimg_encode db 'img_encode',0 + aimg_create db 'img_create',0 + aimg_destroy db 'img_destroy',0 + aimg_destroy_layer db 'img_destroy_layer',0 + aimg_count db 'img_count',0 + aimg_lock_bits db 'img_lock_bits',0 + aimg_unlock_bits db 'img_unlock_bits',0 + aimg_flip db 'img_flip',0 + aimg_flip_layer db 'img_flip_layer',0 + aimg_rotate db 'img_rotate',0 + aimg_rotate_layer db 'img_rotate_layer',0 + aimg_draw db 'img_draw',0 + +align 4 +proclib_import: ;ᠭ ᯮ㥬 㭪権 + OpenDialog_Init dd aOpenDialog_Init + OpenDialog_Start dd aOpenDialog_Start + OpenDialog_Set_file_name dd aOpenDialog_Set_file_name + OpenDialog_Set_file_ext dd aOpenDialog_Set_file_ext +dd 0,0 + aOpenDialog_Init db 'OpenDialog_init',0 + aOpenDialog_Start db 'OpenDialog_start',0 + aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0 + aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0 + +align 4 +import_buf2d: + init dd sz_init + buf2d_create dd sz_buf2d_create + buf2d_create_f_img dd sz_buf2d_create_f_img + buf2d_clear dd sz_buf2d_clear + buf2d_draw dd sz_buf2d_draw + buf2d_delete dd sz_buf2d_delete + buf2d_resize dd sz_buf2d_resize + buf2d_line dd sz_buf2d_line + buf2d_rect_by_size dd sz_buf2d_rect_by_size + buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size + buf2d_circle dd sz_buf2d_circle + buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2 + buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2 + buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8 + buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32 + buf2d_bit_blt dd sz_buf2d_bit_blt + buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp + buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha + buf2d_curve_bezier dd sz_buf2d_curve_bezier + buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix + buf2d_draw_text dd sz_buf2d_draw_text + buf2d_crop_color dd sz_buf2d_crop_color + buf2d_offset_h dd sz_buf2d_offset_h + buf2d_flood_fill dd sz_buf2d_flood_fill + buf2d_set_pixel dd sz_buf2d_set_pixel + buf2d_get_pixel dd sz_buf2d_get_pixel + dd 0,0 + sz_init db 'lib_init',0 + sz_buf2d_create db 'buf2d_create',0 + sz_buf2d_create_f_img db 'buf2d_create_f_img',0 + sz_buf2d_clear db 'buf2d_clear',0 + sz_buf2d_draw db 'buf2d_draw',0 + sz_buf2d_delete db 'buf2d_delete',0 + sz_buf2d_resize db 'buf2d_resize',0 + sz_buf2d_line db 'buf2d_line',0 + sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 + sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 + sz_buf2d_circle db 'buf2d_circle',0 + sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 + sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 + sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0 + sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 + sz_buf2d_bit_blt db 'buf2d_bit_blt',0 + sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0 + sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0 + sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0 + sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0 + sz_buf2d_draw_text db 'buf2d_draw_text',0 + sz_buf2d_crop_color db 'buf2d_crop_color',0 + sz_buf2d_offset_h db 'buf2d_offset_h',0 + sz_buf2d_flood_fill db 'buf2d_flood_fill',0 + sz_buf2d_set_pixel db 'buf2d_set_pixel',0 + sz_buf2d_get_pixel db 'buf2d_get_pixel',0 + +align 4 +import_lib_tinygl: + +macro E_LIB n +{ + n dd sz_#n +} +include '../../../programs/develop/libraries/TinyGL/asm_fork/export.inc' + dd 0,0 +macro E_LIB n +{ + sz_#n db `n,0 +} +include '../../../programs/develop/libraries/TinyGL/asm_fork/export.inc' + +align 4 +buf_0: dd 0 +.l: dw 5 ;+4 left +.t: dw 35 ;+6 top +.w: dd 6*64 ;+8 w +.h: dd 7*64 ;+12 h +.color: dd 0xffffff ;+16 color + db 24 ;+20 bit in pixel + +align 4 +buf_font: + dd 0 ;㪠⥫ ࠦ + dd 0 ;+4 left,top +.w: dd 0 +.h: dd 0,0,24 + +align 4 +buf_cop: ; ஢ ⥪ + dd 0 +.l: dw 0 ;+4 left +.t: dw 0 ;+6 top +.w: dd 0 +.h: dd 0,0,24 + +;室 ࠦ +align 4 +buf_i0: dd 0,0 +.w: dd 0 +.h: dd 0 +.color: dd 0,24 + +;८ࠧ ࠦ +align 4 +buf_ogl: dd 0,0 +.w: dd 0 +.h: dd 0 +.color: dd 0,24 + +align 16 +i_end: +ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext +;sizeof.TinyGLContext = 28 +TexObj dd 0 ;ᨢ 㪠⥫ ⥪ ( 砥 1 .) +nav_x_min dd 0 ;. . x 樨 +nav_y_min dd 0 ;. . y 樨 +nav_x_max dd 0 ;. . x +nav_y_max dd 0 ;. . y +nav_x dd 0 ;⥪. . x 樨 +nav_y dd 0 ;⥪. . y 樨 +nav_sx dd 0 ;஫ x +nav_sy dd 0 ;஫ y +mouse_down_x dd ? +mouse_down_y dd ? +sel_act dd ? ;窠 ࠭ ।஢ +sel_pt rb 8*sizeof.point2d ;窨 롮 4- 㣫 +last_time dd 0 +procinfo process_information +sc system_colors +run_file_70 FileInfoBlock + rb 4096 +align 16 +stacktop: + sys_path rb 1024 + file_name: + rb 1024 ;4096 + library_path rb 1024 + plugin_path rb 4096 + openfile_path rb 4096 + filename_area rb 256 +mem: diff --git a/programs/media/img_transform/select_points.inc b/programs/media/img_transform/select_points.inc new file mode 100644 index 0000000000..2d0046caeb --- /dev/null +++ b/programs/media/img_transform/select_points.inc @@ -0,0 +1,357 @@ +; +; файл для работы с выделенными точками, +; по которым делается преобразование изображения +;[0-3] - рамка (исх. и.) +;[4] - средняя точка (исх. и.) +;[5-6] - рамка (вых. и.) +;[7] - средняя точка (вых. и.) +; + +struct point2d + x dd ? ;координата относит изображения + y dd ? + tx dd ? ;координата для текстуры + ty dd ? + captx rb 6 + capty rb 6 +ends + +;настройка точек при загрузке программы +;(точки не активны) +align 4 +points_init: + xor eax,eax + dec eax + mov ecx,8 + mov edi,sel_pt + @@: + mov [edi+point2d.x],eax + mov [edi+point2d.y],eax + add edi,sizeof.point2d + loop @b + ret + +;настройка точек при открытии изображения +;(точки ставятся по углам изображения) +align 4 +proc points_init_2 uses eax ecx edx edi, ot_x:dword + xor eax,eax + mov edi,sel_pt + mov edx,[ot_x] + mov [edi+point2d.x],edx ;1 + mov [edi+point2d.y],eax ;1 + add edi,sizeof.point2d + mov ecx,[buf_i0.w] + sub ecx,edx + mov [edi+point2d.x],ecx ;2 + mov [edi+point2d.y],eax ;2 + add edi,sizeof.point2d + mov [edi+point2d.x],ecx ;3 + mov ecx,[buf_i0.h] + mov [edi+point2d.y],ecx ;3 + add edi,sizeof.point2d + mov [edi+point2d.x],edx ;4 + mov [edi+point2d.y],ecx ;4 + call points_update_prop + ret +endp + +align 4 +proc points_update_prop uses eax ebx ecx edi esi + ;вычисление координат средней точки + mov edi,sel_pt + xor eax,eax + xor ebx,ebx + mov ecx,4 + @@: + add eax,[edi+point2d.x] + add ebx,[edi+point2d.y] + add edi,sizeof.point2d + loop @b + shr eax,2 + mov [edi+point2d.x],eax + shr ebx,2 + mov [edi+point2d.y],ebx + add edi,sizeof.point2d + + cmp byte[trans_a],0 ;проверяем алгоритм растягивания текстуры + je @f + ;на весь буфер + xor eax,eax + mov ebx,edi + mov edi,buf_i0 + mov [ebx+point2d.x],eax + mov [ebx+point2d.y],eax + add ebx,sizeof.point2d + mov eax,buf2d_w + mov [ebx+point2d.x],eax + mov ecx,buf2d_h + mov [ebx+point2d.y],ecx + add ebx,sizeof.point2d + shr eax,1 + mov [ebx+point2d.x],eax + shr ecx,1 + mov [ebx+point2d.y],ecx + jmp .end0 + @@: + ;на часть буфера + mov eax,[edi+point2d.x-5*sizeof.point2d] + add eax,[edi+point2d.x-2*sizeof.point2d] + shr eax,1 + mov [edi+point2d.x],eax + mov eax,[edi+point2d.x-4*sizeof.point2d] + add eax,[edi+point2d.x-3*sizeof.point2d] + shr eax,1 + mov [edi+point2d.x+sizeof.point2d],eax + + mov eax,[edi+point2d.y-5*sizeof.point2d] + add eax,[edi+point2d.y-4*sizeof.point2d] + shr eax,1 + mov [edi+point2d.y],eax + mov eax,[edi+point2d.y-3*sizeof.point2d] + add eax,[edi+point2d.y-2*sizeof.point2d] + shr eax,1 + mov [edi+point2d.y+sizeof.point2d],eax + + lea esi,[edi-sizeof.point2d] + add edi,2*sizeof.point2d + movsd ;copy coord x + movsd ;copy coord y + .end0: + + mov edi,buf_i0 + mov ebx,sel_pt + mov ecx,8 + finit + .cycle0: + fild dword[ebx+point2d.x] + fidiv buf2d_w + fst dword[ebx+point2d.tx] + + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + m2m dword[ebx+point2d.captx],dword[Data_String] + mov al,byte[Data_String+4] + mov byte[ebx+point2d.captx+4],al + + fild dword[ebx+point2d.y] + fidiv buf2d_h + fst dword[ebx+point2d.ty] + + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + m2m dword[ebx+point2d.capty],dword[Data_String] + mov al,byte[Data_String+4] + mov byte[ebx+point2d.capty+4],al + + add ebx,sizeof.point2d + loop .cycle0 + + call draw_transf_texture + ret +endp + +;рисование выбранных точек +align 4 +proc points_draw +locals + PervX dd 0 ;pervios point coord X + PervY dd 0 ;pervios point coord Y + GrafX dd ? ;active point coord X + GrafY dd ? ;active point coord Y +endl + mov edi,buf_ogl + cmp buf2d_data,0 + je .endf + + xor ecx,ecx + mov edi,sel_pt + mov dword[txt_buf],'0' + + cmp byte[view_b],1 + je .cycle0end + ;берем координаты последней точки + mov eax,[edi+3*sizeof.point2d+point2d.x] + add eax,[nav_x] + mov [PervX],eax + mov ebx,[edi+3*sizeof.point2d+point2d.y] + add ebx,[nav_y] + mov [PervY],ebx +align 4 + .cycle0: + cmp dword[edi+point2d.x],-1 + je .end0 + mov eax,[edi+point2d.x] + add eax,[nav_x] + mov [GrafX],eax + sub eax,3 + mov ebx,[edi+point2d.y] + add ebx,[nav_y] + mov [GrafY],ebx + sub ebx,3 + cmp ecx,[sel_act] + je @f + stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xffff00 + @@: + dec eax + dec ebx + stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 + call point_draw_info + ;рисование линии + stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], 0x808000 + mov eax,[GrafX] + mov [PervX],eax + mov eax,[GrafY] + mov [PervY],eax + .end0: + add edi,sizeof.point2d + inc ecx + cmp ecx,4 + jl .cycle0 + jmp .cycle1end + .cycle0end: + add edi,5*sizeof.point2d +align 4 + .cycle1: + cmp dword[edi+point2d.x],-1 + je .end1 + mov eax,[GrafX] + mov [PervX],eax + mov eax,[GrafY] + mov [PervY],eax + mov eax,[edi+point2d.x] + add eax,[nav_x] + mov [GrafX],eax + sub eax,3 + mov ebx,[edi+point2d.y] + add ebx,[nav_y] + mov [GrafY],ebx + sub ebx,3 + stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xffff00 + dec eax + dec ebx + stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 + call point_draw_info + .end1: + add edi,sizeof.point2d + inc ecx + cmp ecx,2 + jl .cycle1 + mov eax,[GrafX] + sub eax,[PervX] + mov [GrafX],eax + mov eax,[GrafY] + sub eax,[PervY] + mov [GrafY],eax + stdcall [buf2d_rect_by_size], buf_0, [PervX],[PervY], [GrafX],[GrafY], 0x808000 + .cycle1end: + ;средняя точка + mov eax,[edi+point2d.x] + add eax,[nav_x] + sub eax,3 + mov ebx,[edi+point2d.y] + add ebx,[nav_y] + sub ebx,3 + stdcall [buf2d_filled_rect_by_size], buf_0, eax,ebx, 5,5, 0xff0000 + dec eax + dec ebx + stdcall [buf2d_rect_by_size], buf_0, eax,ebx, 7,7, 0x808000 + add ebx,9 + inc byte[txt_buf] + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0 + .endf: + ret +endp + +;input: +; eax - coord x +; ebx - coord y +; edi - указатель на структуру point2d +align 4 +point_draw_info: + ;вывод текста + add ebx,9 + inc byte[txt_buf] + inc eax + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff + sub eax,2 + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff + inc eax + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff + ;dec ebx + sub ebx,2 + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0xffffff + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,txt_buf,eax,ebx,0 + add ebx,9 + lea edx,[edi+point2d.captx] + inc eax + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + sub eax,2 + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + inc eax + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + ;dec ebx + sub ebx,2 + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0 + add ebx,9 + lea edx,[edi+point2d.capty] + inc eax + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + sub eax,2 + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + inc eax + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + ;dec ebx + sub ebx,2 + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0xffffff + inc ebx + stdcall [buf2d_draw_text], buf_0, buf_font,edx,eax,ebx,0 + ret + +;рисование преобразованной текстуры +align 4 +draw_transf_texture: + cmp dword[buf_ogl],0 + je .endf + stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины + stdcall [glBegin],GL_TRIANGLES + + stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 + stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 + stdcall [glTexCoord2f], dword[sel_pt+point2d.tx], dword[sel_pt+point2d.ty] ;1 + stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;6 + stdcall [glTexCoord2f], dword[sel_pt+sizeof.point2d+point2d.tx], dword[sel_pt+sizeof.point2d+point2d.ty] ;2 + stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;7|6 + + stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 + stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 + stdcall [glTexCoord2f], dword[sel_pt+sizeof.point2d+point2d.tx], dword[sel_pt+sizeof.point2d+point2d.ty] ;2 + stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;7|6 + stdcall [glTexCoord2f], dword[sel_pt+2*sizeof.point2d+point2d.tx], dword[sel_pt+2*sizeof.point2d+point2d.ty] ;3 + stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;7 + + stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 + stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 + stdcall [glTexCoord2f], dword[sel_pt+2*sizeof.point2d+point2d.tx], dword[sel_pt+2*sizeof.point2d+point2d.ty] ;3 + stdcall [glVertex3f], dword[sel_pt+6*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;7 + stdcall [glTexCoord2f], dword[sel_pt+3*sizeof.point2d+point2d.tx], dword[sel_pt+3*sizeof.point2d+point2d.ty] ;4 + stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;6|7 + + stdcall [glTexCoord2f], dword[sel_pt+4*sizeof.point2d+point2d.tx], dword[sel_pt+4*sizeof.point2d+point2d.ty] ;5 + stdcall [glVertex3f], dword[sel_pt+7*sizeof.point2d+point2d.tx], dword[sel_pt+7*sizeof.point2d+point2d.ty], 0.1 ;8 + stdcall [glTexCoord2f], dword[sel_pt+3*sizeof.point2d+point2d.tx], dword[sel_pt+3*sizeof.point2d+point2d.ty] ;4 + stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+6*sizeof.point2d+point2d.ty], 0.1 ;6|7 + stdcall [glTexCoord2f], dword[sel_pt+point2d.tx], dword[sel_pt+point2d.ty] ;1 + stdcall [glVertex3f], dword[sel_pt+5*sizeof.point2d+point2d.tx], dword[sel_pt+5*sizeof.point2d+point2d.ty], 0.1 ;6 + + stdcall [glEnd] + .endf: + ret diff --git a/programs/media/img_transform/toolbar.png b/programs/media/img_transform/toolbar.png new file mode 100644 index 0000000000..27da109bac Binary files /dev/null and b/programs/media/img_transform/toolbar.png differ