I am using this example found in the forum:
(Note: the code below has been fixed and now works)
The activity background, labels background and spinners backgrounds are transparent. Even worse, the spinners have the default white font intended for a black background and are totally unreadable. The labels have grey text color and are readable, albeit not easily. The buttons and I have a picture that are also correctly represented.
What can I do to have a screenshot with the same background as the screen?
(Note: the code below has been fixed and now works)
B4X:
Sub TakeScreenshot
Log( "TakeScreenshot activated" )
' Take a screenshot.
Dim Obj1, Obj2 As Reflector
Dim bmp As Bitmap
Dim c As Canvas
Dim now As Long
Dim dt As String
DateTime.DateFormat = "dd-MMM-yyyy HH:mm:ss"
now = DateTime.now
dt = DateTime.date( now )
Activity.Color = Colors.Black ' added this line
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
ScreenShotFolder = Starter.DownloadPath ' replace with your path
ScreenShotFile = dt & ".png"
Out = File.OpenOutput( ScreenShotFolder, ScreenShotFile, False )
bmp.WriteToStream( Out, 100, "PNG" )
Out.close
ToastMessageShow( "Screenshot Captured", False )
End Sub
The activity background, labels background and spinners backgrounds are transparent. Even worse, the spinners have the default white font intended for a black background and are totally unreadable. The labels have grey text color and are readable, albeit not easily. The buttons and I have a picture that are also correctly represented.
What can I do to have a screenshot with the same background as the screen?
Attachments
Last edited: