B4J Question How to save the chart to image file?

positrom2

Active Member
Licensed User
Longtime User
I am starting with this (it is a revised version of that available in this forum):
http://www.rwblinn.de/b4j/opensource/roavgsplit.zip
The Layout is made with SceneBuilder, and then:
I tried this but it doen't work (file not found error):
B4X:
Sub saveform
Dim Snapshot As Image
Snapshot.initialize("d:\","1.png")
Dim out As OutputStream=File.OpenOutput("d:\","1.png",False)
Snapshot.WriteToStream(out)
out.Close
End Sub
Thank you in advance.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your code is wrong. You are trying to load an image and then save it back.

I'm not familiar with this library. However all nodes have a Snapshot method that returns an image from the node (assuming that the library was built correctly).

For example to save a TableView:
B4X:
Dim out As OutputStream = File.OpenOutput(...)
TableView1.Snapshot.WriteToStream(out)
out.Close
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
That was a close hit...
This does it:
B4X:
Sub savechart
Dim out As OutputStream = File.OpenOutput("d:\","2.png",False)
LineChartXY.Snapshot.WriteToStream(out)
out.Close
End Sub
Thank you.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…