Android Question snapshot to camera and UI

bixmatech

Member
Licensed User
Hi...
I used opencv lib in one of my project to open camera and tracking a face. and added some ui (label, button) above the camera's panel.

I wanna make a screenshot to the camera and the UI together

I tried :
B4X:
Sub TakeScreenshot
Dim jo As JavaObject
jo.InitializeContext
Dim decor As JavaObject = jo.RunMethodJO("getWindow", Null).RunMethod("getDecorView", Null)
Dim decorChild As JavaObject = decor.RunMethod("getChildAt", Array(0))
decorChild.RunMethod("setDrawingCacheEnabled", Array(True))
decorChild.RunMethod("buildDrawingCache", Null)
Dim bmp As Bitmap = decorChild.RunMethod("getDrawingCache", Array(True))
bmp.Initialize3(bmp)
decorChild.RunMethod("setDrawingCacheEnabled", Array(False))

Dim filename As String = GenerateFileName
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, filename, False)
bmp.WriteToStream(Out, 100, "PNG")
Out.Close
End Sub


And

B4X:
Sub ScreenShot(panel As Panel)

Dim a As B4XView = panel
Dim bmp As B4XBitmap = a.Snapshot
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, GenerateFileName, False)
bmp.WriteToStream(out, 100, "PNG")
out.Close
End Sub


And a library called "Selfie" , all the same problem...

When I make a screenshot, the saved image show just the UI without the camera's image.

how can i capture both camera and ui ?

I Attached the saved image
(cameras' panel at the background with transparent color, but the button showed)

Thank you ...

 

Attachments

  • test.png
    test.png
    29.7 KB · Views: 325
Last edited:
Top