Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Currently i'm using this

C#
string sourceURL = "http://192.168.1.88/web/admin.html";
            string login = "admin";
            string password = "admin";
            byte[] buffer = new byte[100000];
            int read, total = 0;
            // create HTTP request
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
            // set login and password
            req.Credentials = new NetworkCredential(login, password);
            // get response
            WebResponse resp = req.GetResponse();
            // get response stream
            Stream stream = resp.GetResponseStream();
            

            // read data from stream
            while ((read = stream.Read(buffer, total, 1000)) != 0)
            {
                total += read;
            }
            //stream.Close();
            //resp.Close();
           
            Bitmap bmp = (Bitmap)Bitmap.FromStream(
                          new MemoryStream(buffer, 0, total)); //Error: Parametor not valid


But, it's show error of "Parametor Not Valid". I tried almost each and everything, but all in vain. The, Camera i'm using is 'ZKT eco'.

I, also tried this

C#
http://root:pass@192.168.1.88/web/admin.html
            byte[] bytes = new byte[256];
            Socket sock = new Socket(AddressFamily.InterNetwork
                , SocketType.Stream, ProtocolType.Tcp);
            sock.Connect("192.168.1.88", 80);
            if (sock.Connected)
            {


                int i = sock.Receive(bytes);
            }
            //pictureBox1.Image = (Bitmap)ConvertByteArray2Bitmap(bytes);
            //Bitmap asdjfk =(Bitmap)ConvertByteArray2Bitmap(bytes);
            Image bmppic = ConvertByteArray2Bitmap(bytes);
            pictureBox1.Image = bmppic;

But, it also showing same error.
Please help, thanks in advance...
Posted
Updated 2-Feb-14 18:35pm
v3
Comments
Richard MacCutchan 3-Feb-14 4:31am    
I don't know the answer but take a look at https://www.google.com/search?q=ip+camera+c%23.
Member 10486677 3-Feb-14 4:50am    
I already done enough googling about this... and i got the above code from their... but no fruitful result...
Richard MacCutchan 3-Feb-14 5:01am    
You need to investigate further why it gives Parameter not valid. Maybe the contents of the memory stream buffer cannot be recognised as a valid image type.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900