Sub GetBitmapFromPanel(ScrSource As Panel, WriteToFile As Boolean) As Bitmap
Dim StrMethod As String = "Sub GetBitmapFromPanel(ScrSource As Panel) As Bitmap"
Dim IntWidth As Int = ScrSource.Width
Dim IntHeight As Int = ScrSource.Height
Return GetBitmapFromView(IntWidth, IntHeight, ScrSource, WriteToFile)
End Sub
Sub GetBitmapFromScrollView2D(ScrSource As ScrollView2D, WriteToFile As Boolean) As Bitmap
Dim StrMethod As String = "Sub GetBitmapFromScrollView2D(ScrSource As ScrollView2D) As Bitmap"
Dim IntWidth As Int = ScrSource.Panel.Width
Dim IntHeight As Int = ScrSource.Panel.Height
Return GetBitmapFromView(IntWidth, IntHeight, ScrSource, WriteToFile)
End Sub
Sub GetBitmapFromHorizontalScrollView(ScrSource As HorizontalScrollView, WriteToFile As Boolean) As Bitmap
Dim StrMethod As String = "Sub GetBitmapFromHorizontalScrollView(ScrSource As HorizontalScrollView) As Bitmap"
Dim IntWidth As Int = ScrSource.Panel.Width
Dim IntHeight As Int = ScrSource.Height
Return GetBitmapFromView(IntWidth, IntHeight, ScrSource, WriteToFile)
End Sub
Sub GetBitmapFromScrollView(ScrSource As ScrollView, WriteToFile As Boolean) As Bitmap
Dim StrMethod As String = "Sub GetBitmapFromScrollView(ScrSource As ScrollView) As Bitmap"
Dim IntWidth As Int = ScrSource.Width
Dim IntHeight As Int = ScrSource.Panel.Height
Return GetBitmapFromView(IntWidth, IntHeight, ScrSource, WriteToFile)
End Sub
Sub GetBitmapFromView(IntWidth As Int, IntHeight As Int, ScrSource As View, WriteToFile As Boolean) As Bitmap
Dim StrMethod As String = "Sub GetBitmapFromView(IntWidth as Int, IntHeight as Int, ScrSource As View) As Bitmap"
Dim BmpResult As Bitmap = Null
Try
Dim Bmp As Bitmap
Bmp.InitializeMutable(IntWidth, IntHeight)
Dim Cnv As Canvas
Cnv.Initialize2(Bmp)
Dim Rfl As Reflector
Rfl.Target = Cnv
Dim AryObjectRef(1) As Object
AryObjectRef = Array As Object (Rfl.GetField("canvas"))
Dim AryObjectTypeRef(1) As String
AryObjectTypeRef = Array As String ("android.graphics.Canvas")
Dim RftView As Reflector
RftView.Target = ScrSource
RftView.RunMethod4("draw", AryObjectRef, AryObjectTypeRef)
BmpResult = Bmp
If WriteToFile Then
Dim now As Long
Dim dt As String
DateTime.DateFormat = "yyMMddHHmmss"
now = DateTime.now
dt = DateTime.Date(now) ' e.g.: "110812150355" is Aug.12, 2011, 3:03:55 p.m.
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, cDatabase.DatabasePath(False) &dt & ".png", False)
Bmp.WriteToStream(Out, 100, "PNG")
Out.Close
End If
Catch
'CdException.Show(StrClass, StrMethod, LastException)
End Try
Return BmpResult
End Sub