Subversion Repositories Kolibri OS

Rev

Rev 6342 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; load picture from file to memory
  2. align 4
  3. open_b rb 560
  4. txt_not_memory db 'Cannot open image. Because there is not enough available memory.',0
  5.  
  6. align 4
  7. load_picture:
  8.     mov [file_information.Function], SSF_GET_INFO
  9.     mov [file_information.Position], 0
  10.     mov [file_information.Flags], 0
  11.     mov dword[file_information.Count], 0
  12.     mov dword[file_information.Buffer], open_b
  13.     mov byte[file_information+20], 0
  14.     mov dword[file_information.FileName], file_path
  15.     mcall SF_FILE,file_information
  16.         or eax,eax
  17.         jnz .end_open
  18.  
  19.     mov ecx,dword[open_b+32] ;+32 qword: размер файла в байтах
  20.         add ecx,mem_screen+mem_panel_all+mem_flood_f
  21.         mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[ScreenPointer]
  22.         mov [ScreenPointer],eax
  23.         add eax,mem_screen+mem_panel_all
  24.         sub ecx,mem_screen+mem_panel_all+mem_flood_f
  25.         mov [file_information.Function], SSF_READ_FILE
  26.         mov [file_information.Position], 0
  27.         mov [file_information.Flags], 0
  28.         mov [file_information.Count], ecx
  29.         mov [file_information.Buffer], eax
  30.         mov byte[file_information+20], 0
  31.         mov [file_information.FileName], file_path
  32.         mcall SF_FILE,file_information ;загружаем файл изображения
  33.         cmp ebx,0xffffffff
  34.         je .end_open
  35.                 ;определяем вид изображения и пишем его параметры
  36.                 mov eax,[ScreenPointer]
  37.                 add eax,mem_screen+mem_panel_all
  38.                 stdcall [img_decode], eax,ebx,0
  39.                 push eax
  40.                 ;определяем размер декодированного изображения
  41.                 mov ecx,[eax+4] ;+4 = image width
  42.                 mov dword[Picture_SizeX],ecx
  43.                 mov eax,[eax+8] ;+8 = image height
  44.                 mov dword[Picture_SizeY],eax
  45.                 imul ecx,eax
  46.                 imul ecx,15
  47.                 add ecx,mem_screen+mem_panel_all+mem_flood_f
  48.                 mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[ScreenPointer]
  49.                 or eax,eax
  50.                 jnz .have_new_memory
  51.                         notify_window_run txt_not_memory
  52.                         pop ebx
  53.                         jmp @f
  54.                 .have_new_memory:
  55.                         ;notify_window_run sz_main_menu_File_Open
  56.                         mov [ScreenPointer],eax
  57.                         call prepare_data_pointers
  58.                         pop ebx
  59.                         stdcall [img_to_rgb2], ebx,[PointerToPicture] ;преобразуем изображение к формату rgb
  60.                         mov [save_flag],1
  61.                 @@:
  62.                 stdcall [img_destroy], ebx ;удаляем временный буфер с параметрами изображения
  63.         .end_open:
  64.         ret
  65.