Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uri geturi = new Uri(_cgi);
- //Solicita um comando CGI para câmera FOSCAM
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(geturi);
- byte[] imgByte = null;
- //Pega a Resposta do comando CGI, neste comando uma imagem.
- using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
- {
- if (response != null)
- {
- using (BinaryReader reader = new BinaryReader(response.GetResponseStream()))
- {
- imgByte = reader.ReadBytes(1 * 640 * 480 * 10);
- }
- }
- }
- Uri geturi = new Uri(_cgi);
- string username = "admin";
- string password = "realdrive17";
- //Seta as credenciais
- NetworkCredential cred = new NetworkCredential(username, password);
- CredentialCache cache = new CredentialCache();
- cache.Add(geturi, "Basic", cred);
- //Solicita um comando CGI para câmera FOSCAM
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(geturi);
- request.PreAuthenticate = true;
- request.Credentials = cache;
- byte[] imgByte = null;
- //Pega a Resposta do comando CGI, neste comando uma imagem.
- using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
- {
- if (response != null)
- {
- using (BinaryReader reader = new BinaryReader(response.GetResponseStream()))
- {
- imgByte = reader.ReadBytes(1 * 1024 * 1024 * 10);
- //Converte os Bytes para um bitmap.
- if (BytesToBitmap(imgByte) != null)
- {
- RunOnUiThread(() =>
- {
- _image.SetImageBitmap(BytesToBitmap(imgByte));
- });
- return true;
- }
- }
- return false;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment