Sub ViewToBmp(MyView As View) As Bitmap
' Returns a screenshot of the given view
Dim bmp As Bitmap
bmp.InitializeMutable(MyView.Width, MyView.Height)
C.Initialize2(bmp)
Dim r1 As Reflector
r1.Target = C
r1.Target = r1.GetField("canvas")
Dim r2 As Reflector
Dim args(1) As Object
Dim types(1) As String
args(0) = r1.Target
types(0) = "android.graphics.Canvas"
r2.Target = MyView
r2.RunMethod4("draw", args, types) ' "Draw" renders a view and its children to the given Canvas
Return C.Bitmap
End Sub