Subversion Repositories Kolibri OS

Rev

Rev 3036 | 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.         stdcall mem.Free, [img_data]
  54.         test    eax, eax
  55.         jz      exit
  56. ;-----------------------------------------------------------------------------
  57.  
  58. still:
  59.         mcall   10
  60.         cmp     eax, 1
  61.         je      .draw_window
  62.         cmp     eax, 2
  63.         je      .key
  64.         cmp     eax, 3
  65.         je      .button
  66.         jmp     still
  67.  
  68.  
  69.   .draw_window:
  70.         mcall   12, 1
  71.         mcall   0, <200, 150>, <200, 150>, 0x73FFFFFF, 0x00000000, window_title
  72.         call    draw_image
  73.         mcall   12, 2
  74.         jmp     still
  75.  
  76.   .key:
  77.         mcall   2
  78.         jmp     still
  79.  
  80.   .button:
  81.         mcall   17
  82.         shr     eax, 8
  83.         cmp     eax, 1
  84.         jne     still
  85.  
  86. exit:
  87.         cmp     [image_initial], 0
  88.         je      @f
  89.         invoke  img.destroy, [image_initial]
  90.     @@:
  91.         cmp     [image_scaled], 0
  92.         je      @f
  93.         invoke  img.destroy, [image_scaled]
  94.     @@:
  95.         mcall   -1
  96.  
  97.  
  98. proc    draw_image
  99.  
  100.         cmp     [image_scaled], 0
  101.         je      @f
  102.         invoke  img.destroy, [image_scaled]
  103.     @@:
  104.  
  105.         mcall   9, proc_info, -1
  106.  
  107.         mov     ecx, [proc_info.client_box.height]
  108.         inc     ecx
  109.         mov     edx, [proc_info.client_box.width]
  110.         inc     edx
  111.  
  112.         mov     ebx, [image_initial]
  113. ;       invoke  img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_INTEGER, LIBIMG_INTER_NONE,     5, 5
  114. ;       invoke  img.scale, ebx, 1, 2,                   5,                    5, 0, LIBIMG_SCALE_TILE,    LIBIMG_INTER_NONE,     edx, ecx
  115. ;       invoke  img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_TILE,    LIBIMG_INTER_NONE,     edx, ecx
  116. ;       invoke  img.scale, ebx, 1, 2,                   5,                    5, 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_BILINEAR, edx, ecx
  117.         invoke  img.scale, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_BILINEAR, edx, ecx
  118.  
  119.         test    eax, eax
  120.         jz      exit
  121.         mov     [image_scaled], eax
  122.  
  123.         invoke  img.draw, eax, 0, 0, [eax + Image.Width], [eax + Image.Height], 0, 0
  124.  
  125.         ret
  126. endp
  127.  
  128. ;-----------------------------------------------------------------------------
  129.  
  130. window_title    db 'img.scale example',0
  131. input_file:
  132. ;       db '/hd0/1/gray_5x7.tiff',0
  133.         db '/hd0/1/rgb_lzw_le_2x2.tiff',0
  134. ;       db '/hd0/1/grayscale_123x123.tiff',0
  135. ;       db '/hd0/1/grayscale_357x357.tiff',0
  136. ;       db '/hd0/1/grayscale_620x620.tiff',0
  137. ;       db '/hd0/1/rgb_220.jpg',0
  138. ;       db '/hd0/1/rgba_217.tiff',0
  139. ;       db '/hd0/1/rgb_7x9.tiff',0
  140. ;       db '/hd0/1/rgba_7x9.tiff',0
  141. ;       db '/hd0/1/gray_7x9.tiff',0
  142. ;       db '/hd0/1/rgb_70x90.png',0
  143. ;-----------------------------------------------------------------------------
  144.  
  145. align 4
  146. @IMPORT:
  147.  
  148. library                           \
  149.         libio   , 'libio.obj'   , \
  150.         libimg  , 'libimg.obj'
  151.  
  152. import  libio                           , \
  153.         libio.init      , 'lib_init'    , \
  154.         file.size       , 'file_size'   , \
  155.         file.open       , 'file_open'   , \
  156.         file.read       , 'file_read'   , \
  157.         file.close      , 'file_close'
  158.  
  159. import  libimg                          , \
  160.         libimg.init     , 'lib_init'    , \
  161.         img.decode      , 'img_decode'  , \
  162.         img.destroy     , 'img_destroy' , \
  163.         img.draw        , 'img_draw'    , \
  164.         img.scale       , 'img_scale'   , \
  165.         img.formats_table,'img_formats_table'
  166.  
  167. ;-----------------------------------------------------------------------------
  168.  
  169. I_END:
  170.  
  171. fh              dd ?
  172. img_data_len    dd ?
  173. img_data        dd ?
  174.  
  175. image_initial   dd ?
  176. image_scaled    dd ?
  177.  
  178. proc_info       process_information
  179.  
  180. rd 0x1000       ; stack
  181. E_END:
  182.