我想在圖片框中繪製圖像,並且圖像沒有繪出我的代碼出了什麼問題?謝謝帶圖形C的圖像繪製#
Bitmap b;
private void Form1_Load(object sender, EventArgs e)
{
b = new Bitmap(1000, 100);
pictureBox1.Image = b;
Graphics g = pictureBox1.CreateGraphics();
Rectangle rect = new Rectangle(20, 20, 70, 70);
Image earth = Image.FromFile("" + System.IO.Directory.GetCurrentDirectory() + @"\earth.png");
g.DrawImage(earth,rect);
}
切勿使用CreateGraphics。使用PictureBox的Paint事件來獲取圖形對象。 – LarsTech