using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Imaging; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.ClientSize = new Size( Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)); string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Bitmap bmp = new Bitmap( this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Format32bppArgb); FormBorderStyle f = this.FormBorderStyle; this.FormBorderStyle = FormBorderStyle.None; this.DrawToBitmap(bmp, new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height)); bmp.Save(path + "\\test.png", ImageFormat.Png); this.FormBorderStyle = f; } } }