public void saveURLToImage() { string url = txtURL.Text.Replace("'", "''"); string content = ""; System.Net.WebRequest webRequest = WebRequest.Create(url); System.Net.WebResponse webResponse = webRequest.GetResponse(); System.IO.StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8")); content = sr.ReadToEnd(); //save to file //byte[] key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 }; //byte[] iv = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 }; //string str64Key = Convert.ToBase64String(Encoding.ASCII.GetBytes(content)); // byte[] b=Encoding.Default.GetBytes(content); byte[] b = (new UnicodeEncoding()).GetBytes(content); System.Drawing.Image newImage; System.IO.MemoryStream ms = new System.IO.MemoryStream(b,0,b.Length); ms.Write(b, 0, b.Length); newImage = System.Drawing.Image.FromStream(ms,false,false); newImage.Save(@"~/imagecapture", System.Drawing.Imaging.ImageFormat.Jpeg); newImage.Dispose(); ms.Close(); btm.Dispose(); } In this Function i got the error in this line: newImage = System.Drawing.Image.FromStream(ms,false,false); The error is That: parameter is not valid. I have tried so mnay ways to resolve this problm like I have also applied true,false/false,true/ true,true combination. Insted of image i have tried bitmap also but still it create error. So please help me to solve this probelm.
what you try to do? capture the webpage as an image? If so there are several solutions out there that can do it. I have some code in vb that can do it if you need that.
If you are trying to convert html output to image, you have got it all wrong. You need a rendering engine (same as browsers use) to render the html markup as a web page and only then you can capture the image. Actually, I am looking for a solution to do the same, that is programmatically convert a URL to the web page image. Anyone can help?