我把某個program 的程式, 列出
Image mapImage;
Bitmap map;
Graphics graph,xgraph;
=========Form--Load---Event need Add
xgraph=pictureBox1.CreateGraphics();
ww=pictureBox1.Width; hh=pictureBox1.Height;
src=dest=new Rectangle(0, 0, ww, hh);
map=new Bitmap(ww, hh);
mapImage=Image.FromHbitmap(map.GetHbitmap());
graph=Graphics.FromImage(mapImage);
}
private void pictureBox1_Paint(object sender, PaintEventArgs e) {
if (mapImage==null) return;
try {
e.Graphics.DrawImage(mapImage, dest, src, GraphicsUnit.Pixel);
}
catch(Exception ) { throw; }
}
private void pictureBox1_Resize(object sender, EventArgs e) {
if (mapImage==null) return;
int wd=pictureBox1.Width, ht=pictureBox1.Height;
SetSize(wd,ht);
dest=new Rectangle(0, 0, wd, ht);
if (xgraph==null) game.xgraph=pictureBox1.CreateGraphics();
xgraph.DrawImage(mapImage, dest, src, GraphicsUnit.Pixel);
}
Timer_Click() {
//在graph上 draw, fill 各樣rectangle, ellipse,
xgraph.DrawImage(mapImage, dest, src, GraphicsUnit.Pixel);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.114.246.17