B4J Question Is there a way to make B4J take a screenshot?

Tim Chapman

Active Member
Licensed User
Longtime User
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
 
Upvote 0
Top