Hello I wrote a code to receive image over internet. It can connect successfully and got many byte show in Log but it doesn't show image on imageview. If I use browser type host and port, the image is showed successful, Here is my code :
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private ImageView1 As ImageView
Private client1 As Socket
Private astream As AsyncStreams
'Private Pane1 As Pane
'Private cvs As Canvas
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
client1.Initialize("client1")
client1.Connect("proxy70.yoics.net",38901,20000)
ImageView1.Initialize("ImageView1")
ImageView1.Enabled = True
'cvs.Initialize("cvs")
'Pane1.AddNode(cvs, 0, 0, Pane1.Width, Pane1.Height)
End Sub
Sub client1_Connected (Successful As Boolean)
If Successful Then
astream.Initialize(client1.InputStream,client1.OutputStream,"astream")
Log("connected")
Else
Log("Error")
End If
End Sub
Sub astream_NewData (Buffer() As Byte)
Dim In As InputStream
Log(Buffer.Length)
In.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim img As Image
img.Initialize2(In)
ImageView1.SetImage(img)
'Dim bmp As Image
'bmp.Initialize2(In)
'cvs.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height)
End Sub