fix create empty image buffer

git-svn-id: svn://kolibrios.org@6211 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-02-13 00:08:46 +00:00
parent c28f9414e8
commit 4a01275caa
3 changed files with 23 additions and 74 deletions

View File

@ -6,10 +6,9 @@ use32
include '../../macros.inc'
include '../../proc32.inc'
include '../../KOSfuncs.inc'
include '../../develop/libraries/box_lib/load_lib.mac'
include '../../load_img.inc'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../develop/libraries/TinyGL/asm_fork/opengl_const.inc'
include '../../dll.inc'
include 'lang.inc'
include 'info_fun_float.inc'
include 'info_menu.inc'
@ -24,16 +23,6 @@ version_edit equ 0
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
ID_ICON_CHUNK_MAIN equ 0 ;¨ª®­ª  £« ¢­®£® ¡«®ª 
ID_ICON_CHUNK_NOT_FOUND equ 1 ;¨ª®­ª  ­¥ ¨§¢¥áâ­®£® ¡«®ª 
ID_ICON_DATA equ 2 ;¨ª®­ª  ¤«ï ¤ ­­ëå ¡«®ª , ­¥ ®¯à¥¤¥«¥­­®© áâàãªâãàë
@ -46,61 +35,17 @@ include 'info_o3d.inc'
align 4
fl255 dd 255.0
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì, ­ã¦¥­ ¤«ï ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
open_file_data dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢ 3ds
open_file_size dd 0 ;à §¬¥à ®âªàë⮣® ä ©« 
open_b rb 560
;
main_wnd_height equ 460 ;¢ëá®â  £« ¢­®£® ®ª­  ¯à®£à ¬¬ë
fn_toolbar db 'toolbar.png',0
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*12+54
image_data_toolbar dd 0
;
TREE_ICON_SYS16_BMP_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*11+54 ;à §¬¥à bmp ä ©«  á á¨á⥬­ë¬¨ ¨ª®­ª ¬¨
icon_tl_sys dd 0 ;㪠§ â¥¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï á¨á⥬­ëå ¨ª®­®ª
icon_toolbar dd 0 ;㪠§ â¥¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï ¨ª®­®ª ®¡ê¥ªâ®¢
IMAGE_CHUNKS_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*12+54 ;à §¬¥à bmp ä ©«  á ¨ª®­ª ¬¨ ®¡ê¥ªâ®¢
;
IMAGE_FILE1_SIZE equ 128*144*3+54 ;à §¬¥à ä ©«  á ¨§®¡à ¦¥­¨¥¬
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,0
else
copy_path path,[32],file_name,0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
end if
stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
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], dword size
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 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
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]
@@:
}
icon_tl_sys dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï á¨á⥬­ëå ¨ª®­®ª
icon_toolbar dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï ¨ª®­®ª ®¡ê¥ªâ®¢
;--------------------------------------
level_stack dd 0
@ -180,23 +125,23 @@ start:
mov dword[w_scr_t1.type],1
stdcall dword[tl_data_init], tree1
;á¨á⥬­ë¥ ¨ª®­ª¨ 16*16 ¤«ï tree_list
load_image_file 'tl_sys_16.png', icon_tl_sys,TREE_ICON_SYS16_BMP_SIZE
load_image_file 'tl_sys_16.png', icon_tl_sys
;¥á«¨ ¨§®¡à ¦¥­¨¥ ­¥ ®âªàë«®áì, â® ¢ icon_tl_sys ¡ã¤ãâ
;­¥ ¨­¨æ¨ «¨§¨à®¢ ­­ë¥ ¤ ­­ë¥, ­® ®è¨¡ª¨ ­¥ ¡ã¤¥â, â. ª. ¡ãä¥à ­ã¦­®£® à §¬¥à 
mov eax,dword[icon_tl_sys]
mov dword[tree1.data_img_sys],eax
load_image_file 'objects.png', icon_toolbar,IMAGE_CHUNKS_SIZE
load_image_file 'objects.png', icon_toolbar
mov eax,dword[icon_toolbar]
mov dword[tree1.data_img],eax
load_image_file 'font8x9.bmp', image_data_toolbar,IMAGE_FILE1_SIZE
load_image_file 'font8x9.bmp', image_data_toolbar
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
load_image_file fn_toolbar, image_data_toolbar
;à ¡®â  á ä ©«®¬ ­ áâ஥ª
copy_path ini_name,sys_path,file_name,0
@ -1171,15 +1116,15 @@ l_libs_start:
err_msg_found_lib_0, head_f_l, proclib_import,err_msg_import_0, head_f_i
lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
err_msg_found_lib_1, head_f_l, import_libimg, err_msg_import_1, head_f_i
lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
lib_2 l_libs lib_name_2, sys_path, file_name, system_dir_2,\
err_msg_found_lib_2, head_f_l, import_box_lib,err_msg_import_2,head_f_i
lib_3 l_libs lib_name_3, sys_path, library_path, system_dir_3,\
lib_3 l_libs lib_name_3, sys_path, file_name, system_dir_3,\
err_msg_found_lib_3, head_f_l, import_buf2d, err_msg_import_3,head_f_i
lib_4 l_libs lib_name_4, sys_path, library_path, system_dir_4,\
lib_4 l_libs lib_name_4, sys_path, file_name, system_dir_4,\
err_msg_found_lib_4, head_f_l, import_libkmenu,err_msg_import_4,head_f_i
lib_5 l_libs lib_name_5, sys_path, library_path, system_dir_5,\
lib_5 l_libs lib_name_5, sys_path, file_name, system_dir_5,\
err_msg_found_lib_5, head_f_l, import_lib_tinygl,err_msg_import_5,head_f_i
lib_6 l_libs lib_name_6, sys_path, library_path, system_dir_6,\
lib_6 l_libs lib_name_6, sys_path, file_name, system_dir_6,\
err_msg_found_lib_6, head_f_l, import_libini, err_msg_import_6,head_f_i
l_libs_end:
@ -1423,7 +1368,7 @@ buf_ogl:
align 4
buf_1:
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 25,25 ;+4 left,top
dw 0,0 ;+4 left,top
dd 128,144 ;+8 w,h
dd 0,24 ;+16 color,bit in pixel
@ -1452,9 +1397,9 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ;
lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; <20> à ¬¥âàë ä®­®¢®£® ®á¢¥é¥­¨ï
if lang eq ru
capt db 'info 3ds [user] ¢¥àá¨ï 19.01.16',0 ;¯®¤¯¨áì ®ª­ 
capt db 'info 3ds [user] ¢¥àá¨ï 13.02.16',0 ;¯®¤¯¨áì ®ª­ 
else
capt db 'info 3ds [user] version 19.01.16',0 ;window caption
capt db 'info 3ds [user] version 13.02.16',0 ;window caption
end if
align 16
@ -1479,7 +1424,6 @@ thread_coords:
stacktop:
sys_path rb 2048
file_name rb 4096
library_path rb 2048
plugin_path rb 4096
openfile_path rb 4096
filename_area rb 256

View File

@ -95,10 +95,10 @@ proc buf_create_f_img, buf_struc:dword, rgb_data:dword
mov edi,dword[buf_struc]
mov ecx,buf2d_w
cmp ecx,1
jl .end_create
jl .error
mov ebx,buf2d_h
cmp ebx,1
jl .end_create
jl .error
imul ecx,ebx
cmp buf2d_bits,24
jne @f
@ -115,6 +115,8 @@ proc buf_create_f_img, buf_struc:dword, rgb_data:dword
jne @f
cld
mov esi,[rgb_data]
or esi,esi
jz @f
mov edi,eax ;eax=buf2d_data
rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
jmp .end_create

View File

@ -23,7 +23,8 @@ align 4
open_b rb 560
; path - может быть переменной или строковым параметром
; buf - переменная куда будет записан указатель на изображение в формате rgb
; buf - переменная куда будет записан указатель на изображение в формате rgb,
; в случае если файл не откроется то будет записан 0
; img_w, img_h - переменные куда будут записаны размеры открываемого
; изображения, не обязательные параметры
; bytes_p_p - сколько байт памяти брать на пиксель, не обязательный параметр
@ -42,6 +43,8 @@ if path eqtype '' ;проверяем задан ли строкой парам
else
copy_path path,[32],file_name,0 ;формируем полный путь к файлу изображения, подразумеваем что он в одной папке с программой
end if
mov dword[buf],0
mov [run_file_70.Function], SSF_GET_INFO
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0