Subversion Repositories Kolibri OS

Rev

Blame | 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-fdo.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  img.from_file, input_file
  26.         test    eax, eax
  27.         jz      exit
  28.         mov     [image_top], eax
  29.  
  30.         invoke img.create, 100, 100, Image.bpp32
  31.         mov     [image_bottom], eax
  32.         mov     edi, [eax+Image.Data]
  33.         mov     eax, 0xffffff00
  34.         mov     ecx, 100*100
  35.         rep stosd
  36.  
  37. still:
  38.         mcall   10
  39.         cmp     eax, 1
  40.         je      .draw_window
  41.         cmp     eax, 2
  42.         je      .key
  43.         cmp     eax, 3
  44.         je      .button
  45.         jmp     still
  46.  
  47.  
  48. .draw_window:
  49.         mcall   12, 1
  50.         mcall   0, <200, 150>, <200, 150>, 0x73FFFFFF, 0x00000000, window_title
  51.         call    draw_image
  52.         mcall   12, 2
  53.         jmp     still
  54.  
  55. .key:
  56.         mcall   2
  57.         jmp     still
  58.  
  59. .button:
  60.         mcall   17
  61.         shr     eax, 8
  62.         cmp     eax, 1
  63.         jne     still
  64.  
  65. exit:
  66.         invoke  img.destroy, [image_bottom]
  67.         invoke  img.destroy, [image_top]
  68.         mcall   -1
  69.  
  70.  
  71. proc draw_image
  72.         mcall   9, proc_info, -1
  73.  
  74.         mov     ecx, [proc_info.client_box.height]
  75.         inc     ecx
  76.         mov     edx, [proc_info.client_box.width]
  77.         inc     edx
  78.  
  79.         mov     eax, [image_bottom]
  80.         mov     esi, [eax+Image.Data]
  81.         invoke  img.create, [eax+Image.Width], [eax+Image.Height], Image.bpp32
  82.         mov     [image_blended], eax
  83.         mov     edi, [eax+Image.Data]
  84.         mov     ecx, [eax+Image.Width]
  85.         imul    ecx, [eax+Image.Height]
  86.         rep movsd
  87.         invoke  img.blend, [image_blended], [image_top], 5, 10, 20, 50, 80, 60
  88.         invoke  img.draw, eax, 0, 0, [eax+Image.Width], [eax+Image.Height], 0, 0
  89.         invoke  img.destroy, [image_blended]
  90.  
  91.         ret
  92. endp
  93.  
  94. ;-----------------------------------------------------------------------------
  95.  
  96. window_title    db 'img.blend example',0
  97. input_file:
  98. ;        db '/hd0/1/bottom.jpg',0
  99.         db '/hd0/1/top.png',0
  100. ;-----------------------------------------------------------------------------
  101.  
  102. align 4
  103. @IMPORT:
  104.  
  105. library                           \
  106.         libimg  , 'libimg.obj'
  107.  
  108. import  libimg                            , \
  109.         libimg.init     , 'lib_init'      , \
  110.         img.create      , 'img_create'    , \
  111.         img.decode      , 'img_decode'    , \
  112.         img.destroy     , 'img_destroy'   , \
  113.         img.draw        , 'img_draw'      , \
  114.         img.from_file   , 'img_from_file' , \
  115.         img.blend       , 'img_blend'
  116.  
  117. ;-----------------------------------------------------------------------------
  118.  
  119. I_END:
  120.  
  121. image_top       dd ?
  122. image_bottom    dd ?
  123. image_blended   dd ?
  124.  
  125. proc_info       process_information
  126.  
  127. rd 0x400        ; stack
  128. E_END:
  129.