将窗体或窗体上某控件保存为图片
void SaveControlImage(Control c, string file)
{
int w = c.Size.Width;
int h = c.Size.Height;
using (Bitmap bmp = new Bitmap(w, h)) {
c.DrawToBitmap(bmp, new Rectangle(0, 0, w, h));
bmp.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
哈哈哈~ 超级简单,但是很多时候搞个窗体截图用得到:)
{
int w = c.Size.Width;
int h = c.Size.Height;
using (Bitmap bmp = new Bitmap(w, h)) {
c.DrawToBitmap(bmp, new Rectangle(0, 0, w, h));
bmp.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}