作者ideaup (ideaupsoho)
看板C_Sharp
标题Re: [问题] 绘图与部分绘图
时间Fri Feb 13 18:59:32 2009
我把某个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