Android Question Taking a screenshot of whole (scrollable) panel.

Discussion in 'Android Questions' started by Kapelis, Feb 3, 2015.

Similar threads

B4A Code Snippet Capture complete Panel to imageview
B4A Code Snippet isSystemapp
B4A Code Snippet Get List Of Installed Apps and their icons
B4A Question Panel/Layout to Image
B4A Question Screenshot / Picture
  1. Kapelis

    Kapelis Member Licensed User

    Hi, I'm trying to make a screenshot of my app, I have followed the example in the beginners guide and it all works well. I modified the code to get a screenshot of the whole panel but the photo is "cropped" at some point and the rest (bottom) of the picture is black. Can anyone help? thank you very much.
    Code:
    Sub btnShare_Click
    ' Take a screenshot.
      Dim Obj1, Obj2 As Reflector
      
    Dim bmp As Bitmap
      
    Dim C As Canvas
      Obj1.Target = Obj1.GetActivityBA
      Obj1.Target = Obj1.GetField(
    "vg")
      
    'bmp.InitializeMutable(Activity.Width, Activity.Height)
      bmp.InitializeMutable(Panel1.Width, Panel1.Height)
      C.Initialize2(bmp)
      
    Dim args(1As Object
      
    Dim types(1As 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
      Out = 
    File.OpenOutput(File.DirRootExternal, "Aldrete score" & ".png"False)
      bmp.WriteToStream(Out, 
    100"PNG")
      Out.Close
     
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You are still drawing the activity.
    Try to change to Obj1.Target = Panel1 (I assume that Panel1 is the ScrollView inner panel).
     
    Kapelis likes this.
  3. Kapelis

    Kapelis Member Licensed User

    Works perfectly, thank you very much!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice