Android Question Snapshot of panel

Discussion in 'Android Questions' started by Almog, Sep 11, 2018.

  1. Almog

    Almog Active Member Licensed User

    Hello,

    I used erel solution for snapshot an item (for example - panel) - (https://www.b4x.com/android/forum/threads/save-only-the-image-inside-the-panel.92333/#post-583937)

    Code:
    Sub Button1_Click
        
        
    Dim bmp As B4XBitmap = Crop_Image(Panel1, Panel1.left, Panel1.top, Panel1.width, Panel1.height )
        
    Dim out As OutputStream
        out = 
    File.OpenOutput(File.DirInternal, "1.png"False)
        bmp.WriteToStream(out, 
    100"PNG")
        out.Close
        
    End Sub

    Sub Crop_Image(V As B4XView, left As Int, top As Int, width As Int, height As Int) As Bitmap
        
        
    Return V.Snapshot.Crop(left, top, width, height)
        
    End Sub
    But the image saved is null - white picture only.

    Does anyone know what is the problem and how to fix it?

    Thanks in advance
     
  2. ilan

    ilan Expert Licensed User

    Because V is Panel1 you should set 0 for left and 0 for top!
    Code:
    Dim bmp As B4XBitmap = Crop_Image(Panel1, 00, Panel1.width, Panel1.height )
     
  3. Almog

    Almog Active Member Licensed User

    Thank you.
     
  4. ilan

    ilan Expert Licensed User

    btw if you want to get a screenshot of the whole panel you dont need to crop it. just use:

    Code:
    Dim Out As OutputStream
    Out = 
    File.OpenOutput(File.DirInternal, "Test.png"False)
    p.Snapshot.WriteToStream(Out, 
    100"PNG")
    Out.Close
    you can use directly the p.snapshot feature as the b4xbitmap and save it to a file.
     
    Jeffrey Cameron and JordiCP like this.
  5. Almog

    Almog Active Member Licensed User

    Thank you very much, I will try it :).
     
  6. Almog

    Almog Active Member Licensed User

    Hi Ilan,

    Thanks for the help, but these 2 solutions are not working either, same result...

    Thanks in advance.
     
  7. Almog

    Almog Active Member Licensed User

    Hi Ilan,

    Thanks for the help, but these 2 solutions are not working either, same result...

    Thanks in advance.
     
  8. ilan

    ilan Expert Licensed User

    You should post a simple project example with your code so we can see what is not working. We cannot help you without seeing what yoi are doing in your code.
     
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