new macros 'include_image_file',

't_edit' include image files in program

git-svn-id: svn://kolibrios.org@6906 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2017-05-26 10:20:10 +00:00
parent 17b4bf3701
commit 0715c316ef
5 changed files with 125 additions and 78 deletions

View File

@ -16,9 +16,6 @@ img_files = {
{"CONFIG.INC", PROGS .. "/config.inc"},
{"STRUCT.INC", PROGS .. "/struct.inc"},
{"TOOLBAR.PNG", PROGS .. "/cmm/txtread/toolbar.png"},
{"DEVELOP/TE_ICON.PNG", PROGS .. "/other/t_edit/te_icon.png"},
{"DEVELOP/TL_NOD_16.PNG", PROGS .. "/other/t_edit/tl_nod_16.png"},
{"DEVELOP/TL_SYS_16.PNG", PROGS .. "/media/log_el/trunk/tl_sys_16.png"},
{"DEVELOP/T_EDIT.INI", PROGS .. "/other/t_edit/t_edit.ini"},
{"FB2READ", "common/fb2read"},
{"File Managers/Z_ICONS.PNG", PROGS .. "/fs/opendial/z_icons.png"},

View File

@ -1,6 +1,7 @@
;
; Œ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨© ç१ ä㭪樨 ¡¨¡«¨®â¥ª¨ libimg.
; „¥©áâ¢¨ï ª®â®àë¥ ¤¥« ¥â ¬ ªà®á load_image_file:
; Œ ªà®áë ¤«ï ¤¥ª®¤¨à®¢ ­¨ï ¨§®¡à ¦¥­¨© ç१ ä㭪樨 ¡¨¡«¨®â¥ª¨ libimg.
;
; (1) ¬ ªà®á load_image_file:
;
; <EFBFBD>஢¥àï¥â à §¬¥à ¯®«ã祭­®£® ä ©«  á ¨§®¡à ¦¥­¨¥¬.
; ‚뤥«ï¥â ¯®¤ ­¥£® ¯ ¬ïâì ¨ § £à㦠¥â â㤠 ä ©«.
@ -13,6 +14,15 @@
; ¨á¯®«ì§ãî饩 ¯à®£à ¬¬¥ ¤®«¦­  ¡ëâì ¯®¤ª«î祭  ¡¨¡«¨®â¥ª  libimg,
; ®¡ê¥­  ¯¥à¥¬¥­­ ï file_name à §¬¥à®¬ ®ª®«® 4096 ¡ ©â,
;   â ª¦¥ áâàãªâãà  run_file_70 ⨯  FileInfoBlock.
;
; (2) ¬ ªà®á include_image_file:
;
; ‚­¥¤àï¥â ¨§®¡à ¦¥­¨¥ ¢ ä ©« ¯à®£à ¬¬ë.
; Ž¯à¥¤¥«ï¥â à §¬¥à ¯ ¬ï⨠­¥®¡å®¤¨¬®© ¤«ï à á¯ ª®¢ª¨ ¨§®¡à ¦¥­¨ï.
; ‚뤥«ï¥â ¯ ¬ïâì, ¨ à á¯ ª®¢ë¢ ¥â ¨§®¡à ¦¥­¨¥ ¨§ ä®à¬ â®¢ jpg, png, ...
; ¢ ä®à¬ â rgb ª®â®àë© ¬®¦­® ¢ë¢®¤¨âì ­  íªà ­ ç¥à¥§ á¨áâ. äã­ªæ¨î.
; <EFBFBD>ਠ­¥®¡å®¤¨¬®á⨠¬®¦­® â ª¦¥ ¯®«ãç¨âì à §¬¥àë ¢­¥¤à¥­­®£® ¨§®¡à ¦¥­¨ï ¤«ï
; ¨å ¤ «ì­¥©è¥£® ¨á¯®«ì§®¢ ­¨ï ¢ ¯à®£à ¬¬¥.
; ¯®¤ª«î祭¨¥ ­¥ª®â®àëå ­¥®¡å®¤¨¬ëå ä ©«®¢:
include 'dll.inc'
@ -45,84 +55,130 @@ local .err_open
local .end_open
if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
local .path_str
jmp @f
.path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
db 0
@@:
;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
copy_path .path_str,[32],file_name,0
local .path_str
jmp @f
.path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
db 0
@@:
;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
copy_path .path_str,[32],file_name,0
else
copy_path path,[32],file_name,0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
copy_path path,[32],file_name,0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
end if
mov dword[buf],0
mov dword[buf],0
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], file_name
mcall SF_FILE,run_file_70
or eax,eax
jnz .err_open
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], file_name
mcall SF_FILE,run_file_70
or eax,eax
jnz .err_open
mov ecx,dword[open_b+32] ;+32 qword: à §¬¥à ä ©«  ¢ ¡ ©â å
stdcall mem.Alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
mov [buf],eax
mov [run_file_70.Function], SSF_READ_FILE
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov [run_file_70.Count], ecx
mov [run_file_70.Buffer], eax
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
mcall SF_FILE,run_file_70 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
mov ecx,dword[open_b+32] ;+32 qword: à §¬¥à ä ©«  ¢ ¡ ©â å
stdcall mem.Alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
mov [buf],eax
mov [run_file_70.Function], SSF_READ_FILE
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov [run_file_70.Count], ecx
mov [run_file_70.Buffer], eax
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
mcall SF_FILE,run_file_70 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
test eax,eax
jnz .err_open
cmp ebx,0xffffffff
je .end_open
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¨è¥¬ ¥£® ¯ à ¬¥âàë
stdcall [img_decode], [buf],ebx,0
mov ebx,eax
;®¯à¥¤¥«ï¥¬ à §¬¥à ¤¥ª®¤¨à®¢ ­­®£® ¨§®¡à ¦¥­¨ï
mov ecx,[eax+4] ;+4 = image width
cmp ebx,0xffffffff
je .end_open
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¨è¥¬ ¥£® ¯ à ¬¥âàë
stdcall [img_decode], [buf],ebx,0
mov ebx,eax
;®¯à¥¤¥«ï¥¬ à §¬¥à ¤¥ª®¤¨à®¢ ­­®£® ¨§®¡à ¦¥­¨ï
mov ecx,[eax+4] ;+4 = image width
if img_w eq
else
mov dword[img_w],ecx
mov dword[img_w],ecx
end if
if img_h eq
imul ecx,[eax+8] ;+8 = image height
imul ecx,[eax+8] ;+8 = image height
else
mov eax,[eax+8] ;+8 = image height
mov dword[img_h],eax
imul ecx,eax
mov eax,[eax+8] ;+8 = image height
mov dword[img_h],eax
imul ecx,eax
end if
if bytes_p_p eq
imul ecx,3 ;need for r,g,b
imul ecx,3 ;need for r,g,b
else
imul ecx,bytes_p_p
imul ecx,bytes_p_p
end if
stdcall mem.ReAlloc,[buf],ecx ;¨§¬¥­ï¥¬ à §¬¥à ¤«ï ¡ãä¥à 
mov [buf],eax
stdcall [img_to_rgb2], ebx,[buf] ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall [img_destroy], ebx ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à á ¯ à ¬¥âà ¬¨ ¨§®¡à ¦¥­¨ï
stdcall mem.ReAlloc,[buf],ecx ;¨§¬¥­ï¥¬ à §¬¥à ¤«ï ¡ãä¥à 
mov [buf],eax
stdcall [img_to_rgb2], ebx,[buf] ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall [img_destroy], ebx ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à á ¯ à ¬¥âà ¬¨ ¨§®¡à ¦¥­¨ï
jmp .end_open
.err_open:
add al,'0'
mov byte[txt_err_img_file.n],al
.err_open:
add al,'0'
mov byte[txt_err_img_file.n],al
if path eqtype ''
mov eax,dword[.path_str]
mov dword[txt_err_img_file.f],eax
mov eax,dword[.path_str+4]
mov eax,dword[.path_str]
mov dword[txt_err_img_file.f],eax
mov eax,dword[.path_str+4]
else
mov eax,dword[path]
mov dword[txt_err_img_file.f],eax
mov eax,dword[path+4]
mov eax,dword[path]
mov dword[txt_err_img_file.f],eax
mov eax,dword[path+4]
end if
mov dword[txt_err_img_file.f+4],eax
mov byte[txt_err_img_file.f+7],0
notify_window_run txt_err_img_file
.end_open:
mov dword[txt_err_img_file.f+4],eax
mov byte[txt_err_img_file.f+7],0
notify_window_run txt_err_img_file
.end_open:
}
; path - ¨¬ï ¢ª«îç ¥¬®£® ä ©« 
; buf - ¯¥à¥¬¥­­ ï ªã¤  ¡ã¤¥â § ¯¨á ­ 㪠§ â¥«ì ­  ¨§®¡à ¦¥­¨¥ ¢ ä®à¬ â¥ rgb
; img_w, img_h - ¯¥à¥¬¥­­ë¥ ªã¤  ¡ã¤ãâ § ¯¨á ­ë à §¬¥àë ¨§®¡à ¦¥­¨ï,
; ­¥ ®¡ï§ â¥«ì­ë¥ ¯ à ¬¥âàë
; bytes_p_p - ᪮«ìª® ¡ ©â ¯ ¬ï⨠¡à âì ­  ¯¨ªá¥«ì, ­¥ ®¡ï§ â¥«ì­ë© ¯ à ¬¥âà
; ¥á«¨ ­¥ 㪠§ ­ ¡¥à¥âáï 3. Œ¨­¨¬ «ì­®¥ §­ ç¥­¨¥ ¤®«¦­® ¡ëâì ­¥ ¬¥­ìè¥ 3.
macro include_image_file path, buf, img_w, img_h, bytes_p_p
{
local .beg_file
local .end_file
jmp .end_file
align 4
.beg_file:
file path
.end_file:
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¨è¥¬ ¥£® ¯ à ¬¥âàë
stdcall [img_decode], .beg_file,.end_file-.beg_file,0
mov ebx,eax
;®¯à¥¤¥«ï¥¬ à §¬¥à ¤¥ª®¤¨à®¢ ­­®£® ¨§®¡à ¦¥­¨ï
mov ecx,[eax+4] ;+4 = image width
if img_w eq
else
mov dword[img_w],ecx
end if
if img_h eq
imul ecx,[eax+8] ;+8 = image height
else
mov eax,[eax+8] ;+8 = image height
mov dword[img_h],eax
imul ecx,eax
end if
if bytes_p_p eq
imul ecx,3 ;need for r,g,b
else
imul ecx,bytes_p_p
end if
stdcall mem.Alloc,ecx ;¨§¬¥­ï¥¬ à §¬¥à ¤«ï ¡ãä¥à 
mov [buf],eax
stdcall [img_to_rgb2], ebx,[buf] ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall [img_destroy], ebx ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à á ¯ à ¬¥âà ¬¨ ¨§®¡à ¦¥­¨ï
}

View File

@ -1,8 +1,5 @@
if not exist bin mkdir bin
if not exist bin\tl_sys_16.png @copy ..\..\media\log_el\trunk\tl_sys_16.png bin\tl_sys_16.png
if not exist bin\tl_nod_16.png @copy tl_nod_16.png bin\tl_nod_16.png
if not exist bin\msgbox.obj @copy msgbox.obj bin\msgbox.obj
if not exist bin\te_icon.png @copy te_icon.png bin\te_icon.png
if not exist bin\info mkdir bin\info
if not exist bin\box_lib.obj @fasm.exe -m 16384 ..\..\develop\libraries\box_lib\trunk\box_lib.asm bin\box_lib.obj

View File

@ -1,8 +1,5 @@
if not exist bin mkdir bin
if not exist bin\tl_sys_16.png @copy ..\..\media\log_el\trunk\tl_sys_16.png bin\tl_sys_16.png
if not exist bin\tl_nod_16.png @copy tl_nod_16.png bin\tl_nod_16.png
if not exist bin\msgbox.obj @copy msgbox.obj bin\msgbox.obj
if not exist bin\te_icon.png @copy te_icon.png bin\te_icon.png
if not exist bin\info mkdir bin\info
if not exist bin\box_lib.obj @fasm.exe -m 16384 ..\..\develop\libraries\box_lib\trunk\box_lib.asm bin\box_lib.obj

View File

@ -1,7 +1,7 @@
;Ž£à®¬­ ï ¡« £®¤ à­®áâì ¢á¥¬, ªâ® ¯®¬®£ «: ª®¤®¬/ᮢ¥â®¬/¤¨§ ©­®¬ ...
use32
org 0x0
org 0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 1, start, i_end, mem, stacktop, file_name, sys_path
@ -144,18 +144,18 @@ mov ebp,lib0
stdcall [ksubmenu_add], [main_menu], eax
; init toolbar file
load_image_file 'te_icon.png', bmp_icon,,,6 ;6 ¤«ï á¥àëå ª­®¯®ª
include_image_file 'te_icon.png', bmp_icon,,,6 ;6 ¤«ï á¥àëå ª­®¯®ª
mov eax,[bmp_icon]
add eax,TOOLBAR_ICONS_SIZE
stdcall img_to_gray, [bmp_icon],eax,(TOOLBAR_ICONS_SIZE)/3
;---------------------------------------------------------------------
; ç¨â ¥¬ ä ©« á ªãàá®à ¬¨ ¨ «¨­¨ï¬¨
load_image_file 'tl_sys_16.png', icon_tl_sys
; ¢­¥¤à塞 ä ©« á ªãàá®à ¬¨ ¨ «¨­¨ï¬¨
include_image_file '..\..\media\log_el\trunk\tl_sys_16.png', icon_tl_sys
mov eax,dword[icon_tl_sys]
mov dword[tree1.data_img_sys],eax
;---------------------------------------------------------------------
; ç¨â ¥¬ ä ©« á ¨ª®­ª ¬¨ 㧫®¢
load_image_file 'tl_nod_16.png', icon_tl_sys
; ¢­¥¤à塞 ä ©« á ¨ª®­ª ¬¨ 㧫®¢
include_image_file 'tl_nod_16.png', icon_tl_sys
mov eax,dword[icon_tl_sys]
mov dword[tree1.data_img],eax
;------------------------------------------------------------------------------