I have tried many methods to do that…and it’s all working fine , stream snapshot from the camera then save it as a jpg in the PC…. picture (jpg format,1280*1024,140KB)..That’s fine
But my problem is in the application performance...
The app need about 20 ~30 seconds to read the steam, that’s not acceptable because that method will be called every 2 second .I need to know what wrong with that code and how I can get it much faster than that. ?
Many thanks in advance
Code:
Expand|Select|Wrap|Line Numbers
- string sourceURL = "http://192.168.0.211/cgi-bin/cmd/encoder?SNAPSHOT";
- byte[] buffer = new byte[200000];
- int read, total = 0;
- WebRequest req = (WebRequest)WebRequest.Create(sourceURL);
- req.Credentials = new NetworkCredential("admin", "123456");
- WebResponse resp = req.GetResponse();
- Stream stream = resp.GetResponseStream();
- while ((read = stream.Read(buffer, total, 1000)) != 0)
- {
- total += read;
- }
- Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0,total));
- string path = JPGName.Text+".jpg";
- bmp.Save(path);