Subversion Repositories Kolibri OS

Rev

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

  1. ;-----------------------------------------------------------
  2. ;-------analizing picture to palette------------------------
  3. ;-----------------------------------------------------------
  4. analizing_picture_to_palette:
  5.         mov     eax,[Picture_SizeX]
  6.         mov     ebx,[Picture_SizeY]
  7.         imul    eax,ebx
  8.         mov     ecx,eax
  9.         mov     edx,[PointerToPicture]
  10.         mov     esi,1 ;counter colors in palette
  11.  
  12. ;put firs color of picture how one color in palette
  13.         mov     ebp,[PointerToPalette]
  14.         mov     eax,[edx]
  15.         and     eax,0xffffff
  16.         mov     [ebp],eax
  17.  
  18. analizing_to_palette:
  19.         mov     eax,[edx]
  20.         and     eax,0xffffff
  21.         mov     edi,esi
  22.         mov     ebp,[PointerToPalette]
  23.  
  24. next_color_in_palette:
  25.         mov     ebx,[ebp]
  26.         and     ebx,0xffffff
  27.         cmp     ebx,eax     ;this is color have in palette
  28.         je      exit_loop_palette
  29.  
  30.         add     ebp,4
  31.         dec     edi
  32.         jnz     next_color_in_palette
  33.  
  34.         inc     esi
  35.         cmp     esi,256 ;256 colors
  36.         ja      more_than_256_colors
  37.  
  38.         mov     ebp,[PointerToPalette]
  39.         mov     ebx,esi
  40.         dec     ebx
  41.         shl     ebx,2
  42.         add     ebp,ebx
  43.         mov     [ebp],ax
  44.         shr     eax,16
  45.         mov     [ebp+2],al
  46.  
  47. exit_loop_palette:
  48.         add     edx,3
  49.         dec     ecx
  50.         jnz     analizing_to_palette
  51.  
  52. more_than_256_colors:
  53.         mov     eax,esi
  54.         ret