kolibrios-gitea/programs/media/animage/trunk/palette.inc
Marat Zakiyanov (Mario79) bab525b2cf Animage v1.3
1) Fixed window flicker when redrawing
2) Fixed memory leak for stack

git-svn-id: svn://kolibrios.org@1643 a494cfbc-eb01-0410-851d-a64ba20cac60
2010-10-04 20:40:19 +00:00

54 lines
1.1 KiB
PHP

;-----------------------------------------------------------
;-------analizing picture to palette------------------------
;-----------------------------------------------------------
analizing_picture_to_palette:
mov eax,[Picture_SizeX]
mov ebx,[Picture_SizeY]
imul eax,ebx
mov ecx,eax
mov edx,[PointerToPicture]
mov esi,1 ;counter colors in palette
;put firs color of picture how one color in palette
mov ebp,[PointerToPalette]
mov eax,[edx]
and eax,0xffffff
mov [ebp],eax
analizing_to_palette:
mov eax,[edx]
and eax,0xffffff
mov edi,esi
mov ebp,[PointerToPalette]
next_color_in_palette:
mov ebx,[ebp]
and ebx,0xffffff
cmp ebx,eax ;this is color have in palette
je exit_loop_palette
add ebp,4
dec edi
jnz next_color_in_palette
inc esi
cmp esi,256 ;256 colors
ja more_than_256_colors
mov ebp,[PointerToPalette]
mov ebx,esi
dec ebx
shl ebx,2
add ebp,ebx
mov [ebp],ax
shr eax,16
mov [ebp+2],al
exit_loop_palette:
add edx,3
dec ecx
jnz analizing_to_palette
more_than_256_colors:
mov eax,esi
ret