Android Question How to save Label view to transparent bitmap?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I've seen the code to save panel details to an imageview, I'm looking for code to save the contents of a label view to a transparent bitmap. Can someone please advise?

B4X:
'Capture Panel to imageview
Sub PanelScreenShot(pnl As Panel, Img2 As ImageView)
    Dim Obj1, Obj2 As Reflector
    Dim bmp As Bitmap
    Dim c As Canvas
    Obj1.Target = Obj1.GetActivityBA
    Obj1.Target = Obj1.GetField("vg")
    bmp.InitializeMutable(pnl.left + pnl.Width, pnl.Top + pnl.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)
    'draw from image to canavas
    Dim canvas1 As Canvas
    canvas1.Initialize(Img2)
    Dim scrt As Rect
    scrt.Initialize(pnl.left, pnl.top, pnl.left + pnl.Width, pnl.Top + pnl.Height)
    Dim rectPanel1 As Rect
    rectPanel1.Initialize(0, 0,Img2.Width, Img2.Height)
    canvas1.DrawBitmap(bmp, scrt , rectPanel1)
    Img2.Invalidate
End Sub

Thanks
 
Top