Subject: convert byte to bitmap
Posted By: jlzmut Post Date: 12/17/2005 2:00:10 PM
//this is on client side
MemoryStream mstream=new MemoryStream();
Bitmap b=new Bitmap(@"C:\Documents andSettings\jelena\Desktop\lud'lo diplomski\image\Frame.bmp");
    b.Save(mstream,System.Drawing.Imaging.ImageFormat.Bmp);
    byte[] ba=mstream.ToArray();
    BinaryWriter writer=new BinaryWriter(mstream);
    writer.Write(ba);

//the problem is to receive this bytes on server side and convert  them back to bmp

Thank's in advance

Reply By: planoie Reply Date: 12/18/2005 2:12:16 PM
Can you elaborate on "receive this bytes on server side"?
How are they being sent?
What type is 'writer'?

-Peter
Reply By: jlzmut Reply Date: 12/18/2005 4:18:42 PM
socket=listener.AcceptSocket();
NetworkStream nstream=new NetworkStream(socket);
BinaryReader reader=new BinaryReader(nstream);
int  k=0;
k=reader.ReadInt32();
byte[] ba=reader.ReadBytes(k);
MemoryStream ms=new MemoryStream(ba);
Bitmap bmp = (Bitmap)System.Drawing.Bitmap.FromStream(ms);
this.pictureBox1.Image = bmp;

//this code is on server side  but the problem is still the same.
On client side bitmap is being convert into bytes and on server side we must convert them back to bitmap.
Thank's


Go to topic 37654

Return to index page 414
Return to index page 413
Return to index page 412
Return to index page 411
Return to index page 410
Return to index page 409
Return to index page 408
Return to index page 407
Return to index page 406
Return to index page 405