I have tried saving as a screenshot with this code which I know works elsewhere in the program
However with the charts I am playing around with I just get a black screen. The charts show on the screen ok. The relevant code is just putting a chart on the activity screen
Can anyone advise how I maight save the graphs? Sometimes I may have a bar chart on the screen as well as a pie chart
TIA for any replies
B4X:
'Public Sub CaptureScreen( act As Activity, dir As String, fileName As String)
Public Sub CaptureScreen(dir As String, fileName As String)
Dim Obj1, Obj2 As Reflector
Dim bmp As Bitmap
Dim c As Canvas
Obj1.Target = Obj1.GetActivityBA
Obj1.Target = Obj1.GetField("vg")
bmp.InitializeMutable(Activity.Width, Activity.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)
Dim Out As OutputStream
Out = File.OpenOutput( dir, fileName, False)
Dim fmt As String = "PNG"
If fileName.ToUpperCase.Contains("JPG") Then fmt = "JPEG"
If fileName.ToUpperCase.Contains("JPEG") Then fmt = "JPEG"
bmp.WriteToStream(Out, 100, fmt)
Out.Close
End Sub
However with the charts I am playing around with I just get a black screen. The charts show on the screen ok. The relevant code is just putting a chart on the activity screen
B4X:
pv1.Initialize("pv1")
Activity.Color=Colors.black
Activity.AddView(pv1, -1%x, 1%y, 60%y, 60%y)
Dim piedata() As Float = Array As Float(35, 65)
pv1.Data = piedata
Dim piecolors() As Int = Array As Int(Colors.green, Colors.Blue)
pv1.PieColors = piecolors
pv1.ShowPercentLabel = True
pv1.BringToFront
Can anyone advise how I maight save the graphs? Sometimes I may have a bar chart on the screen as well as a pie chart
TIA for any replies