PC Review


Reply
Thread Tools Rate Thread

How to convert a socket data buffer into pictures.

 
 
=?Utf-8?B?UEhT?=
Guest
Posts: n/a
 
      7th Dec 2004
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?
 
Reply With Quote
 
 
 
 
Chris, Master of All Things Insignificant
Guest
Posts: n/a
 
      7th Dec 2004
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" <(E-Mail Removed)> wrote in message
news4306DB4-879A-4A69-8D67-(E-Mail Removed)...
>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?



 
Reply With Quote
 
Landley
Guest
Posts: n/a
 
      7th Dec 2004
This is the correct way.


"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news4306DB4-879A-4A69-8D67-(E-Mail Removed)...
> >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?

>
>



 
Reply With Quote
 
=?Utf-8?B?UEhT?=
Guest
Posts: n/a
 
      8th Dec 2004
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:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news4306DB4-879A-4A69-8D67-(E-Mail Removed)...
> > >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?

> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?c2MyOTc3NTQ=?=
Guest
Posts: n/a
 
      13th Dec 2004
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:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news4306DB4-879A-4A69-8D67-(E-Mail Removed)...
> > > >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?
> > >
> > >

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?c2MyOTc3NTQ=?=
Guest
Posts: n/a
 
      13th Dec 2004
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:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news4306DB4-879A-4A69-8D67-(E-Mail Removed)...
> > > >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?
> > >
> > >

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDP Socket buffer issue =?Utf-8?B?V2lsbCBGcmFuay1HZW1taWxs?= Microsoft Dot NET Compact Framework 0 7th Oct 2005 09:22 AM
Buffer in Socket =?Utf-8?B?UnVpeG8=?= Microsoft Dot NET Framework 0 1st Apr 2005 12:45 PM
marshalling socket buffer allen Microsoft C# .NET 2 5th Feb 2005 11:23 AM
Re: UDP Socket buffer clarifications Chad Z. Hower aka Kudzu Microsoft Dot NET Framework 0 4th Feb 2004 04:04 PM
Net.Sockets.Socket.BegineReceive with 1 byte buffer losses data Jack Microsoft C# .NET 0 22nd Aug 2003 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 AM.