I have a c# client application that connects to a network socket. When
connected, the listener sends a network stream containing bitmap, jpeg, data
from a file nominated by the client. The client application (also c#)
receives the data into a byte[] array. I want to pass the byte[] array
directly to a picture control on the form. I can't find a way to do this so I
used a file stream and write the byte[] array to a file, and then pass that
pathname into the Image.LoadFile(pathname) method and then assign the image
to the picture, as in Picture.Image = RuntimeImage.
This works but having to use an interface file to get the data into the
picture control is not ideal. Is it possible somehow to massage the byte[]
array I got from the NetworkStream directly to the Picture control? 5 2600
I haven't tested this and not positive that it would work, but can't you use
the share function Image.FromStream(Stream) as Image. Just pass in your
stream.
Chris
"PHS" <PH*@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com... I have a c# client application that connects to a network socket. When connected, the listener sends a network stream containing bitmap, jpeg, data from a file nominated by the client. The client application (also c#) receives the data into a byte[] array. I want to pass the byte[] array directly to a picture control on the form. I can't find a way to do this so I used a file stream and write the byte[] array to a file, and then pass that pathname into the Image.LoadFile(pathname) method and then assign the image to the picture, as in Picture.Image = RuntimeImage.
This works but having to use an interface file to get the data into the picture control is not ideal. Is it possible somehow to massage the byte[] array I got from the NetworkStream directly to the Picture control?
This is the correct way.
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:ub*************@TK2MSFTNGP12.phx.gbl... I haven't tested this and not positive that it would work, but can't you
use the share function Image.FromStream(Stream) as Image. Just pass in your stream.
Chris
"PHS" <PH*@discussions.microsoft.com> wrote in message news:D4**********************************@microsof t.com...I have a c# client application that connects to a network socket. When connected, the listener sends a network stream containing bitmap, jpeg, data from a file nominated by the client. The client application (also c#) receives the data into a byte[] array. I want to pass the byte[] array directly to a picture control on the form. I can't find a way to do this so I used a file stream and write the byte[] array to a file, and then pass that pathname into the Image.LoadFile(pathname) method and then assign the image to the picture, as in Picture.Image = RuntimeImage.
This works but having to use an interface file to get the data into the picture control is not ideal. Is it possible somehow to massage the
byte[] array I got from the NetworkStream directly to the Picture control?
Thanks guys.
I tried that and ended up with this chunk of code:
TcpClient S = new TcpClient("localhost", 50001);
NetworkStream NS = S.GetStream();
Picture.Image = Image.FromStream(NS);
Picture.Refresh();
NS.Close();
S.Close();
It works 100% fine. I could receive image files (bmp/jpg) in size from 4k
upto 1.6Mb and they displayed perfectly.
Peter.
"Landley" wrote: This is the correct way.
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote in message news:ub*************@TK2MSFTNGP12.phx.gbl... I haven't tested this and not positive that it would work, but can't you use the share function Image.FromStream(Stream) as Image. Just pass in your stream.
Chris
"PHS" <PH*@discussions.microsoft.com> wrote in message news:D4**********************************@microsof t.com...I have a c# client application that connects to a network socket. When connected, the listener sends a network stream containing bitmap, jpeg, data from a file nominated by the client. The client application (also c#) receives the data into a byte[] array. I want to pass the byte[] array directly to a picture control on the form. I can't find a way to do this so I used a file stream and write the byte[] array to a file, and then pass that pathname into the Image.LoadFile(pathname) method and then assign the image to the picture, as in Picture.Image = RuntimeImage.
This works but having to use an interface file to get the data into the picture control is not ideal. Is it possible somehow to massage the byte[] array I got from the NetworkStream directly to the Picture control?
Hello,
First, sorry for my English.
I have the same problem, with the NET CompactFramework. With
NETCF the Image.FromFile method is not available.
Have you other solutions for these problem?
Thank you
"PHS" schrieb: Thanks guys.
I tried that and ended up with this chunk of code:
TcpClient S = new TcpClient("localhost", 50001); NetworkStream NS = S.GetStream(); Picture.Image = Image.FromStream(NS); Picture.Refresh(); NS.Close(); S.Close();
It works 100% fine. I could receive image files (bmp/jpg) in size from 4k upto 1.6Mb and they displayed perfectly.
Peter.
"Landley" wrote:
This is the correct way.
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote in message news:ub*************@TK2MSFTNGP12.phx.gbl... I haven't tested this and not positive that it would work, but can't you use the share function Image.FromStream(Stream) as Image. Just pass in your stream.
Chris
"PHS" <PH*@discussions.microsoft.com> wrote in message news:D4**********************************@microsof t.com... >I have a c# client application that connects to a network socket. When > connected, the listener sends a network stream containing bitmap, jpeg, > data > from a file nominated by the client. The client application (also c#) > receives the data into a byte[] array. I want to pass the byte[] array > directly to a picture control on the form. I can't find a way to do this > so I > used a file stream and write the byte[] array to a file, and then pass > that > pathname into the Image.LoadFile(pathname) method and then assign the > image > to the picture, as in Picture.Image = RuntimeImage. > > This works but having to use an interface file to get the data into the > picture control is not ideal. Is it possible somehow to massage the byte[] > array I got from the NetworkStream directly to the Picture control?
Hello,
First, sorry for my English.
I have the same problem, with the NET CompactFramework. With
NETCF the Image.FromFile method is not available.
Have you other solutions for these problem?
Thank you
"PHS" schrieb: Thanks guys.
I tried that and ended up with this chunk of code:
TcpClient S = new TcpClient("localhost", 50001); NetworkStream NS = S.GetStream(); Picture.Image = Image.FromStream(NS); Picture.Refresh(); NS.Close(); S.Close();
It works 100% fine. I could receive image files (bmp/jpg) in size from 4k upto 1.6Mb and they displayed perfectly.
Peter.
"Landley" wrote:
This is the correct way.
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote in message news:ub*************@TK2MSFTNGP12.phx.gbl... I haven't tested this and not positive that it would work, but can't you use the share function Image.FromStream(Stream) as Image. Just pass in your stream.
Chris
"PHS" <PH*@discussions.microsoft.com> wrote in message news:D4**********************************@microsof t.com... >I have a c# client application that connects to a network socket. When > connected, the listener sends a network stream containing bitmap, jpeg, > data > from a file nominated by the client. The client application (also c#) > receives the data into a byte[] array. I want to pass the byte[] array > directly to a picture control on the form. I can't find a way to do this > so I > used a file stream and write the byte[] array to a file, and then pass > that > pathname into the Image.LoadFile(pathname) method and then assign the > image > to the picture, as in Picture.Image = RuntimeImage. > > This works but having to use an interface file to get the data into the > picture control is not ideal. Is it possible somehow to massage the byte[] > array I got from the NetworkStream directly to the Picture control?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: chellappa |
last post by:
Hi,
This is program for socket program for server and client ... but data
send from client and receive by server but i can t sen d message fro m
server to client ... check i mistake .. i treed...
|
by: Chris Tanger |
last post by:
Context:
C#
System.Net.Sockets
Socket created with constructor prarmeters Internetwork, Stream and TCP
everything else is left at the default parameters and options except linger
may be changed...
|
by: Jim |
last post by:
Here is a snipet of the code.
// State object for receiving data from remote device.
public class StateObject
{
// Client socket.
public Socket workSocket = null;
// Size of receive buffer....
|
by: Craig |
last post by:
Hi
I listen on a port, when data is received I raise an event
(OnMessageReceived) in the while loop as follows:
private void WaitForConnection() {
TcpListener listener = new...
|
by: mscirri |
last post by:
The code below is what I am using to asynchronously get data from a
PocketPC device. The data comes in fine in blocks of 1024 bytes but
even when I send no data from the PocketPC constant blocks of...
|
by: vinothgsd |
last post by:
Hi,
I have created Client/Server application. In that Client side Program
i have used Asynchronous Callback method for send and receive the
stream. In the Receive method I want to make the...
|
by: PHS |
last post by:
I have a c# client application that connects to a network socket. When
connected, the listener sends a network stream containing bitmap, jpeg, data
from a file nominated by the client. The client...
|
by: Macca |
last post by:
Hi,
I am writing an asychronous socket server to handle 20+ simulataneous
connections.
I have used the example in MSDN as a base. The code is shown at end of
question.
Each connection has a...
|
by: george585 |
last post by:
Hello!
I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |