Sending Bitmap using WCF

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2007
Posts: 30
Reputation: Fouly is an unknown quantity at this point 
Solved Threads: 0
Fouly Fouly is offline Offline
Light Poster

Sending Bitmap using WCF

 
0
  #1
Dec 27th, 2008
Hi,
I'm trying to send a bitmap using WCF and here's the steps i followed:
1-Convert it into byte array
  1. private IDataObject tempObj;
  2. private System.Drawing.Image tempImg;
  3. tempObj = Clipboard.GetDataObject();
  4. tempImg = (System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);
  5. tempImg.Save("hello.bmp");
  6. 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
  1. public void ReceiveByteArray(byte[] Data)
  2. {
  3. try
  4. {
  5. TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
  6. Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(Data);
  7.  
  8. pictureBox2.Image = bitmap1;
  9. }
  10. catch (Exception ex)
  11. {
  12. MessageBox.Show(ex.Message);
  13. }

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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Sending Bitmap using WCF

 
0
  #2
Dec 27th, 2008
If you saved this bitmap on client's HDD, what the result, also black?
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 30
Reputation: Fouly is an unknown quantity at this point 
Solved Threads: 0
Fouly Fouly is offline Offline
Light Poster

Re: Sending Bitmap using WCF

 
0
  #3
Dec 27th, 2008
yes it's black...
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Sending Bitmap using WCF

 
0
  #4
Dec 28th, 2008
Check if your array comes in order or not.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 30
Reputation: Fouly is an unknown quantity at this point 
Solved Threads: 0
Fouly Fouly is offline Offline
Light Poster

Re: Sending Bitmap using WCF

 
0
  #5
Dec 28th, 2008
Yes it comes in order and everything is okay...it was a matter of format.

  1. private void WebCamCapture_ImageCaptured(object source, WebcamEventArgs e)
  2. {
  3. // set the picturebox picture
  4. MemoryStream ms = new MemoryStream();
  5. e.WebCamImage.Save(ms, ImageFormat.Jpeg);
  6.  
  7. proxy.SendShot(new SimpleSvc.VideoChat(ms.ToArray(),lstContacts.SelectedItem.ToString()));
  8.  
  9. this.pictureBox1.Image = e.WebCamImage;
  10. }
Thanks for help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC