WinForm之GDI手動雙緩沖技術
阿新 • • 發佈:2019-04-28
angle bsp rec graphics pict 就是 winform file bit
private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp=new Bitmap(this.picturebox.Width,this.picturebox.Height); //在內存中創建一個bmp圖,bmp的大小和窗口中picturebox的大小相同
Graphics g=Graphics.FromImage(bmp); //通過內存中的bmp圖像創建一個在內存中的畫布g,那麽在畫布上的任何操作就都是在內存中操作了
Brush b = new SolidBrush(Color.Green); //創建一個綠色的筆刷
Rectangle r = new Rectangle(10,10,this.picturebox.Width,this.picturebox.Height); //創建一個長方形
g.FileRectangle(b,r); //在內存中的畫布中畫我們要畫的圖形
b.Dispose(); //釋放畫筆
g.Dispose(); //釋放畫布
this.picturebox.CreateGraphics().DrawImage(bmp,0,0); //最後就是我們手動雙緩沖技術的 最後一步了,就是將內存中的bmp的圖像一次性的展示到窗口中的picturebox中
}
WinForm之GDI手動雙緩沖技術