Esempio n. 1
0
        //private void CloseForms()
        //{
        //    for (int i = 0; i < _forms.Length; i++) {
        //        _forms[i].Dispose();
        //    }
        //}
        #endregion

        public static System.Drawing.Image Snip()
        {
            var rc = Screen.PrimaryScreen.Bounds;

            using (Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format24bppRgb))
            {
                using (Graphics gr = Graphics.FromImage(bmp))
                {
                    gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                }
                using (var snipper = new SnippingTool(bmp, new Rectangle(0, 0, 0, 0), 0))
                {
                    if (snipper.ShowDialog() == DialogResult.OK)
                    {
                        return(snipper.Image);
                    }
                }
                return(null);
            }
        }
Esempio n. 2
0
 public static System.Drawing.Image SnipRect(Rectangle limitedRect, int margine, ref Rectangle margineRect, ref Rectangle snipedRect)
 {
     using (Bitmap bmp = new Bitmap(limitedRect.Width, limitedRect.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb))
     {
         using (Graphics gr = Graphics.FromImage(bmp))
         {
             gr.CopyFromScreen(limitedRect.X, limitedRect.Y, 0, 0, bmp.Size);
         }
         using (var snipper = new SnippingTool(bmp, limitedRect, margine))
         {
             if (snipper.ShowDialog() == DialogResult.OK)
             {
                 snipedRect  = _Selection;
                 margineRect = _margineRect;
                 return(snipper.Image);
             }
         }
         return(null);
     }
 }