private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { var bmp = SnippingTool.Snip(); this.Opacity = 1; // Shows dialog window while uploading if (bmp != null) { try { imgur.PostImage(bmp, ImageFormat.Png); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public static Image Snip() { //var rc = Screen.PrimaryScreen.Bounds; using (Bitmap bmp = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height , System.Drawing.Imaging.PixelFormat.Format32bppPArgb)) { using (Graphics gr = Graphics.FromImage(bmp)) gr.CopyFromScreen(SystemInformation.VirtualScreen.Left, SystemInformation.VirtualScreen.Top, 0, 0, bmp.Size); using (var snipper = new SnippingTool(bmp, new Point(SystemInformation.VirtualScreen.Left, SystemInformation.VirtualScreen.Top))) { if (snipper.ShowDialog() == DialogResult.OK) { return snipper.Image; } } return null; } }
public static Image Snip() { //var rc = Screen.PrimaryScreen.Bounds; using (Bitmap bmp = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height , System.Drawing.Imaging.PixelFormat.Format32bppPArgb)) { using (Graphics gr = Graphics.FromImage(bmp)) gr.CopyFromScreen(SystemInformation.VirtualScreen.Left, SystemInformation.VirtualScreen.Top, 0, 0, bmp.Size); using (var snipper = new SnippingTool(bmp, new Point(SystemInformation.VirtualScreen.Left, SystemInformation.VirtualScreen.Top))) { if (snipper.ShowDialog() == DialogResult.OK) { return(snipper.Image); } } return(null); } }