<

How to load images from URI into a .NET image object?

Published on
6,448 Points
3,448 Views
Last Modified:
In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it.

The first step, was to retrieve the image from camera into

Image

object. So that it can be displayed or do some processing on it.

Some of the IP cameras have an interface to acquire images or streams. One of the easiest interfaces is giving some steel JPEG images. For example via a simple HTTP request (e.g. http://webcam.mmhk.cz/axis-cgi/jpg/image.cgi) we have an JPEG image.

Here is code snippet to acquire an image from a URI and display in a PictureBox.
//uri resource
Uri uri = new Uri(
  "http://webcam.mmhk.cz/axis-cgi/jpg/image.cgi"); 
//create a stream using a http web request
System.IO.Stream s = 
  System.Net.HttpWebRequest.Create(uri)
  .GetResponse().GetResponseStream(); 
//create an image object from stream
Image img = Image.FromStream(s); 
//display image in a picture box
this.pictureBox1.Image = img;

Open in new window

0
Comment
2 Comments
 

Expert Comment

by:jr_barros_jr
Mandar imagens ou webcam para uma URL
0
 

Expert Comment

by:Falcubar
Hi,

Take a look at Webbrowser control it comes with a nice function.

webBrowser1.DrawToBitmap();

Open in new window


I've used this for getting captcha images etc.
0

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Join & Write a Comment

In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function. See how to call a wrapper function from a query, and …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month