Sub Pixelate(B0 As Bitmap) 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