Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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.         add     eax, 200*0x10000 + 5*2 - 1      ; window x position + 10 pixels width for skin borders
  74.         mov     [window_width], eax
  75.  
  76.         mcall   48, 4   ; get skin height
  77.         mov     ebx, [image_converted]
  78.         add     eax, [ebx + Image.Height]
  79.         add     eax, 100*0x10000 + 5 - 1        ; window y position + 5 pixels height for skin bottom border
  80.         mov     [window_height], eax
  81. ;-----------------------------------------------------------------------------
  82.  
  83. still:
  84.         mcall   10
  85.         cmp     eax, 1
  86.         je      .draw_window
  87.         cmp     eax, 2
  88.         je      .key
  89.         cmp     eax, 3
  90.         je      .button
  91.         jmp     still
  92.  
  93.  
  94.   .draw_window:
  95.         mcall   12, 1
  96.         mcall   0, [window_width], [window_height], 0x74FFFFFF, 0x00000000, window_title
  97.         call    draw_image
  98.         mcall   12, 2
  99.         jmp     still
  100.  
  101.   .key:
  102.         mcall   2
  103.         jmp     still
  104.  
  105.   .button:
  106.         mcall   17
  107.         shr     eax, 8
  108.         cmp     eax, 1
  109.         jne     still
  110.  
  111. exit:
  112.         invoke  img.destroy, [image_converted]
  113.         mcall   -1
  114.  
  115.  
  116. proc    draw_image
  117.  
  118.         mov     ebx, [image_converted]
  119.         invoke  img.draw, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, 0
  120.  
  121.         ret
  122. endp
  123.  
  124. ;-----------------------------------------------------------------------------
  125.  
  126. window_title    db 'img.convert example',0
  127. input_file:
  128.         db '/hd0/1/kolibri_logo.jpg',0
  129. ;       db '/hd0/1/tga/CTC16.TGA',0
  130. ;       db '/hd0/1/indexed_packbits_le_test_00.tiff',0
  131. ;       db '/hd0/1/graya_123x123.tiff',0
  132. ;       db '/hd0/1/bilevel_00.wbmp',0
  133. ;       db '/hd0/1/rgb_af.jpg',0
  134. ;       db '/hd0/1/gray_5x7.tiff',0
  135. ;       db '/hd0/1/rgb_lzw_le_2x2.tiff',0
  136. ;       db '/hd0/1/grayscale_123x123.tiff',0
  137. ;       db '/hd0/1/grayscale_357x357.tiff',0
  138. ;       db '/hd0/1/grayscale_620x620.tiff',0
  139. ;       db '/hd0/1/rgb_220.jpg',0
  140. ;       db '/hd0/1/rgba_217.tiff',0
  141. ;       db '/hd0/1/rgb_7x9.tiff',0
  142. ;       db '/hd0/1/rgba_7x9.tiff',0
  143. ;       db '/hd0/1/gray_7x9.tiff',0
  144. ;       db '/hd0/1/rgb_70x90.png',0
  145. ;-----------------------------------------------------------------------------
  146.  
  147. align 4
  148. @IMPORT:
  149.  
  150. library                           \
  151.         libio   , 'libio.obj'   , \
  152.         libimg  , 'libimg.obj'
  153.  
  154. import  libio                           , \
  155.         libio.init      , 'lib_init'    , \
  156.         file.size       , 'file_size'   , \
  157.         file.open       , 'file_open'   , \
  158.         file.read       , 'file_read'   , \
  159.         file.close      , 'file_close'
  160.  
  161. import  libimg                          , \
  162.         libimg.init     , 'lib_init'    , \
  163.         img.decode      , 'img_decode'  , \
  164.         img.destroy     , 'img_destroy' , \
  165.         img.draw        , 'img_draw'    , \
  166.         img.convert     , 'img_convert' , \
  167.         img.types_table , 'img_types_table'
  168.  
  169. ;-----------------------------------------------------------------------------
  170.  
  171. I_END:
  172.  
  173. fh              dd ?
  174. img_data_len    dd ?
  175. img_data        dd ?
  176.  
  177. image_initial   dd ?
  178. image_converted dd ?
  179.  
  180. window_width    dd ?
  181. window_height   dd ?
  182.  
  183. rd 0x1000       ; stack
  184. E_END:
  185.