2013年5月31日 星期五
[.NET][C#] 顯示圖片
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ImageForm MyImage = new ImageForm(@"D:\123.png");
MyImage.Show();
}
}
class ImageForm : Form
{
Image image;
public ImageForm(string FilePath)
{
image = Image.FromFile(FilePath);
this.Text = FilePath;
MessageBox.Show(image.RawFormat.ToString());
}
protected override void OnPaint(PaintEventArgs e)
{
this.Height = image.Height;
this.Width = image.Width;
e.Graphics.DrawImage(image, 0, 0, Width, Height);
}
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言