hi,
I am trying to develop an application using C#.
The problem i am facing is i am unable to display an url image in picturebox.
each time i try , m_bmpdata = null.... i can retrieve the url image
height, width etc but the pict is not displaying. below is the code i m
trying. Any help or hint will be very helpful. I been trying for the
past 2 days.
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(thumbnail.Url);
request.Timeout = 5000; // 5 seconds in milliseconds
request.ReadWriteTimeout = 20000; // allow up to 20 seconds to elapse
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream ms = response.GetResponseStream();
using (MemoryStream ms2 = new MemoryStream())
{
int bytes = 0;
byte[] temp = new byte[4096];
while ((bytes = ms.Read(temp, 0, temp.Length)) != 0)
ms2.Write(temp, 0, bytes);
test = new Bitmap(ms2);
//response.BinaryWrite(ms2.ToArray());
}
pictureBox2.Height = test.Height;
pictureBox2.Width = test.Width;
pictureBox2.Image = test;
thank you very much for any help... a big thanks in advance.. if there is any better do inform me... thank you thank you
Loading

Roei BarRank #1,271 · 1.4K reputationPosted Sep 17, 2009, 3:48 AM EDT
private Image GetImageFromURL(string strURL) { Image retVal = null; try { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(strURL); request.Timeout = 5000; // 5 seconds in milliseconds request.ReadWriteTimeout = 20000; // allow up to 20 seconds to elapse // execute the request HttpWebResponse response = (HttpWebResponse) request.GetResponse(); retVal = Image.FromStream(streamThreadStream); } catch(Exception) { retVal = null; } return retVal; } Image retVal = GetImageFromURL("http://"); pictureBox2.Height = retVal.Height; pictureBox2.Width = retVal.Width; pictureBox2.Image = retval;senthil kumar5 reputationPosted Sep 17, 2009, 6:09 PM EDT
appreciate the help but as far as i know "Image.FromStream" is not supported by .NET CF right? i have come across that code before bu ti was unable to use it as it was not supported by .NET CF.
Please let me know if I am wrong.
Thank you very much again.
Master BillaRank #2,229 · 630 reputationPosted Sep 18, 2009, 12:36 AM EDT
Yes you need use the P/Invoke to this
http://www.codeproject.com/KB/mobile/IPhoneUI.aspx
thank you
senthil kumar5 reputationPosted Sep 18, 2009, 1:28 AM EDT
Thanks for the reply but i m unsure on how to do it.
Should i invoke Image.fromStream only.. Any sample code.. Sorry coz i am still new to C#.
Thank you..