Android Question B4X Preference Dialog take a snapshot of a whole inside display panel

mike1967

Active Member
Licensed User
Longtime User
Hello, Is possible to take a snapshot of a whole inside display panel of a B4X Preference Dialog ? Thanks in Advances
 

Mahares

Expert
Licensed User
Longtime User
Is possible to take a snapshot of a whole inside display panel of a B4X Preference Dialog

I think it is something like this, but don't take to the bank yet until Erel or someone more knowledgeable verifies ir or come up with a better one:
B4X:
If Result = xui.DialogResponse_Positive Then
        Dim b As B4XBitmap = prefdialog.mBase.Snapshot
        Activity.SetBackgroundImage(b) 'here I am using a default project. You can apply to a B4XPages project
        Log("snapshot taken")
 
Upvote 0

mike1967

Active Member
Licensed User
Longtime User
I think it is something like this, but don't take to the bank yet until Erel or someone more knowledgeable verifies ir or come up with a better one:
B4X:
If Result = xui.DialogResponse_Positive Then
        Dim b As B4XBitmap = prefdialog.mBase.Snapshot
        Activity.SetBackgroundImage(b) 'here I am using a default project. You can apply to a B4XPages project
        Log("snapshot taken")
i use this code:
code:
Dim pdf As PdfDocument
    pdf.Initialize
    pdf.StartPage(595, 842) 'A4 size
    'PrefDialog.CustomListView1.sv.ScrollViewInnerPanel.Height=100%y
    Dim bmp As B4XBitmap = PrefDialog.CustomListView1.sv.ScrollViewInnerPanel.Snapshot
    Dim dest As Rect
    Dim w As Int = bmp.Width / bmp.Scale*0.8
    Dim h As Int = bmp.Height / bmp.Scale*0.8
    dest.Initialize((595-w)/2, 10, 0, 0)
    dest.Width = bmp.Width / bmp.Scale*0.8
    dest.Height = bmp.Height / bmp.Scale*0.8
    pdf.Canvas.DrawBitmap(bmp, Null, dest)
    pdf.FinishPage
    Dim out As OutputStream = File.OpenOutput(provider.SharedFolder, "snapshot.pdf", False)
    pdf.WriteToStream(out)
    out.Close
    pdf.Close
        
    Dim in As Intent
    in.Initialize(in.ACTION_VIEW, "")
    provider.SetFileUriAsIntentData(in, "snapshot.pdf")
    in.SetType("application/pdf")
    StartActivity(in)

But the image is truncated in height , i need a whole snapshot (there are more Prefdialogs items)
 
Upvote 0
Top