|
-
Jan 31st, 2015, 05:57 AM
#1
Thread Starter
Member
Image from HttpWebResponse makes Argument exception error
Hi, I'm trying to get single image stream from IP camera, and it works with other cameras
and using web browser, image displayed correctly but not with my code.
This is my code:
Code:
Private Sub obtainImage()
Dim url As String = "http://" + CAMAddr + "/cgi-bin/fwcamimg.cgi?FwModID=0&PortId=1&FwCgiVer=0x0001"
Dim request As Net.HttpWebRequest
Try
request = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)
Catch ex As Exception
Exit Sub
End Try
request.KeepAlive = False
' This is method A
'Dim webClient As New System.Net.WebClient
'Dim bytes() As Byte = webClient.DownloadData(url)
'Dim stream As New IO.MemoryStream(bytes)
'Dim Img As Image = Image.FromStream(stream)
' This is method B
Dim response As Net.HttpWebResponse = DirectCast(request.GetResponse, Net.HttpWebResponse)
Dim img As Image = Image.FromStream(response.GetResponseStream)
If Not PictureBox1 Is Nothing Then
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureShow(PictureBox1, img)
End If
response.Close()
request.Abort()
response = Nothing
request = Nothing
End Sub
When I use other cameras, this works perfectly.
I use new camera, and this routine does not work, but, with webbrowser, above url works
nicely... when I use same url string with webbrowser control, image is displayed and
webbrowser.documenttype shows it is JPEG format.
But above code, with blue line, it makes Argument exception error.
Anybody can help me?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|