C#显示url图片

C#显示url图片 webtech 发表于 2007-1-18 16:48:00 private void GetUrlImage(string url)
        { 
            WebClient client = new WebClient();
            client.OpenReadCompleted +=new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            client.OpenReadAsync(new Uri(url));
        }
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            Stream stream = e.Result;
            this.pictureBox1.Image= Image.FromStream(stream); 
        }
 

C#下载图片修改后显示



 
using System.Net;
using System.Drawing;

//1、将原始图片下载下来:
string url = "
http://www.mozilla.org/images/feature-back-cnet.png";
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(url,"C:\\temp\\feature-back-cnet.png"); 

System.Drawing.Image image = System.Drawing.Image.FromFile("C:\\temp\\feature-back-cnet.png");
Bitmap bmp = new Bitmap(image,new Size(100,100));

//2.将新图片保存到 C:\temp\newPic.png
bmp.Save("C:\\temp\\newPic.png",System.Drawing.Imaging.ImageFormat.Png);

Image1.ImageUrl = "C:\\temp\\newPic.png";

你可能感兴趣的:(C#显示url图片)