Hi
Here is source code to pixelate bitmaps that I got here in B4a.
I kindly need similar for my b4i app.
Can someone please help.
Thanks in advance
Here is source code to pixelate bitmaps that I got here in B4a.
B4X:
Sub PixelateBitMap(B0 As Bitmap, factor As Float) As Bitmap
'Dim factor As Float=8 'Change it to get different pixellations
Dim new_w As Int = B0.Width/factor
Dim new_h As Int = B0.Height/factor
If new_w>=1 And new_h>=1 Then
'Draw the original onto a smaller one
Dim B_small As Bitmap
B_small.InitializeMutable(new_w,new_h)
Dim cv As Canvas
cv.Initialize2(B_small)
Dim DestRect As Rect
DestRect.Initialize(0,0,B_small.Width,B_small.Height)
cv.DrawBitmap(B0,Null,DestRect)
'Create a new bitmap wth the same dimensions as the original
Dim B_pixelated As Bitmap
B_pixelated.initializemutable(B0.width,B0.Height)
cv.Initialize2(B_pixelated)
Dim DestRect As Rect
DestRect.Initialize(0,0,B_pixelated.Width,B_pixelated.Height)
cv.DrawBitmap(B_small,Null,DestRect)
Return B_pixelated
Else
Return B0
End If
End Sub
I kindly need similar for my b4i app.
Can someone please help.
Thanks in advance