Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2. org 0x0
  3.         db 'MENUET01'
  4.         dd 0x01, START, I_END, E_END, E_END, 0, 0
  5.  
  6. ;-----------------------------------------------------------------------------
  7.  
  8. include '../../../../../proc32.inc'
  9. include '../../../../../macros.inc'
  10. include '../../../../../dll.inc'
  11. ;include '../../../../../debug.inc'
  12.  
  13. include '../../libio/libio.inc'
  14. include '../../libimg/libimg.inc'
  15.  
  16. ;-----------------------------------------------------------------------------
  17.  
  18. START:
  19.         mcall   68, 11
  20.  
  21.         stdcall dll.Load, @IMPORT
  22.         or      eax, eax
  23.         jnz     exit
  24.  
  25.         invoke  file.open, input_file, O_READ
  26.         or      eax, eax
  27.         jz      exit
  28.         mov     [fh], eax
  29.  
  30.         invoke  file.size, input_file
  31.         mov     [img_data_len], ebx
  32.  
  33.         stdcall mem.Alloc, ebx
  34.         or      eax, eax
  35.         jz      exit
  36.         mov     [img_data], eax
  37.  
  38.         invoke  file.read, [fh], eax, [img_data_len]
  39.         cmp     eax, -1
  40.         je      exit
  41.         cmp     eax, [img_data_len]
  42.         jne     exit
  43.  
  44.         invoke  file.close, [fh]
  45.         inc     eax
  46.         jz      exit
  47.        
  48.         invoke  img.decode, [img_data], [img_data_len], 0
  49.         or      eax, eax
  50.         jz      exit
  51.         mov     [image_initial], eax
  52.  
  53. ;pushfd
  54. ;pushad
  55. ;mov ebx, [image_initial]
  56. ;debug_print_dec dword[ebx + Image.Type]
  57. ;newline
  58. ;popad
  59. ;popfd
  60.         stdcall mem.Free, [img_data]
  61.         test    eax, eax
  62.         jz      exit
  63.  
  64.         invoke  img.convert, [image_initial], 0, Image.bpp8g, 0, 0
  65.         test    eax, eax
  66.         jz      exit
  67.         mov     [image_converted], eax
  68.  
  69.         invoke  img.destroy, [image_initial]
  70.  
  71.         mov     ebx, [image_converted]
  72.         mov     eax, [ebx + Image.Width]
  73.         ; window x position + 10 pixels width for skin borders
  74.         add     eax, 200*0x10000 + 5*2 - 1
  75.         mov     [window_width], eax
  76.  
  77.         mcall   48, 4   ; get skin height
  78.         mov     ebx, [image_converted]
  79.         add     eax, [ebx + Image.Height]
  80.         ; window y position + 5 pixels height for skin bottom border
  81.         add     eax, 100*0x10000 + 5 - 1
  82.         mov     [window_height], eax
  83. ;-----------------------------------------------------------------------------
  84.  
  85. still:
  86.         mcall   10
  87.         cmp     eax, 1
  88.         je      .draw_window
  89.         cmp     eax, 2
  90.         je      .key
  91.         cmp     eax, 3
  92.         je      .button
  93.         jmp     still
  94.  
  95.  
  96.   .draw_window:
  97.         mcall   12, 1
  98.         mcall   0, [window_width], [window_height], 0x74FFFFFF, 0x00000000, \
  99.                 window_title
  100.         call    draw_image
  101.         mcall   12, 2
  102.         jmp     still
  103.  
  104.   .key:
  105.         mcall   2
  106.         jmp     still
  107.  
  108.   .button:
  109.         mcall   17
  110.         shr     eax, 8
  111.         cmp     eax, 1
  112.         jne     still
  113.  
  114. exit:
  115.         invoke  img.destroy, [image_converted]
  116.         mcall   -1
  117.  
  118.  
  119. proc    draw_image
  120.  
  121.         mov     ebx, [image_converted]
  122.         invoke  img.draw, ebx, 0, 0, [ebx + Image.Width], \
  123.                 [ebx + Image.Height], 0, 0
  124.  
  125.         ret
  126. endp
  127.  
  128. ;-----------------------------------------------------------------------------
  129.  
  130. window_title    db 'img.convert example',0
  131. input_file:
  132.         db '/hd0/1/kolibri_logo.jpg',0
  133. ;       db '/hd0/1/tga/CTC16.TGA',0
  134. ;       db '/hd0/1/indexed_packbits_le_test_00.tiff',0
  135. ;       db '/hd0/1/graya_123x123.tiff',0
  136. ;       db '/hd0/1/bilevel_00.wbmp',0
  137. ;       db '/hd0/1/rgb_af.jpg',0
  138. ;       db '/hd0/1/gray_5x7.tiff',0
  139. ;       db '/hd0/1/rgb_lzw_le_2x2.tiff',0
  140. ;       db '/hd0/1/grayscale_123x123.tiff',0
  141. ;       db '/hd0/1/grayscale_357x357.tiff',0
  142. ;       db '/hd0/1/grayscale_620x620.tiff',0
  143. ;       db '/hd0/1/rgb_220.jpg',0
  144. ;       db '/hd0/1/rgba_217.tiff',0
  145. ;       db '/hd0/1/rgb_7x9.tiff',0
  146. ;       db '/hd0/1/rgba_7x9.tiff',0
  147. ;       db '/hd0/1/gray_7x9.tiff',0
  148. ;       db '/hd0/1/rgb_70x90.png',0
  149. ;-----------------------------------------------------------------------------
  150.  
  151. align 4
  152. @IMPORT:
  153.  
  154. library                           \
  155.         libio   , 'libio.obj'   , \
  156.         libimg  , 'libimg.obj'
  157.  
  158. import  libio                           , \
  159.         libio.init      , 'lib_init'    , \
  160.         file.size       , 'file_size'   , \
  161.         file.open       , 'file_open'   , \
  162.         file.read       , 'file_read'   , \
  163.         file.close      , 'file_close'
  164.  
  165. import  libimg                          , \
  166.         libimg.init     , 'lib_init'    , \
  167.         img.decode      , 'img_decode'  , \
  168.         img.destroy     , 'img_destroy' , \
  169.         img.draw        , 'img_draw'    , \
  170.         img.convert     , 'img_convert' , \
  171.         img.types_table , 'img_types_table'
  172.  
  173. ;-----------------------------------------------------------------------------
  174.  
  175. I_END:
  176.  
  177. fh              dd ?
  178. img_data_len    dd ?
  179. img_data        dd ?
  180.  
  181. image_initial   dd ?
  182. image_converted dd ?
  183.  
  184. window_width    dd ?
  185. window_height   dd ?
  186.  
  187. rd 0x1000       ; stack
  188. E_END:
  189.