日期:2014-05-17 浏览次数:20982 次
using System;我是先下载图片,在生成实例bmp,获取bmp的宽度和高度。
using System.Drawing;
using System.Net;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//private static string url = "http://www3.clustrmaps.com/stats/maps-layer/958000/958172/www.cnblogs.com-sun8134--thumb-dots.png";
private static string url = "http://ww2.sinaimg.cn/bmiddle/6128e4c9jw1e8w8ckn6taj20np0hs0uw.jpg";
private static string filepath = "c:\\pic.bmp";
public Form1()
{
InitializeComponent();
pictureBox1.BackColor = Color.Black;
}
private void button1_Click(object sender, EventArgs e)
{
WebClient mywebclient = new WebClient();
mywebclient.DownloadFile(url, filepath);
Bitmap bmp = new Bitmap(filepath);
int w_bmp = bmp.Width;
int h_bmp = bmp.Height;
textBox1.Text = Convert.ToString(w_bmp);
textBox2.Text = Convert.ToString(h_bmp);
pictureBox1.Image = bmp;
}
}
}
using System;
using System.Drawing;
using System.Net;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//private static string&nb