473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Displaying an image url in c#

Hi,

I have an image url (eg:http://myimages.com/pic1.jpg)
Now i want to display the above image in a C# windows form.
Which control should i use?
i am using VS .NET 2003.

Pls provide some example code.

Regards,
Kiran
Mar 22 '06 #1
3 39169
You can use PictureBox to show the images in Windows Forms. You can't
directly load images from URI location. You will have to download them first
using System.Net.WebRequest and System.Net.WebResponse classes, and then load
the image from the saved location and show it in PictureBox.

Following article shows some sample code on how to dowload images from URI
location:
http://www.gotdotnet.com/Community/M...=164268&Page=1

Once downloaded you can use following code to load the file into PictureBox:

pictureBox1.Image = System.Drawing.Image.FromFile(@"Path\YourFile.jpg" );
Mar 22 '06 #2
Try this:

private Bitmap LoadPicture(string url)
{
HttpWebRequest wreq;
HttpWebResponse wresp;
Stream mystream;
Bitmap bmp;

bmp = null;
mystream = null;
wresp = null;
try
{
wreq = (HttpWebRequest)WebRequest.Create(url);
wreq.AllowWriteStreamBuffering = true;

wresp = (HttpWebResponse)wreq.GetResponse();

if ((mystream = wresp.GetResponseStream()) != null)
bmp = new Bitmap(mystream);
}
finally
{
if (mystream != null)
mystream.Close();

if (wresp != null)
wresp.Close();
}

return (bmp);
}

an then...
pictureDetail.Image = LoadPicture(strURL);
where pictureDetail is image control.

Mar 22 '06 #3
The PictureBox in 2.0 supports loading from a URL.

"yogeshprabhu" <yo**********@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
You can use PictureBox to show the images in Windows Forms. You can't
directly load images from URI location. You will have to download them
first
using System.Net.WebRequest and System.Net.WebResponse classes, and then
load
the image from the saved location and show it in PictureBox.

Following article shows some sample code on how to dowload images from URI
location:
http://www.gotdotnet.com/Community/M...=164268&Page=1

Once downloaded you can use following code to load the file into
PictureBox:

pictureBox1.Image = System.Drawing.Image.FromFile(@"Path\YourFile.jpg" );

Mar 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gregory | last post by:
Hello, I've managed to build two web pages, one that can display images with associated text data in a table, and one that can resize and display images without the text. I'd like to resize the...
3
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or...
2
by: marvin | last post by:
Hi, I am trying to display images in a repeater from a SQL database and do some transformations on the image prior to displaying them (such as thumbnail with a shadow). The problem is I can't...
3
by: CD | last post by:
An application is logging faxes sent in SQL2000 image column type. I have found code on the net but what it is doing is prompting to save to local which is fine for single page image. Not good...
5
by: ljuljacka | last post by:
I'm trying to display resized images. Locations of images are fetched from database. The problem is that with the following code, I get only the first image displayed: <?php...
4
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
4
by: shahidrasul | last post by:
i display a pic on picture box and then i want to display another pic after some seconds but problem is that first image is not displaying only display 2nd image 1... display first picture from...
6
by: Jeff | last post by:
hi asp.net 2.0 I have a image (.jpeg) stored in sql server 2005 and now I want to display it on a webpage. So I created a webpage (Image.aspx) which just writes the buffer data to the...
3
by: mvijayrkumar | last post by:
Hi to all.... Guys pls help me..... I have an image issue in RLDC while hosting my project on server.The image displays or works fine with the local system.But when hosted on server,both the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.