DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Sending Bitmap using WCF (http://www.daniweb.com/forums/thread164484.html)

Fouly Dec 27th, 2008 9:19 pm
Sending Bitmap using WCF
 
Hi,
I'm trying to send a bitmap using WCF and here's the steps i followed:
1-Convert it into byte array
private IDataObject tempObj;
private System.Drawing.Image tempImg;
tempObj = Clipboard.GetDataObject();
tempImg = (System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);
tempImg.Save("hello.bmp");
VideoData = System.IO.File.ReadAllBytes("hello.bmp");
2-Receiving the byte array from the other client side and convert it into bitmap to display it
public void ReceiveByteArray(byte[] Data)
        {
            try
            {
                TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
                Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(Data);

                pictureBox2.Image = bitmap1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

i don't know why pictureBox.Image is always black...it doesn't display the image,although the "hello.bmp" file on the hard disk changes while catching the picture.

N.B the byte array "Data" isn't set to null it contains the values i sent from the other client side.

Ramy Mahrous Dec 27th, 2008 9:23 pm
Re: Sending Bitmap using WCF
 
If you saved this bitmap on client's HDD, what the result, also black?

Fouly Dec 27th, 2008 9:34 pm
Re: Sending Bitmap using WCF
 
yes it's black...

Ramy Mahrous Dec 28th, 2008 8:27 am
Re: Sending Bitmap using WCF
 
Check if your array comes in order or not.

Fouly Dec 28th, 2008 5:15 pm
Re: Sending Bitmap using WCF
 
Yes it comes in order and everything is okay...it was a matter of format.

private void WebCamCapture_ImageCaptured(object source, WebcamEventArgs e)
        {
            // set the picturebox picture
            MemoryStream ms = new MemoryStream();
            e.WebCamImage.Save(ms, ImageFormat.Jpeg);

            proxy.SendShot(new SimpleSvc.VideoChat(ms.ToArray(),lstContacts.SelectedItem.ToString()));

            this.pictureBox1.Image = e.WebCamImage;
        }
Thanks for help


All times are GMT -4. The time now is 5:26 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC