D
Deleted member 103
Guest
Hi,
I share the appearance of my app with a second device, I use the example "MJPEG / CCTV Server" of Erel.
But not the camera is used, as in the example, but I send with a timer a few screenshot per second.
My question is: is there a better solution or is my approach right?
I share the appearance of my app with a second device, I use the example "MJPEG / CCTV Server" of Erel.
But not the camera is used, as in the example, but I send with a timer a few screenshot per second.
My question is: is there a better solution or is my approach right?
B4X:
Private Sub mirrorTimer_Tick
'Log("mirrorTimer_Tick")
Dim jpeg() As Byte = ConvertBitmapToByte(TakeScreenshot)
Starter.smanager.NewBitmap(jpeg)
End Sub
Private Sub TakeScreenshot As Bitmap
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))
Return bmp
End Sub
Private Sub ConvertBitmapToByte(foto As Bitmap) As Byte()
'convert the image file to a bytes array
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
'Dim InputStream1 As InputStream
foto.WriteToStream(OutputStream1,70,"JPEG")
Dim Buffer() As Byte 'declares an empty array
Buffer = OutputStream1.ToBytesArray
Return Buffer
End Sub