public static Image Snip() { var rc = Screen.PrimaryScreen.Bounds; //MessageBox.Show(rc.ToString() ); 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); // bmp.Save("d:\\file.jpg", ImageFormat.Jpeg); using (var snipper = new SnippingTool(bmp)) { if (snipper.ShowDialog() == DialogResult.OK) { return snipper.Image; } } return null; } }
public static Image Snip() { var rc = Screen.PrimaryScreen.Bounds; //MessageBox.Show(rc.ToString() ); 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); // bmp.Save("d:\\file.jpg", ImageFormat.Jpeg); using (var snipper = new SnippingTool(bmp)) { if (snipper.ShowDialog() == DialogResult.OK) { return(snipper.Image); } } return(null); } }
private void addImage() { snippingOn = true; this.Hide(); var bmp = SnippingTool.Snip(); if (bmp != null) { string path; if (Properties.Settings.Default.savepath == "") { string pathPictures = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); path = Path.Combine(pathPictures, "SnipDock"); Directory.CreateDirectory(path); } else { path = Properties.Settings.Default.savepath; } bmp.Save(Path.Combine(path, DateTime.Now.ToString("yyyyMMddTHHmmss") + ".png"), ImageFormat.Png); if (docksnips) { this.pictureBox1.Image = bmp; this.pictureBox1.Size = new System.Drawing.Size(bmp.Width + 10, bmp.Height + 10); this.pictureBox1.Image = bmp; this.Size = new Size(bmp.Width, this.Height); if (bmp.Width > 320) { move_items_top(); } } } snippingOn = false; this.Show(); }