示例#1
0
        private void cropFromScreenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //this.Visible = false;
            var bmp = SnippingTool.Snip();

            if (bmp != null)
            {
                picBox.Image = bmp;
            }
            //this.Visible = true;
        }
示例#2
0
        public static Image Snip()
        {
            var rc = Screen.PrimaryScreen.Bounds;

            using (Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)) {
                using (Graphics gr = Graphics.FromImage(bmp))
                    gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                using (var snipper = new SnippingTool(bmp)) {
                    if (snipper.ShowDialog() == DialogResult.OK)
                    {
                        return(snipper.Image);
                    }
                }
                return(null);
            }
        }