bitmap参数无效是怎么回事啊?
public partial class Form1 : Form
{
Bitmap bit;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bit = new Bitmap("heart.bmp");
bit.MakeTransparent(Color.Blue);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage((Image)bit, new Point(0, 0));
}
private void label1_Click(object sender, EventArgs e)
{
this.Close();
}
}
heart是电脑里面存在的图片,但是运行时总说参数无效,请问是什么原因啊?
------解决方案-------------------- bit = new Bitmap("heart.bmp");
你这么写要把图片放到bin目录下。不然路径就从盘符开始c:/heart.bmp这个样子写全。