读出图片
this.pictureBox1.Image = null;
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open JPG" ;
dlg.Filter = "jpg files (*.img)|*.img" ;
if(dlg.ShowDialog() == DialogResult.OK)
{
try
{
Image i = Image.FromFile(dlg.FileName);
this.pictureBox1.Image = i;
MessageBox.Show("高:"+i.Size.Height.ToString()+" 宽:"+i.Size.Width.ToString());
}
catch(System.OutOfMemoryException error)
{
MessageBox.Show("这就是强行打开非jpg文件格式的异常:"+error.Message.ToString());
}
}
this.pictureBox1.Image = null;
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open JPG" ;
dlg.Filter = "jpg files (*.img)|*.img" ;
if(dlg.ShowDialog() == DialogResult.OK)
{
try
{
Image i = Image.FromFile(dlg.FileName);
this.pictureBox1.Image = i;
MessageBox.Show("高:"+i.Size.Height.ToString()+" 宽:"+i.Size.Width.ToString());
}
catch(System.OutOfMemoryException error)
{
MessageBox.Show("这就是强行打开非jpg文件格式的异常:"+error.Message.ToString());
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货