2010-05-20 205 views

回答

3

是,使用一個Bitmap對每個「層」和每個位圖的繪製到面板上。

您可以通過以特定順序撥打DrawImage來控制哪個「層」處於頂層。

例如:

private void panel1_Paint(object sender, PaintEventArgs e) 
{ 
    Bitmap bmp1 = new Bitmap(panel1.Width, panel1.Height); 
    Bitmap bmp2 = new Bitmap(panel1.Width, panel1.Height); 

    Graphics g1 = Graphics.FromImage(bmp1); 
    Graphics g2 = Graphics.FromImage(bmp2); 

    g1.FillRectangle(Brushes.Red, 10, 10, 100, 100); 
    g2.FillEllipse(Brushes.Blue, 20, 20, 100, 100); 

    e.Graphics.DrawImage(bmp1, 0, 0); 
    e.Graphics.DrawImage(bmp2, 0, 0); 
} 
+0

感謝,這工作。 – jwdehaan 2010-05-20 20:41:13