Subversion Repositories Kolibri OS

Rev

Rev 3105 | Rev 5389 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3105 Rev 3138
Line 3449... Line 3449...
3449
 
3449
 
3450
	popad
3450
	popad
3451
	ret
3451
	ret
Line 3452... Line 3452...
3452
endp
3452
endp
3453
 
3453
 
3454
;䨫ìâ¥à
3454
;䨫ìâà
3455
align 4
3455
align 4
3456
proc buf_filter_dither, buffer:dword, algor:dword
3456
proc buf_filter_dither, buffer:dword, algor:dword
3457
	pushad
3457
	pushad
Line 3462... Line 3462...
3462
		mov esi,buf2d_h
3462
		mov esi,buf2d_h
3463
		mov edi,buf2d_data
3463
		mov edi,buf2d_data
3464
;edi - pointer to 24bit bitmap
3464
;edi - pointer to 24bit bitmap
3465
;edx - x size
3465
;edx - x size
3466
;esi - y size
3466
;esi - y size
3467
		lea   edx,[edx*3]
3467
		lea   edx,[edx+edx*2]
3468
		imul  esi,edx
3468
		imul  esi,edx
Line 3469... Line 3469...
3469
 
3469
 
3470
		;®¯à¥¤¥«ï¥¬ ª ª®©  «£®à¨â¬ ¨á¯®«ì§®¢ âì
3470
		;®¯à¥¤¥«ï¥¬ ª ª®©  «£®à¨â¬ ¨á¯®«ì§®¢ âì
3471
		cmp dword[algor],0
3471
		cmp dword[algor],0
Line 3476... Line 3476...
3476
		cmp dword[algor],1
3476
		cmp dword[algor],1
3477
		jne @f
3477
		jne @f
3478
			call dither_1
3478
			call dither_1
3479
			jmp .dither_end
3479
			jmp .dither_end
3480
		@@:
3480
		@@:
-
 
3481
		cmp dword[algor],2
-
 
3482
		jne @f
3481
		call dither_2
3483
			call dither_2
3482
		jmp .dither_end
3484
			jmp .dither_end
-
 
3485
		@@:
-
 
3486
		cmp dword[algor],3
-
 
3487
		jne @f
-
 
3488
			call dither_3
-
 
3489
			jmp .dither_end
-
 
3490
		@@:
-
 
3491
		call dither_4
-
 
3492
		jmp .dither_end
3483
	.error:
3493
	.error:
3484
		stdcall print_err,sz_buf2d_filter_dither,txt_err_n24b
3494
		stdcall print_err,sz_buf2d_filter_dither,txt_err_n24b
3485
	.dither_end:
3495
	.dither_end:
3486
	popad
3496
	popad
3487
	ret
3497
	ret
3488
endp
3498
endp
Line 3489... Line 3499...
3489
 
3499
 
3490
align 16
3500
align 16
3491
dither_0: ; Sierra Filter Lite algoritm
3501
dither_0: ; Sierra Filter Lite algorithm
3492
newp_0:   ; Dithering cycle
3502
newp_0:   ; Dithering cycle
3493
	xor   ebx,ebx ; At first threshold
3503
	xor   ebx,ebx ; At first threshold
3494
	movzx ecx,byte[edi]
3504
	movzx ecx,byte[edi]
3495
	cmp   cl,255
3505
	cmp   cl,255
Line 3549... Line 3559...
3549
	dec   esi
3559
	dec   esi
3550
	jnz   newp_0
3560
	jnz   newp_0
3551
	ret
3561
	ret
Line 3552... Line 3562...
3552
 
3562
 
3553
align 16
3563
align 16
3554
dither_1: ; Floyd-Steinberg algoritm
3564
dither_1: ; Floyd-Steinberg algorithm
3555
newp_1:   ; Dithering cycle
3565
newp_1:   ; Dithering cycle
3556
	xor   ebx,ebx ; At first threshold
3566
	xor   ebx,ebx ; At first threshold
3557
	movzx ecx,byte[edi]
3567
	movzx ecx,byte[edi]
3558
	cmp   cl,255
3568
	cmp   cl,255
Line 3627... Line 3637...
3627
	dec  esi
3637
	dec  esi
3628
	jnz  newp_1
3638
	jnz  newp_1
3629
	ret
3639
	ret
Line 3630... Line 3640...
3630
 
3640
 
3631
align 16
3641
align 16
3632
dither_2: ; Burkers algoritm
3642
dither_2: ; Burkes algorithm
3633
newp_2:   ; Dithering cycle
3643
newp_2:   ; Dithering cycle
3634
	xor   ebx,ebx ; At first threshold
3644
	xor   ebx,ebx ; At first threshold
3635
	movsx ecx,byte[edi]
3645
	movsx ecx,byte[edi]
3636
	cmp   cl,255
3646
	cmp   cl,255
Line 3740... Line 3750...
3740
	dec   esi
3750
	dec   esi
3741
	jnz   newp_2
3751
	jnz   newp_2
3742
	ret
3752
	ret
Line -... Line 3753...
-
 
3753
 
-
 
3754
 
-
 
3755
align 16
-
 
3756
dither_3:                        ; Heavyiron_mod algorithm
-
 
3757
 newp_3:                         ; Dithering cycle
-
 
3758
    xor   ebx,ebx                ; At first threshold
-
 
3759
    movzx ecx,byte[edi]
-
 
3760
    cmp   cl,255
-
 
3761
    je   .next
-
 
3762
    test  cl,cl
-
 
3763
    jz    .next
-
 
3764
    jns   @f
-
 
3765
    dec   ebx
-
 
3766
    sub   ecx,255
-
 
3767
  @@:
-
 
3768
    mov   [edi],bl               ; putpixel
-
 
3769
 
-
 
3770
    sar   ecx,2                  ; error/4
-
 
3771
 
-
 
3772
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
-
 
3773
    add   eax,ecx                ; add error/4 to (x+1;y)
-
 
3774
    jge   @f                     ; check_overflow
-
 
3775
    xor   eax,eax
-
 
3776
    jmp   .ok
-
 
3777
  @@:
-
 
3778
    cmp   eax,255
-
 
3779
    jle   .ok
-
 
3780
    or    al,255
-
 
3781
  .ok:
-
 
3782
    mov   [edi+3],al             ; putpixel
-
 
3783
 
-
 
3784
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
-
 
3785
    add   eax,ecx                ; add error/4 to (x-1;y+1)
-
 
3786
    jge   @f                     ; check_overflow
-
 
3787
    xor   eax,eax
-
 
3788
    jmp   .ok1
-
 
3789
  @@:
-
 
3790
    cmp   eax,255
-
 
3791
    jle   .ok1
-
 
3792
    or    al,255
-
 
3793
  .ok1:
-
 
3794
    mov   [edi+edx-3],al         ; putpixel
-
 
3795
 
-
 
3796
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
-
 
3797
    add   eax,ecx                ; add error/4 to (x;y+1)
-
 
3798
    jge   @f                     ; check_overflow
-
 
3799
    xor   eax,eax
-
 
3800
    jmp   .ok2
-
 
3801
  @@:
-
 
3802
    cmp   eax,255
-
 
3803
    jle   .ok2
-
 
3804
    or    al,255
-
 
3805
  .ok2:
-
 
3806
    mov   [edi+edx],al           ; putpixel
-
 
3807
 
-
 
3808
  .next:
-
 
3809
    inc   edi
-
 
3810
    dec   esi
-
 
3811
    jnz   newp_3
-
 
3812
    ret
-
 
3813
 
-
 
3814
align 16
-
 
3815
dither_4:                        ; Atkinson algorithm
-
 
3816
 newp_4:                         ; Dithering cycle
-
 
3817
 
-
 
3818
    xor   ebx,ebx                ; At first threshold
-
 
3819
    movsx ecx,byte[edi]
-
 
3820
    cmp   cl,255
-
 
3821
    je   .next
-
 
3822
    test  cl,cl
-
 
3823
    jz    .next
-
 
3824
    jns   @f
-
 
3825
    dec   ebx
-
 
3826
  @@:
-
 
3827
    mov   [edi],bl               ; putpixel
-
 
3828
 
-
 
3829
    sar   ecx,3                  ; error/8
-
 
3830
 
-
 
3831
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
-
 
3832
    add   eax,ecx                ; add error/8 to (x+1;y)
-
 
3833
    jge   @f                     ; check_overflow
-
 
3834
    xor   eax,eax
-
 
3835
    jmp   .ok
-
 
3836
  @@:
-
 
3837
    cmp   eax,255
-
 
3838
    jle   .ok
-
 
3839
    or    al,255
-
 
3840
  .ok:
-
 
3841
    mov   [edi+3],al             ; putpixel
-
 
3842
 
-
 
3843
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
-
 
3844
    add   eax,ecx                ; add error/8 to (x;y+1)
-
 
3845
    jge   @f                     ; check_overflow
-
 
3846
    xor   eax,eax
-
 
3847
    jmp   .ok1
-
 
3848
  @@:
-
 
3849
    cmp   eax,255
-
 
3850
    jle   .ok1
-
 
3851
    or    al,255
-
 
3852
  .ok1:
-
 
3853
    mov   [edi+edx],al           ; putpixel
-
 
3854
 
-
 
3855
    movzx eax,byte[edi+6]        ; pixel (x+2;y)
-
 
3856
    add   eax,ecx                ; add error/8 to (x+2;y)
-
 
3857
    jge   @f                     ; check_overflow
-
 
3858
    xor   eax,eax
-
 
3859
    jmp   .ok2
-
 
3860
  @@:
-
 
3861
    cmp   eax,255
-
 
3862
    jle   .ok2
-
 
3863
    or    al,255
-
 
3864
  .ok2:
-
 
3865
    mov   [edi+6],al             ; putpixel
-
 
3866
 
-
 
3867
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
-
 
3868
    add   eax,ecx                ; add error/8 to (x-1;y+1)
-
 
3869
    jge   @f                     ; check_overflow
-
 
3870
    xor   eax,eax
-
 
3871
    jmp   .ok3
-
 
3872
  @@:
-
 
3873
    cmp   eax,255
-
 
3874
    jle   .ok3
-
 
3875
    or    al,255
-
 
3876
  .ok3:
-
 
3877
    mov   [edi+edx-3],al         ; putpixel
-
 
3878
 
-
 
3879
    movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
-
 
3880
    add   eax,ecx                ; add error/8 to (x+1;y+1)
-
 
3881
    jge   @f                     ; check_overflow
-
 
3882
    xor   eax,eax
-
 
3883
    jmp   .ok4
-
 
3884
  @@:
-
 
3885
    cmp   eax,255
-
 
3886
    jle   .ok4
-
 
3887
    or    al,255
-
 
3888
  .ok4:
-
 
3889
    mov   [edi+edx+3],al         ; putpixel
-
 
3890
 
-
 
3891
 
-
 
3892
    movzx eax,byte[edi+edx+edx]    ; pixel (x;y+2)
-
 
3893
    add   eax,ecx                ; add error/8 to (x;y+2)
-
 
3894
    jge   @f                     ; check_overflow
-
 
3895
    xor   eax,eax
-
 
3896
    jmp   .ok5
-
 
3897
  @@:
-
 
3898
    cmp   eax,255
-
 
3899
    jle   .ok5
-
 
3900
    or    al,255
-
 
3901
  .ok5:
-
 
3902
    mov   [edi+edx+edx],al         ; putpixel
-
 
3903
 
-
 
3904
  .next:
-
 
3905
    inc   edi
-
 
3906
    dec   esi
-
 
3907
    jnz   newp_4
Line 3743... Line 3908...
3743
 
3908
    ret