add new library 'exif.obj'

git-svn-id: svn://kolibrios.org@4994 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2014-07-15 14:57:31 +00:00
parent e72c474426
commit d7cac76dad
5 changed files with 839 additions and 0 deletions

View File

@ -0,0 +1,8 @@
if not exist bin mkdir bin
@fasm.exe -m 16384 viev_exif.asm bin\viev_exif.kex
@kpack bin\viev_exif.kex
if not exist bin\toolbar.png @copy toolbar.png bin\toolbar.png
if not exist bin\font8x9.bmp @copy ..\..\..\..\fs\kfar\trunk\font8x9.bmp bin\font8x9.bmp
@fasm.exe -m 16384 ..\trunk\exif.asm bin\exif.obj
@kpack bin\exif.obj
pause

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,575 @@
use32
org 0x0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 0x1
dd start
dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
dd mem
dd stacktop
dd 0
dd sys_path
include '../../../../macros.inc'
include '../../../../proc32.inc'
include '../../../../develop/libraries/box_lib/load_lib.mac'
include '../../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../../dll.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db '<27>à®á¬®âà ¨­ä®à¬ æ¨¨ Exif 15.07.14',0 ;¯®¤¯¨áì ®ª­ 
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
run_file_70 FileInfoBlock
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
fn_toolbar db 'toolbar.png',0
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*5
image_data_toolbar dd 0
IMAGE_FILE1_SIZE equ 128*144*3+54 ;à §¬¥à ä ©«  á ¨§®¡à ¦¥­¨¥¬
memory_file_size dd 512*1024 ;à §¬¥à ¯ ¬ï⨠¤«ï ®âªàëâ¨ï ä ©«®¢ (¢ ­ ç «¥ 512 Kb, ­® ¬®¦¥â 㢥«¨ç¨¢ âáï ¯à¨ ­¥®¡å®¤¨¬®áâ¨)
macro load_image_file path,buf,size { ;¬ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨©
;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
jmp @f
local .path_str
.path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
db 0
@@:
;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
copy_path .path_str,[32],file_name,0x0
else
copy_path path,[32],file_name,0x0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
end if
stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
mov [buf],eax
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov [run_file_70.Count], dword size
m2m [run_file_70.Buffer], [buf]
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je @f
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_decode], dword[buf],ebx,0
mov dword[image_data],eax
;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_destroy], dword[image_data]
@@:
}
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 -1 ;exit not correct
@@:
mcall 48,3,sc,sizeof.system_colors
mcall 40,0xC0000027
stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à 
load_image_file 'font8x9.bmp', image_data_toolbar,IMAGE_FILE1_SIZE
stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;ᮧ¤ ¥¬ ¡ãä¥à
stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
stdcall [buf2d_conv_24_to_8], buf_1,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8 ¡¨â
stdcall [buf2d_convert_text_matrix], buf_1
load_image_file fn_toolbar, image_data_toolbar,IMAGE_TOOLBAR_SIZE
stdcall mem.Alloc,[memory_file_size]
mov dword[open_file],eax
call but_new_file
align 4
red_win:
call draw_window
align 4
still:
mcall 10
cmp al,1
jz red_win
cmp al,2
jz key
cmp al,3
jz button
cmp al,6 ;¬ëèì
jne @f
jmp mouse
@@:
jmp still
align 4
draw_window:
pushad
mcall 12,1
; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
xor eax,eax
mov ebx,(20 shl 16)+480
mov ecx,(20 shl 16)+410
mov edx,[sc.work]
or edx,(3 shl 24)+0x10000000+0x20000000
mov edi,caption
int 0x40
; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
mov eax,8
mov ebx,(5 shl 16)+20
mov ecx,(5 shl 16)+20
mov edx,3
mov esi,[sc.work_button]
int 0x40
mov ebx,(30 shl 16)+20
mov edx,4
int 0x40
mov ebx,(55 shl 16)+20
mov edx,5
int 0x40
mov ebx,(85 shl 16)+20
mov edx,6
int 0x40
mov ebx,(110 shl 16)+20
mov edx,7
int 0x40
; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
mov eax,7
mov ebx,[image_data_toolbar]
mov ecx,(16 shl 16)+16
mov edx,(7 shl 16)+7 ;icon new
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon open
int 0x40
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) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
; *** à¨á®¢ ­¨¥ ¡ãä¥à  ***
stdcall [buf2d_draw], buf_0
mcall 12,2
popad
ret
align 4
key:
mcall 2
jmp still
align 4
mouse:
jmp still
align 4
button:
mcall 17
cmp ah,3
jne @f
call but_new_file
@@:
cmp ah,4
jne @f
call but_open_file
@@:
cmp ah,5
jne @f
call but_save_file
@@:
cmp ah,6
jne @f
call but_1
@@:
cmp ah,7
jne @f
call but_2
@@:
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0
stdcall [buf2d_delete],buf_1 ;㤠«ï¥¬ ¡ãä¥à
stdcall mem.Free,[image_data_toolbar]
stdcall mem.Free,[open_file]
mcall -1
align 4
but_new_file:
mov dword[open_file_size],0
call draw_file
ret
align 4
open_file dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢
open_file_size dd 0 ;à §¬¥à ®âªàë⮣® ä ©«  (¤®«¦¥­ ¡ëâì ­¥ ¡®«ìè¥ memory_file_size)
align 4
but_open_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],0
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2
je .end_open_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 5
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov dword[run_file_70.Count], 0
m2m [run_file_70.Buffer], [open_file]
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp eax,0
jne .end_open_file
mov eax,[open_file]
mov ebx,dword[eax+32] ;dword[eax+32] - à §¬¥à ®âªà뢠¥¬®£® ä ©« 
mov dword[open_file_size],ebx ;ebx - à §¬¥à ®âªà뢠¥¬®£® ä ©« 
;memory_file_size - à §¬¥à ¢ë¤¥«¥­­®© ¯ ¬ï⨠¤«ï ä ©« 
cmp dword[memory_file_size],ebx
jge @f
;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
mov dword[memory_file_size],ebx
stdcall mem.ReAlloc, dword[open_file],ebx
@@:
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
m2m dword[run_file_70.Count], dword[open_file_size]
m2m dword[run_file_70.Buffer],dword[open_file]
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je .end_open_file
mov [open_file_size],ebx
;add ebx,dword[open_file]
;mov byte[ebx],0 ;­  á«ãç © ¥á«¨ à ­¥¥ ¡ë« ®âªàëâ ä ©« ¡®«ì襣® à §¬¥à  ç¨á⨬ ª®­¥æ ¡ãä¥à  á ä ©«®¬
stdcall [exif_get_app1], [open_file],h_app1
mcall 71,1,openfile_path
call draw_file
.end_open_file:
popad
ret
align 4
draw_file:
pushad
stdcall [buf2d_clear], buf_0, [buf_0.color]
cmp dword[open_file_size],0
je .open_file
mov eax,1
mov ebx,2
.cycle_0:
stdcall [exif_get_app1_tag], [h_app1],eax,txt_buf,80
stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,4,ebx,0xb0
inc eax
add ebx,10
cmp byte[txt_buf],0
jne .cycle_0
jmp @f
.open_file:
stdcall [buf2d_draw_text], buf_0, buf_1,txt_openfile,3,3,0xb000
@@:
stdcall [buf2d_draw], buf_0
popad
ret
align 4
but_save_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],1
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2
je .end_save_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 2
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov ebx, dword[open_file]
mov [run_file_70.Buffer], ebx
mov ebx,[open_file_size]
mov dword[run_file_70.Count], ebx ;à §¬¥à ä ©« 
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;á®å࠭塞 ä ©« ¨§®¡à ¦¥­¨ï
;cmp ebx,0xffffffff
;je .end_save_file
; ... á®®¡é¥­¨¥ ® ­¥ã¤ ç­®¬ á®åà ­¥­¨¨ ...
.end_save_file:
popad
ret
align 4
but_1:
stdcall [exif_get_app1_tag], [h_app1],1,txt_buf,80
notify_window_run txt_buf
ret
align 4
but_2:
stdcall [exif_get_app1_tag], [h_app1],2,txt_buf,80
notify_window_run txt_buf
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 'JPG',0
db 'JPEG',0
.end:
db 0
head_f_i:
head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
system_dir_0 db '/sys/lib/'
lib_name_0 db 'proc_lib.obj',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
system_dir_1 db '/sys/lib/'
lib_name_1 db 'libimg.obj',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
system_dir_2 db '/sys/lib/'
lib_name_2 db 'buf2d.obj',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
system_dir_3 db '/sys/lib/'
lib_name_3 db 'exif.obj',0
err_msg_found_lib_3 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'exif.obj',39,0
err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'exif',39,0
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_exif,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
dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',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_conv_24_to_8 dd sz_buf2d_conv_24_to_8
buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
buf2d_draw_text dd sz_buf2d_draw_text
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_conv_24_to_8 db 'buf2d_conv_24_to_8',0
sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
sz_buf2d_draw_text db 'buf2d_draw_text',0
align 4
import_exif: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
exif_get_app1 dd sz_des_encryption
exif_get_app1_tag dd sz_des_decryption
dd 0,0
sz_des_encryption db 'exif_get_app1',0
sz_des_decryption db 'exif_get_app1_tag',0
;exif_get_image_160_120
sc system_colors
align 16
procinfo process_information
align 4
buf_0: dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 5 ;+4 left
dw 31 ;+6 top
.w: dd 456 ;+8 w
.h: dd 350 ;+12 h
.color: dd 0xffffd0 ;+16 color
db 24 ;+20 bit in pixel
align 4
buf_1:
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 25 ;+4 left
dw 25 ;+6 top
dd 128 ;+8 w
dd 144 ;+12 h
dd 0 ;+16 color
db 24 ;+20 bit in pixel
h_app1 dd 0
txt_openfile db 'Žâªà®©â¥ ä ©« ¨§®¡à ¦¥­¨ï ¢ ä®à¬ â¥ *.jpg.',0
txt_buf rb 80
i_end:
rb 2048
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:

View File

@ -0,0 +1,3 @@
@fasm.exe -m 16384 exif.asm exif.obj
@kpack exif.obj
pause

View File

@ -0,0 +1,253 @@
format MS COFF
public EXPORTS
section '.flat' code readable align 16
include '../../../../macros.inc'
include '../../../../proc32.inc'
;---------
offs_m_or_i equ 8 ;ᬥ饭¨¥ ¯ à ¬¥âà  'MM' ¨«¨ 'II' (Motorola, Intel)
offs_tag_count equ 16 ;ᬥ饭¨¥ ª®«¨ç¥á⢠ ⥣®¢
offs_tag_0 equ 18 ;ᬥ饭¨¥ 0-£® ⥣ 
tag_size equ 12 ;à §¬¥à áâàãªâãàë ⥣ 
;ä®à¬ âë ¤ ­­ëå
tag_format_ui1b equ 1 ;unsigned integer 1 byte
tag_format_text equ 2 ;ascii string
tag_format_ui2b equ 3 ;unsigned integer 2 byte
tag_format_ui4b equ 4 ;unsigned integer 4 byte
tag_format_ui8b equ 5 ;unsigned integer 8 byte
tag_format_si1b equ 6 ;signed integer 1 byte
tag_format_undef equ 7 ;undefined
tag_format_si2b equ 8 ;signed integer 2 byte
tag_format_si4b equ 9 ;signed integer 4 byte
tag_format_si8b equ 10 ;signed integer 8 byte
tag_format_f4b equ 11 ;float 4 byte
tag_format_f8b equ 12 ;float 8 byte
align 4
txt_dp db ': ',0
;
align 4
exif_tag_numbers:
db 0x01,0x0e,'Image description',0
db 0x01,0x0f,'Manufacturer of digicam',0
db 0x01,0x10,'Model',0
db 0x01,0x12,'Orientation',0
db 0x01,0x1a,'X resolution',0
db 0x01,0x1b,'Y resolution',0
db 0x01,0x28,'Resolution unit',0
db 0x01,0x31,'Software',0
db 0x01,0x32,'Date time',0
db 0x01,0x3e,'White point',0
db 0x01,0x3f,'Primary chromaticities',0
db 0x02,0x11,'YCbCrCoefficients',0
db 0x02,0x13,'YCbCrPositioning',0
db 0x02,0x14,'Reference black white',0
db 0x82,0x98,'Copyright',0
db 0x87,0x69,'Exif offset',0
db 0x88,0x25,'GPS Info',0
dw 0
;input:
; bof - 㪠§ â¥«ì ­  ­ ç «® ä ©« 
; app1 - 㪠§ â¥«ì ¤«ï § ¯®«­¥­¨ï exif.app1
;output:
; app1 - 㪠§ â¥«ì ­  ­ ç «® exif.app1 (¨«¨ 0 ¥á«¨ ­¥ ­ ©¤¥­® ¨«¨ ä®à¬ â ä ©«  ­¥ ¯®¤¤¥à¦¨¢ ¥âáï)
align 4
proc exif_get_app1 uses eax ebx edi, bof:dword, app1:dword
mov eax,[bof]
mov edi,[app1]
;ä ©« ¢ ä®à¬ â¥ jpg?
cmp word[eax],0xd8ff
jne .no_exif
add eax,2
;ä ©« ᮤ¥à¦¨â exif.app0?
cmp word[eax],0xe0ff
jne @f
add eax,2
movzx ebx,word[eax]
ror bx,8 ;¢á¥£¤  «¨ â ª ­ ¤®?
add eax,ebx
@@:
;ä ©« ᮤ¥à¦¨â exif.app1?
cmp word[eax],0xe1ff
jne .no_exif
add eax,2
mov [edi],eax
jmp @f
.no_exif:
mov dword[edi],0
@@:
ret
endp
;input:
; app1 - 㪠§ â¥«ì ­  ­ ç «® exif.app1
; num - ¯®à浪®¢ë© ­®¬¥à ⥣  (­ ç¨­ ¥âáï á 1)
; txt - 㪠§ â¥«ì ­  ⥪áâ, ªã¤  ¡ã¤¥â § ¯¨á ­® §­ ç¥­¨¥
; t_max - ¬ ªá¨¬ «ì­ë© à §¬¥à ⥪áâ 
align 4
proc exif_get_app1_tag, app1:dword, num:dword, txt:dword, t_max:dword
pushad
mov eax,[app1]
mov edi,[txt]
mov ecx,[num]
xor edx,edx
cmp eax,edx
je .end_f ;¥á«¨ ­¥ ­ ©¤¥­ 㪠§ â¥«ì ­  ­ ç «® exif.app1
cmp ecx,edx
jle .end_f ;¥á«¨ ¯®à浪®¢ë© ­®¬¥à ⥣  <= 0
mov byte[edi],0
cmp word[eax+offs_m_or_i],'II'
je @f
inc edx ;if 'MM' edx=1
@@:
;¯à®¢¥à塞 ç¨á«® ⥣®¢
movzx ebx,word[eax+offs_tag_count]
bt edx,0
jnc @f
ror bx,8
@@:
cmp ecx,ebx
jg .end_f ;¥á«¨ ­®¬¥à ⥣  ¡®«ìè¥ ç¥¬ ¨å ¥áâì ¢ ä ©«¥
;¯¥à¥å®¤¨¬ ­  § ¤ ­­ë© ⥣
dec ecx
imul ecx,tag_size
add eax,offs_tag_0
add eax,ecx
;ç¨â ¥¬ ­ §­ ç¥­¨¥ ⥣ 
push exif_tag_numbers
pop esi
.next_tag:
mov bx,word[esi]
cmp bx,0
je .tag_unknown ;⥣ ­¥ ®¯®§­ ­
bt edx,0
jc @f
ror bx,8
@@:
cmp word[eax],bx
je .found
inc esi
@@:
inc esi
cmp byte[esi],0
jne @b
inc esi
jmp .next_tag
.found:
;ª®¯¨à㥬 áâபã
add esi,2
stdcall str_n_cat,edi,esi,[t_max]
;ç¨â ¥¬ ¨­ä®à¬ æ¨î ¢ ⥣¥
mov bx,tag_format_text
bt edx,0
jnc @f
ror bx,8
@@:
cmp word[eax+2],bx
jne .tag_02
stdcall str_n_cat,edi,txt_dp,[t_max]
;¯à®¢¥à塞 ¤«¨­­ã áâப¨
mov ebx,dword[eax+4]
bt edx,0
jnc @f
ror bx,8
ror ebx,16
ror bx,8
@@:
cmp ebx,4
jg @f
;¥á«¨ áâப  ¯®¬¥é ¥âáï ¢ 4 ᨬ¢®« 
mov esi,eax
add esi,8
stdcall str_n_cat,edi,esi,[t_max]
jmp .end_f
;¥á«¨ áâப  ­¥ ¯®¬¥é ¥âáï ¢ 4 ᨬ¢®« 
@@:
mov esi,dword[eax+8]
bt edx,0
jnc @f
ror si,8
ror esi,16
ror si,8
@@:
add esi,offs_m_or_i
add esi,[app1]
stdcall str_n_cat,edi,esi,[t_max]
;;;jmp .end_f
.tag_02:
jmp .end_f
.tag_unknown:
mov dword[edi],'???'
mov byte[edi+3],0
.end_f:
popad
ret
endp
align 4
proc exif_get_image_160_120 uses edi, app1:dword
mov edi,[app1]
ret
endp
align 4
proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n:dword
mov esi,dword[str2]
mov ecx,dword[n]
mov edi,dword[str1]
stdcall str_len,edi
add edi,eax
cld
repne movsb
mov byte[edi],0
ret
endp
;output:
; eax = strlen
align 4
proc str_len, str1:dword
mov eax,[str1]
@@:
cmp byte[eax],0
je @f
inc eax
jmp @b
@@:
sub eax,[str1]
ret
endp
align 16
EXPORTS:
dd sz_exif_get_app1, exif_get_app1
dd sz_exif_get_app1_tag, exif_get_app1_tag
;dd sz_exif_get_image_160_120, exif_get_image_160_120
dd 0,0
sz_exif_get_app1 db 'exif_get_app1',0
sz_exif_get_app1_tag db 'exif_get_app1_tag',0
;sz_exif_get_image_160_120 db 'exif_get_image_160_120',0