Sub FitCenterBitmap(Imv As ImageView, Dir As String, FileName As String)
Private bmp As Bitmap = LoadBitmapSample(Dir, FileName, 32dip,32dip)'LoadBitmapResize(Dir, FileName, 35dip,35dip ,True)
Private cvs As Canvas
cvs.Initialize(Imv)
Dim rectDest As Rect
Dim delta As Int
If bmp.Width / bmp.Height > Imv.Width / Imv.Height Then
delta = (Imv.Height - bmp.Height / bmp.Width * Imv.Width) / 2
rectDest.Initialize(0, delta,Imv.Width, Imv.Height - delta)
Else
delta = (Imv.Width - bmp.Width / bmp.Height * Imv.Height) / 2
rectDest.Initialize(delta, 0, Imv.Width - delta, Imv.Height)
End If
cvs.DrawBitmap(bmp, Null, rectDest)
Imv.Invalidate
Dim jo = bmp As JavaObject
jo.RunMethod("recycle", Null)
End Sub