Using that code, I asked an AI how to save the result. I got this result which works:
B4J screenshot:
Sub SaveSnapshot
' Take a snapshot of the RootPane
Dim bmp As B4XBitmap = MainForm.RootPane.As(B4XView).Snapshot
' Open an output stream to save the image
Dim out As OutputStream
out = File.OpenOutput(File.DirApp, "screenshot.png", False)
' Save the snapshot as a PNG file
bmp.WriteToStream(out, 100, "PNG")
' Close the output stream
out.Close
Log("Screenshot saved as screenshot.png in the application directory.")
End Sub
Hi LucaMs. No worries. Thank you for the reply. You got me going in the right direction. I wanted to post the whole code for this for newbies who read this later.