public static void chargerImage(etat e, FormControlePrintScreen form) { switch (e) { case etat.initial: form.Hide(); System.Threading.Thread.Sleep(250); FormWindowScreen formWS = new FormWindowScreen(); formWS.ShowDialog(); break; case etat.fonctionnement: using (MemoryStream s = new MemoryStream()) { try { //save graphic variable into memory FormControlePrintScreen.imprimeEcran.Save(s, ImageFormat.Bmp); form.pictureBoxMain.Size = new System.Drawing.Size(form.Width, form.Height); //set the picture box with temporary stream form.pictureBoxMain.Image = Image.FromStream(s); } catch (Exception ex) { MessageBox.Show(ex.GetType().ToString()); } finally { } } break; } }
private void FormControlePrintScreen_Load(object sender, EventArgs e) { this.etatModeImage = modeImage.center; this.buttonMode.Text = "Zoomer"; FormControlePrintScreen.chargerImage(etat.initial, this); this.Focus(); }
private void SaveToClipboard() { //valide si une selection existe if (selectLargeur > 0 && selectHauteur > 0) { Rectangle rect = new Rectangle(postionX0, positionY0, selectLargeur, selectHauteur); Bitmap OriginalImage = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height); Bitmap _img = new Bitmap(selectLargeur, selectHauteur); Graphics g = Graphics.FromImage(_img); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.DrawImage(OriginalImage, 0, 0, rect, GraphicsUnit.Pixel); FormControlePrintScreen.imprimeEcran = _img; FormControlePrintScreen.chargerImage(FormControlePrintScreen.etat.fonctionnement, FormControlePrintScreen.formMainCapture); FormControlePrintScreen.formMainCapture.Show(); FormControlePrintScreen.formMainCapture.Focus(); this.Close(); } }