سلام
در اینجا میخوام به شما آموزش بدم که چگونه یک عکس رو تار کنید
برای این کار ابتدا کد زیر رو به اکتیویتون اضافه کنید
Private Sub Blur (bmp As B4XBitmap) As B4XBitmap
Dim n As Long = DateTime.Now
Dim bc As BitmapCreator
Dim ReduceScale As Int = 2
bc.Initialize(bmp.Width / ReduceScale / bmp.Scale, bmp.Height / ReduceScale / bmp.Scale)
bc.CopyPixelsFromBitmap(bmp)
Dim count As Int = 3
Dim clrs(3) As ARGBColor
Dim temp As ARGBColor
Dim m As Int
For steps = 1 To count
For y = 0 To bc.mHeight - 1
For x = 0 To 2
bc.GetARGB(x, y, clrs(x))
Next
SetAvg(bc, 1, y, clrs, temp)
m = 0
For x = 2 To bc.mWidth - 2
bc.GetARGB(x + 1, y, clrs(m))
m = (m + 1) Mod clrs.Length
SetAvg(bc, x, y, clrs, temp)
Next
Next
For x = 0 To bc.mWidth - 1
For y = 0 To 2
bc.GetARGB(x, y, clrs(y))
Next
SetAvg(bc, x, 1, clrs, temp)
m = 0
For y = 2 To bc.mHeight - 2
bc.GetARGB(x, y + 1, clrs(m))
m = (m + 1) Mod clrs.Length
SetAvg(bc, x, y, clrs, temp)
Next
Next
Next
Log(DateTime.Now - n)
Return bc.Bitmap
End Sub
Private Sub SetAvg(bc As BitmapCreator, x As Int, y As Int, clrs() As ARGBColor, temp As ARGBColor)
temp.Initialize
For Each c As ARGBColor In clrs
temp.r = temp.r + c.r
temp.g = temp.g + c.g
temp.b = temp.b + c.b
Next
temp.a = 255
temp.r = temp.r / clrs.Length
temp.g = temp.g / clrs.Length
temp.b = temp.b / clrs.Length
bc.SetARGB(x, y, temp)
End Sub
هر کجا هم که خواستید استفاده کنید این کد رو بگذارید و به جای ایمج ویو ۱ اسم ایمیج ویوی خودتون رو بگذارید
Dim bmp As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "bas-van-brandwijk-588535-unsplash.jpg", ImageView1.Width, ImageView1.Height, True) ImageView1.SetBitmap(Blur(bmp))
