读出图片
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());

}