Wait For (TakeAScreenShot(MainPanel,"ResultsInThisImage")) Complete (Result As Bitmap)
imgGame.Bitmap=Result
'Or
'imgGame.Bitmap = LoadBitmap(GetDataFolder, "ResultsInThisImage.png")
Sub TakeAScreenShot(pnl As Panel, bmpFileName As String) As ResumableSub
' Take a screenshot.
'Depends on: Reflector, JavaObject
Dim Obj1, Obj2 As Reflector
Dim bmp As Bitmap
Dim C As Canvas
Obj1.Target = pnl
bmp.InitializeMutable(pnl.Width, pnl.Height)
C.Initialize2(bmp)
Dim args(1) As Object
Dim types(1) As String
Obj2.Target = C
Obj2.Target = Obj2.GetField("canvas")
args(0) = Obj2.Target
types(0) = "android.graphics.Canvas"
Obj1.RunMethod4("draw", args, types)
If bmpFileName.Length>0 Then
Dim Out As OutputStream
Out = File.OpenOutput(GetDataFolder, bmpFileName.Trim & ".png", False)
bmp.WriteToStream(Out, 100, "PNG")
Out.Close
End If
Return bmp
End Sub