<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

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

Published on
6,505 Points
3,505 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

Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Join & Write a Comment

Learn the basics of Skype For Business in office 365
See the Basics of Office 365's Note Taking app, OneNote

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month