用Visual Studio建立Console应用程序,记得引用程序集System.Drawing;

代码如下:

using System;
using System.Drawing;
using System.IO;
using System.Net;

namespace Keleyi.Com
{
class KeleyiImage
{
static void Main(string[] args)
{
WebRequest request = WebRequest.Create(@"http://keleyi.com/image/a/tvh00n12.jpg");
request.Credentials = CredentialCache.DefaultCredentials;
Stream s = request.GetResponse().GetResponseStream();

byte[] b = new byte[74373];
MemoryStream mes_keleyi_com = new MemoryStream(b);
s.Read(b, 0, 74373);
s.Close();
Image image = Image.FromStream(mes_keleyi_com);
Console.WriteLine("高{0},宽{1}", image.Height, image.Width);
Console.WriteLine("更多信息请访问keleyi.com,按任意健退出 - 柯乐义");
Console.ReadKey();
}
}
}

 

原文:http://keleyi.com/a/bjac/f37p93cv.htm

posted on 2013-07-19 10:05  计划  阅读(4803)  评论(4编辑  收藏  举报