Subversion Repositories Kolibri OS

Rev

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

Rev 3040 Rev 3105
Line 3449... Line 3449...
3449
 
3449
 
3450
	popad
3450
	popad
3451
	ret
3451
	ret
Line -... Line 3452...
-
 
3452
endp
-
 
3453
 
-
 
3454
;䨫ìâ¥à
-
 
3455
align 4
-
 
3456
proc buf_filter_dither, buffer:dword, algor:dword
-
 
3457
	pushad
-
 
3458
	mov edi,[buffer]
-
 
3459
	cmp buf2d_bits,24
-
 
3460
	jne .error
-
 
3461
		mov edx,buf2d_w
-
 
3462
		mov esi,buf2d_h
-
 
3463
		mov edi,buf2d_data
-
 
3464
;edi - pointer to 24bit bitmap
-
 
3465
;edx - x size
-
 
3466
;esi - y size
-
 
3467
		lea   edx,[edx*3]
-
 
3468
		imul  esi,edx
-
 
3469
 
-
 
3470
		;®¯à¥¤¥«ï¥¬ ª ª®©  «£®à¨â¬ ¨á¯®«ì§®¢ âì
-
 
3471
		cmp dword[algor],0
-
 
3472
		jne @f
-
 
3473
			call dither_0
-
 
3474
			jmp .dither_end
-
 
3475
		@@:
-
 
3476
		cmp dword[algor],1
-
 
3477
		jne @f
-
 
3478
			call dither_1
-
 
3479
			jmp .dither_end
-
 
3480
		@@:
-
 
3481
		call dither_2
-
 
3482
		jmp .dither_end
-
 
3483
	.error:
-
 
3484
		stdcall print_err,sz_buf2d_filter_dither,txt_err_n24b
-
 
3485
	.dither_end:
-
 
3486
	popad
-
 
3487
	ret
-
 
3488
endp
-
 
3489
 
-
 
3490
align 16
-
 
3491
dither_0: ; Sierra Filter Lite algoritm
-
 
3492
newp_0:   ; Dithering cycle
-
 
3493
	xor   ebx,ebx ; At first threshold
-
 
3494
	movzx ecx,byte[edi]
-
 
3495
	cmp   cl,255
-
 
3496
	je    newp_0.next
-
 
3497
	test  cl,cl
-
 
3498
	jz    newp_0.next
-
 
3499
	jns   @f
-
 
3500
	dec   ebx
-
 
3501
	sub   ecx,255
-
 
3502
@@:
-
 
3503
	mov   [edi],bl               ; putpixel
-
 
3504
 
-
 
3505
	sar   ecx,1                  ; error/2
-
 
3506
	;adc   ecx,0                  ; round to integer
-
 
3507
 
-
 
3508
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
-
 
3509
	add   eax,ecx                ; add error/2 to (x+1;y)
-
 
3510
	jge   @f                     ; check_overflow
-
 
3511
	xor   eax,eax
-
 
3512
	jmp   .ok
-
 
3513
@@:
-
 
3514
	cmp   eax,255
-
 
3515
	jle   .ok
-
 
3516
	or    al,255
-
 
3517
.ok:
-
 
3518
	mov   [edi+3],al             ; putpixel
-
 
3519
 
-
 
3520
	sar   ecx,1                  ; error/4
-
 
3521
	adc   ecx,0                  ; round to integer
-
 
3522
 
-
 
3523
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
-
 
3524
	add   eax,ecx                ; add error/4 to (x-1;y+1)
-
 
3525
	jge   @f                     ; check_overflow
-
 
3526
	xor   eax,eax
-
 
3527
	jmp   .ok1
-
 
3528
@@:
-
 
3529
	cmp   eax,255
-
 
3530
	jle   .ok1
-
 
3531
	or    al,255
-
 
3532
.ok1:
-
 
3533
	mov   [edi+edx-3],al         ; putpixel
-
 
3534
 
-
 
3535
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
-
 
3536
	add   eax,ecx                ; add error/4 to (x;y+1)
-
 
3537
	jge   @f                     ; check_overflow
-
 
3538
	xor   eax,eax
-
 
3539
	jmp   .ok2
-
 
3540
@@:
-
 
3541
	cmp   eax,255
-
 
3542
	jle   .ok2
-
 
3543
	or    al,255
-
 
3544
.ok2:
-
 
3545
	mov   [edi+edx],al           ; putpixel
-
 
3546
 
-
 
3547
.next:
-
 
3548
	inc   edi
-
 
3549
	dec   esi
-
 
3550
	jnz   newp_0
-
 
3551
	ret
-
 
3552
 
-
 
3553
align 16
-
 
3554
dither_1: ; Floyd-Steinberg algoritm
-
 
3555
newp_1:   ; Dithering cycle
-
 
3556
	xor   ebx,ebx ; At first threshold
-
 
3557
	movzx ecx,byte[edi]
-
 
3558
	cmp   cl,255
-
 
3559
	je    newp_1.next
-
 
3560
	test  cl,cl
-
 
3561
	jz    newp_1.next
-
 
3562
	jns   @f
-
 
3563
	dec   ebx
-
 
3564
	sub   ecx,255
-
 
3565
@@:
-
 
3566
	mov   [edi],bl               ; putpixel
-
 
3567
 
-
 
3568
	sar   ecx,4                  ; error/16
-
 
3569
	adc   ecx,0                  ; round to integer
-
 
3570
	mov   ebx,ecx
-
 
3571
 
-
 
3572
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
-
 
3573
	add   eax,ecx                ; add error/16 to (x+1;y+1)
-
 
3574
	jge   @f                     ; check_overflow
-
 
3575
	xor   eax,eax
-
 
3576
	jmp   .ok
-
 
3577
@@:
-
 
3578
	cmp   eax,255
-
 
3579
	jle   .ok
-
 
3580
	or    al,255
-
 
3581
.ok:
-
 
3582
	mov   [edi+edx+3],al         ;putpixel
-
 
3583
 
-
 
3584
	imul  ecx,3
-
 
3585
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
-
 
3586
	add   eax,ecx                ; add 3*error/16 to (x-1;y+1)
-
 
3587
	jge   @f                     ; check_overflow
-
 
3588
	xor   eax,eax
-
 
3589
	jmp   .ok1
-
 
3590
@@:
-
 
3591
	cmp   eax,255
-
 
3592
	jle   .ok1
-
 
3593
	or    al,255
-
 
3594
.ok1:
-
 
3595
	mov   [edi+edx-3],al         ;putpixel
-
 
3596
 
-
 
3597
	mov   ecx,ebx
-
 
3598
	imul  ecx,5
-
 
3599
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
-
 
3600
	add   eax,ecx                ; add 5*error/16 to (x;y+1)
-
 
3601
	jge   @f                     ; check_overflow
-
 
3602
	xor   eax,eax
-
 
3603
	jmp   .ok2
-
 
3604
@@:
-
 
3605
	cmp   eax,255
-
 
3606
	jle   .ok2
-
 
3607
	or    al,255
-
 
3608
.ok2:
-
 
3609
	mov   [edi+edx],al           ;putpixel
-
 
3610
 
-
 
3611
	mov   ecx,ebx
-
 
3612
	imul  ecx,7
-
 
3613
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
-
 
3614
	add   eax,ecx                ; add 7*error/16 to (x+1;y)
-
 
3615
	jge   @f                     ; check_overflow
-
 
3616
	xor   eax,eax
-
 
3617
	jmp   .ok3
-
 
3618
@@:
-
 
3619
	cmp   eax,255
-
 
3620
	jle   .ok3
-
 
3621
	or    al,255
-
 
3622
.ok3:
-
 
3623
	mov   [edi+3],al             ;putpixel
-
 
3624
 
-
 
3625
.next:
-
 
3626
	inc  edi
-
 
3627
	dec  esi
-
 
3628
	jnz  newp_1
-
 
3629
	ret
-
 
3630
 
-
 
3631
align 16
-
 
3632
dither_2: ; Burkers algoritm
-
 
3633
newp_2:   ; Dithering cycle
-
 
3634
	xor   ebx,ebx ; At first threshold
-
 
3635
	movsx ecx,byte[edi]
-
 
3636
	cmp   cl,255
-
 
3637
	je    newp_2.next
-
 
3638
	test  cl,cl
-
 
3639
	jz    newp_2.next
-
 
3640
	jns   @f
-
 
3641
	dec   ebx
-
 
3642
@@:
-
 
3643
	mov   [edi],bl               ; putpixel
-
 
3644
 
-
 
3645
	sar   ecx,2                  ; error/4
-
 
3646
	adc   ecx,0                  ; round to integer
-
 
3647
 
-
 
3648
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
-
 
3649
	add   eax,ecx                ; add error/4 to (x+1;y)
-
 
3650
	jge   @f                     ; check_overflow
-
 
3651
	xor   eax,eax
-
 
3652
	jmp   .ok
-
 
3653
@@:
-
 
3654
	cmp   eax,255
-
 
3655
	jle   .ok
-
 
3656
	or    al,255
-
 
3657
.ok:
-
 
3658
	mov   [edi+3],al             ; putpixel
-
 
3659
 
-
 
3660
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
-
 
3661
	add   eax,ecx                ; add error/4 to (x;y+1)
-
 
3662
	jge   @f                     ; check_overflow
-
 
3663
	xor   eax,eax
-
 
3664
	jmp   .ok1
-
 
3665
@@:
-
 
3666
	cmp   eax,255
-
 
3667
	jle   .ok1
-
 
3668
	or    al,255
-
 
3669
.ok1:
-
 
3670
	mov   [edi+edx],al           ; putpixel
-
 
3671
 
-
 
3672
	sar   ecx,1                  ; error/8
-
 
3673
	adc   ecx,0                  ; round to integer
-
 
3674
 
-
 
3675
	movzx eax,byte[edi+6]        ; pixel (x+2;y)
-
 
3676
	add   eax,ecx                ; add error/8 to (x+2;y)
-
 
3677
	jge   @f                     ; check_overflow
-
 
3678
	xor   eax,eax
-
 
3679
	jmp   .ok2
-
 
3680
@@:
-
 
3681
	cmp   eax,255
-
 
3682
	jle   .ok2
-
 
3683
	or    al,255
-
 
3684
.ok2:
-
 
3685
	mov   [edi+6],al             ; putpixel
-
 
3686
 
-
 
3687
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
-
 
3688
	add   eax,ecx                ; add error/8 to (x-1;y+1)
-
 
3689
	jge   @f                     ; check_overflow
-
 
3690
	xor   eax,eax
-
 
3691
	jmp   .ok3
-
 
3692
@@:
-
 
3693
	cmp   eax,255
-
 
3694
	jle   .ok3
-
 
3695
	or    al,255
-
 
3696
.ok3:
-
 
3697
	mov   [edi+edx-3],al         ; putpixel
-
 
3698
 
-
 
3699
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
-
 
3700
	add   eax,ecx                ; add error/8 to (x+1;y+1)
-
 
3701
	jge   @f                     ; check_overflow
-
 
3702
	xor   eax,eax
-
 
3703
	jmp   .ok4
-
 
3704
@@:
-
 
3705
	cmp   eax,255
-
 
3706
	jle   .ok4
-
 
3707
	or    al,255
-
 
3708
.ok4:
-
 
3709
	mov   [edi+edx+3],al         ; putpixel
-
 
3710
 
-
 
3711
	sar   ecx,1                  ; error/16
-
 
3712
	;adc   ecx,0                  ; round to integer
-
 
3713
 
-
 
3714
	movzx eax,byte[edi+edx-6]    ; pixel (x-2;y+1)
-
 
3715
	add   eax,ecx                ; add error/16 to (x-2;y+1)
-
 
3716
	jge   @f                     ; check_overflow
-
 
3717
	xor   eax,eax
-
 
3718
	jmp   .ok5
-
 
3719
@@:
-
 
3720
	cmp   eax,255
-
 
3721
	jle   .ok5
-
 
3722
	or    al,255
-
 
3723
.ok5:
-
 
3724
	mov   [edi+edx-6],al         ; putpixel
-
 
3725
 
-
 
3726
	movzx eax,byte[edi+edx+6]    ; pixel (x+2;y+1)
-
 
3727
	add   eax,ecx                ; add error/16 to (x+2;y+1)
-
 
3728
	jge   @f                     ; check_overflow
-
 
3729
	xor   eax,eax
-
 
3730
	jmp   .ok6
-
 
3731
@@:
-
 
3732
	cmp   eax,255
-
 
3733
	jle   .ok6
-
 
3734
	or    al,255
-
 
3735
.ok6:
-
 
3736
	mov   [edi+edx+6],al         ; putpixel
-
 
3737
 
-
 
3738
.next:
-
 
3739
	inc   edi
-
 
3740
	dec   esi
-
 
3741
	jnz   newp_2
Line 3452... Line 3742...
3452
endp
3742
	ret
Line 4814... Line 5104...
4814
	dd sz_buf2d_offset_h, buf_offset_h
5104
	dd sz_buf2d_offset_h, buf_offset_h
4815
	dd sz_buf2d_flood_fill, buf_flood_fill
5105
	dd sz_buf2d_flood_fill, buf_flood_fill
4816
	dd sz_buf2d_set_pixel, buf_set_pixel
5106
	dd sz_buf2d_set_pixel, buf_set_pixel
4817
	dd sz_buf2d_get_pixel, buf_get_pixel
5107
	dd sz_buf2d_get_pixel, buf_get_pixel
4818
	dd sz_buf2d_flip_v, buf_flip_v
5108
	dd sz_buf2d_flip_v, buf_flip_v
-
 
5109
	dd sz_buf2d_filter_dither, buf_filter_dither
4819
	dd sz_buf2d_vox_brush_create, vox_brush_create
5110
	dd sz_buf2d_vox_brush_create, vox_brush_create
4820
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
5111
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
4821
	dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
5112
	dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
4822
	dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
5113
	dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
4823
	dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
5114
	dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
Line 4854... Line 5145...
4854
	sz_buf2d_offset_h db 'buf2d_offset_h',0
5145
	sz_buf2d_offset_h db 'buf2d_offset_h',0
4855
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
5146
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
4856
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
5147
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
4857
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
5148
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
4858
	sz_buf2d_flip_v db 'buf2d_flip_v',0
5149
	sz_buf2d_flip_v db 'buf2d_flip_v',0
-
 
5150
	sz_buf2d_filter_dither db 'buf2d_filter_dither',0
4859
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
5151
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
4860
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
5152
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
4861
	sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
5153
	sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
4862
	sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
5154
	sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
4863
	sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
5155
	sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0