captain hawak Member Dec 17, 2021 #1 hi i send image with c# server to b4a tcp client and after get error load bitmap error. this code very good work for udp just error in tcp from b4a i think problem for tcp b4a Code: Copy img = Image.FromFile(@"C:\Users\at\Pictures\download.jpeg"); ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Jpeg); byte[] byteArray = ms.ToArray(); reci = byteArray.Length.ToString(); nwStream.Write(byteArray, 0, byteArray.Length); Code: Copy Sub img (buffer() As Byte) Dim in As InputStream in.InitializeFromBytesArray(buffer, 0, buffer.Length) Dim bmp As Bitmap bmp.Initialize2(in) Dim bd As BitmapDrawable bd.Initialize(bmp) bd.Gravity = Gravity.FILL Panel3.Background = bd in.Close End Sub errors: screen_second_img (java line: 411) java.lang.RuntimeException: Error loading bitmap. at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539) at io.hanitum.screen_second._img(screen_second.java:411) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082) at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037) at io.hanitum.tcp._astream_newdata(tcp.java:162) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213) at anywheresoftware.b4a.BA$2.run(BA.java:387) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7565) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) java.lang.RuntimeException: Error loading bitmap.
hi i send image with c# server to b4a tcp client and after get error load bitmap error. this code very good work for udp just error in tcp from b4a i think problem for tcp b4a Code: Copy img = Image.FromFile(@"C:\Users\at\Pictures\download.jpeg"); ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Jpeg); byte[] byteArray = ms.ToArray(); reci = byteArray.Length.ToString(); nwStream.Write(byteArray, 0, byteArray.Length); Code: Copy Sub img (buffer() As Byte) Dim in As InputStream in.InitializeFromBytesArray(buffer, 0, buffer.Length) Dim bmp As Bitmap bmp.Initialize2(in) Dim bd As BitmapDrawable bd.Initialize(bmp) bd.Gravity = Gravity.FILL Panel3.Background = bd in.Close End Sub errors: screen_second_img (java line: 411) java.lang.RuntimeException: Error loading bitmap. at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539) at io.hanitum.screen_second._img(screen_second.java:411) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082) at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037) at io.hanitum.tcp._astream_newdata(tcp.java:162) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213) at anywheresoftware.b4a.BA$2.run(BA.java:387) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7565) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) java.lang.RuntimeException: Error loading bitmap.
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2021 #2 ahmadkhazali said: i think problem for tcp b4a Click to expand... Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder. Upvote 0
ahmadkhazali said: i think problem for tcp b4a Click to expand... Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder.
captain hawak Member Dec 19, 2021 #3 Erel said: Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder Click to expand... Thank you very much for your answer. I am building a very big project and I preferred to write it with b4a. Upvote 0
Erel said: Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder Click to expand... Thank you very much for your answer. I am building a very big project and I preferred to write it with b4a.
captain hawak Member Dec 20, 2021 #4 Erel said: Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder. Click to expand... I tried and used the methods you mentioned, but neither sound nor image was received I tried mjpeg or udp and tcp or any other method but they do not work the only way is a real time connection with b4a. When I enable the prefix mode in tcp, after receiving the first byte, the connection is automatically disconnected This issue is very important to me. I have to receive and display 60 images every second. Also, the sound must be clearly received. The server is under Windows c#. I'm glad you if can help with example code b4a. Upvote 0
Erel said: Of course not. Don't assume that the complete image will arrive as a single packet. It won't. Either switch to AsyncStreams in prefix mode or collect the data yourself with B4XBytesBuilder. Click to expand... I tried and used the methods you mentioned, but neither sound nor image was received I tried mjpeg or udp and tcp or any other method but they do not work the only way is a real time connection with b4a. When I enable the prefix mode in tcp, after receiving the first byte, the connection is automatically disconnected This issue is very important to me. I have to receive and display 60 images every second. Also, the sound must be clearly received. The server is under Windows c#. I'm glad you if can help with example code b4a.
Erel B4X founder Staff member Licensed User Longtime User Dec 21, 2021 #5 Start with this example: [B4X] [B4XPages] Network + AsyncStreams + B4XSerializator ahmadkhazali said: I have to receive and display 60 images every second Click to expand... It will be difficult to receive 60 fps of separate images. You will need to use a video encoding for such rate. Upvote 0
Start with this example: [B4X] [B4XPages] Network + AsyncStreams + B4XSerializator ahmadkhazali said: I have to receive and display 60 images every second Click to expand... It will be difficult to receive 60 fps of separate images. You will need to use a video encoding for such rate.
captain hawak Member Dec 21, 2021 #6 Erel said: Start with this example: [B4X] [B4XPages] Network + AsyncStreams + B4XSerializator It will be difficult to receive 60 fps of separate images. You will need to use a video encoding for such rate. Click to expand... Hello, good day, yes, I tried this method and b4a strangely cuts the connection after receiving information from a b4j program. For example, my server is in C #, it is only responsible for sending text, but when sending data such as photos .... The connection be broken. I tried to send the information in 100 bytes, but unfortunately in perfix mode this will happen. I have a game page directly, I can stream it, and this can not be done directly with video, it is only possible with photos. Upvote 0
Erel said: Start with this example: [B4X] [B4XPages] Network + AsyncStreams + B4XSerializator It will be difficult to receive 60 fps of separate images. You will need to use a video encoding for such rate. Click to expand... Hello, good day, yes, I tried this method and b4a strangely cuts the connection after receiving information from a b4j program. For example, my server is in C #, it is only responsible for sending text, but when sending data such as photos .... The connection be broken. I tried to send the information in 100 bytes, but unfortunately in perfix mode this will happen. I have a game page directly, I can stream it, and this can not be done directly with video, it is only possible with photos.
Erel B4X founder Staff member Licensed User Longtime User Dec 21, 2021 #7 You need to understand how prefix mode works and how network streams work. Watch the TCP/IP video tutorial: https://www.b4x.com/etp.html Upvote 0
You need to understand how prefix mode works and how network streams work. Watch the TCP/IP video tutorial: https://www.b4x.com/etp.html
captain hawak Member Dec 21, 2021 #8 Erel said: You need to understand how prefix mode works and how network streams work. Watch the TCP/IP video tutorial: https://www.b4x.com/etp.html Click to expand... I am building a large application in the gaming industry and it works with artificial intelligence. 90% of the work is done and 10% is left. Because of this issue, anyway. Thank you for answer. Upvote 0
Erel said: You need to understand how prefix mode works and how network streams work. Watch the TCP/IP video tutorial: https://www.b4x.com/etp.html Click to expand... I am building a large application in the gaming industry and it works with artificial intelligence. 90% of the work is done and 10% is left. Because of this issue, anyway. Thank you for answer.