I am looking at the following code trying to figure away to us it and send the image over to another app across tcp.
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "1.jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "1.jpg"), True)
End Sub
I have a open socket and I have no problem sending simple text back and forth between apps.
B4X:
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
Socket1 = NewSocket
tw.Initialize(Socket1.OutputStream)
tw.Writeline ("OK,Connected!,")
tw.Flush
AStreams.Initialize (Socket1.InputStream, Socket1.OutputStream, "AStreams")
Else
ToastMessageShow(LastException.Message, True)
End If
Server.Listen
End Sub
Ok I have a app sending a picture over to another app on another tablet. Seems my send Code is working fine but when i get the image on the other device it just saves a black image.
My Code for sending the image using Astreams.
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
AStreams.Write2 (Data,0,Data.Length)
End Sub
The code for receiving the image and saving it to a file.
B4X:
Sub AStreams_NewData (Buffer() As Byte)
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "1.jpg", False)
out.WriteBytes(Buffer, 0, Buffer.Length)
out.Close
End Sub