Exemplo n.º 1
0
        private void picguardar_Click(object sender, EventArgs e)
        {
            var bmp  = new Bitmap(Pantalla.Width, Pantalla.Height);
            var g    = Graphics.FromImage(bmp);
            var rect = Pantalla.RectangleToScreen(Pantalla.ClientRectangle);

            g.CopyFromScreen(rect.Location, Point.Empty, Pantalla.Size);
            g.Dispose();
            var s = new SaveFileDialog();

            s.Filter = "Png files|*.png|jpeg files|*jpg|bitmaps|*.bmp";
            if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (File.Exists(s.FileName))
                {
                    File.Delete(s.FileName);
                }
                if (s.FileName.Contains(".jpg"))
                {
                    bmp.Save(s.FileName, ImageFormat.Jpeg);
                }
                else if (s.FileName.Contains(".png"))
                {
                    bmp.Save(s.FileName, ImageFormat.Png);
                }
                else if (s.FileName.Contains(".bmp"))
                {
                    bmp.Save(s.FileName, ImageFormat.Bmp);
                }
            }
        }