Getting byte size of image

  • Thread starter Thread starter Jerry Spence1
  • Start date Start date
J

Jerry Spence1

I am trying to come up with a focussing routine for a camera and I need to
detect when the image is in focus.

As I understand it, JPG Image size goes up sharply when it is in focus as it
is very sensitive to the presence of sharply defined edges (high spatial
frequency information). I have the following routine which gets the image
from the camera into NewPic. I am trying to find the size in bytes of this
image and I don't want to write it out to disk and read it again. I have
looked at various properties of NewPic and also respStream and I can't find
the answer.


Dim siteUri As New System.Uri(URL)
WebRequest = System.Net.WebRequest.Create(siteUri)
WebRequest.Timeout = 3000
Dim respStream As System.IO.Stream = Nothing
Dim webResponse As System.Net.WebResponse = WebRequest.GetResponse()
respStream = webResponse.GetResponseStream()
Dim NewPic As Image = Image.FromStream(respStream)

-Jerry
 
Jerry said:
I am trying to come up with a focussing routine for a camera and I need to
detect when the image is in focus.

As I understand it, JPG Image size goes up sharply when it is in focus as it
is very sensitive to the presence of sharply defined edges (high spatial
frequency information). I have the following routine which gets the image
from the camera into NewPic. I am trying to find the size in bytes of this
image and I don't want to write it out to disk and read it again. I have
looked at various properties of NewPic and also respStream and I can't find
the answer.


Dim siteUri As New System.Uri(URL)
WebRequest = System.Net.WebRequest.Create(siteUri)
WebRequest.Timeout = 3000
Dim respStream As System.IO.Stream = Nothing
Dim webResponse As System.Net.WebResponse = WebRequest.GetResponse()
respStream = webResponse.GetResponseStream()
Dim NewPic As Image = Image.FromStream(respStream)

-Jerry

If you can't get the length from the WebResponse object, you can write
the stream to a MemoryStream.
 
Back
Top