Hello,
I also want to do something like spy camera between two phones. I'm not really advanced in programming using Basic4android but made several small programs. I wanted to use AsyncStreamsObject but i don't know how to send jpeg byte array so I have used AsyncStream such as in CCTV example and when I recive bytes, convert them to Bitmap. Both phones are connected but i receive only one frame per 5-10 sec... Its something like taking photos.. That works so slow..
Can anybody help me ? or tell, how to convert byte array jpeg to a bitmap and than send with AsyncStreamsObject ?
this is my code for receiving :
Sub astream_NewData(Buffer() As Byte)
Dim In As InputStream
In.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim bmp As Bitmap
Try
bmp.Initialize2(In)
In.Close
Dim r As Rect
r.Initialize(0, 0, Panel1.Width, Panel1.Height)
cvs.DrawBitmap(bmp, Null, r)
Panel1.Invalidate
Catch
End Try
End Sub
I also Tried to do so with Object but i got error not in program but on phone : "sub: asyncstreamsobject_getavailablefile (java line:179) java.lang.RuntimeException: Object should first be initialized (Map) ...
And that is when i try to convert byte array to a bitmap..
Sub Camera1_Preview (PreviewPic() As Byte)
If DateTime.Now > lastPreviewSaved + IntervalMs Then
Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
lastPreviewSaved = DateTime.Now
Dim bmp As Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
Try
bmp.Initialize2(In)
In.Close
Catch
End Try
astreamO.WriteBitmap("image", bmp)
End If
End Sub
I discovered that an error occurs when i try to send a bitmap using "astreamO.WriteBitmap("image", bmp)"
If anybody want to check my program, i can make it available..