B4J Question [ABMaterial] ABMCanvas - save as image

Harris

Expert
Licensed User
Longtime User
https://www.b4x.com/android/forum/t...to-save-the-canvas-as-jpg-file.75218/#content
Similar post above with problem...

https://www.b4x.com/android/forum/threads/abmaterial-barchart.85293/

Creating charts with canvas is fast and easy - as in above link and my own results.

However, there isn't a Snapshot method in ABMCanvas as there is with the B4J canvas...
I need to create a chart, save it to an image and then add the image as a blob (image type) in a MySQL table.

Why? Because this is the work around I need to perform in order to produce a jNextReport with an image... (been there - done that...).

Can I use the standard canvas in my ABM projects (requires jFX lib to be linked in) to do the same (has snapshot) - or is there some other trick I can apply to achieve the same result.

I don't need to "view" the canvas - just save it to an image...

Thanks

B4X:
' jFX canvas...
 Dim Image1 As Image = BD.Canvas.Snapshot
    Dim Out As OutputStream = File.OpenOutput(File.DirApp,  "sample.png", False)
    Image1.WriteToStream(Out)
    Out.Close
 

Harris

Expert
Licensed User
Longtime User
Since I did not want to include jFX in my ABM app (no response whether any harm or foul), I created another (UI) app for the sole purpose of using a canvas to create a chart. I have found you need a form (thus UI app) to create a canvas object - or you get canvas not initialized when running it...

Within the ABM app, I call the chart app with jshell and when it returns in the ProcessCompleted event, I carry on with generating the final report which includes the chart.

Cat-skinnin again.... There is always a way.
 
Upvote 0
Top