System.Windows.Forms.Clipboard.SetImage(System.Drawing.Image)

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.SetImage(System.Drawing.Image) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

40 Examples 7

1. Example

Project: SeleniumBasic
Source File: ClipboardExt.cs
public static void SetImage(Bitmap value) {
            ThreadExt.RunSTA(() => {
                Clipboard.SetImage(value);
                return 0;
            }, 6000);
        }

2. Example

Project: Baka-MPlayer-old
Source File: SnapshotForm.cs
private void copyLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Clipboard.SetImage(SnapshotImage);
        }

3. Example

Project: Kuriimu
Source File: Converter.cs
private void cmsPreviewCopy_Click(object sender, EventArgs e)
        {
            Clipboard.SetImage(imbPreview.Image);
        }

4. Example

Project: Kuriimu
Source File: Editor.cs
private void tsbPreviewCopy_Click(object sender, EventArgs e)
        {
            Clipboard.SetImage(pbxPreview.Image);
        }

5. Example

Project: ImageVisualizer
Source File: Helpers.cs
public static void CopyImage(Image img)
        {
            if (img != null)
            {
                Clipboard.SetImage(img);
            }
        }

6. Example

Project: PKHeX
Source File: QR.cs
private void PB_QR_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Copy QR Image to Clipboard?")) return;
            try { Clipboard.SetImage(PB_QR.BackgroundImage); }
            catch { WinFormsUtil.Alert("Failed to set Image to Clipboard"); }
        }

7. Example

Project: HEIF-Utility
Source File: MainWindow.cs
private void ??ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Clipboard.SetImage(MainPictureBox.Image);
            }
            catch (Exception) { }
        }

8. Example

Project: HEIF-Utility
Source File: MainWindow.cs
private void ??ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Clipboard.SetImage(MainPictureBox.Image);
            }
            catch (Exception) { }
        }

9. Example

Project: mRemoteNG
Source File: ScreenshotManagerWindow.cs
private void CopyImageToClipboard()
		{
			try
			{
				Clipboard.SetImage(((PictureBox) cMenScreenshot.Tag).Image);
			}
			catch (Exception ex)
			{
				Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "CopyImageToClipboard (UI.Window.ScreenshotManager) failed" + Environment.NewLine + ex.Message, true);
			}
		}

10. Example

Project: HTML-Renderer
Source File: WinFormsAdapter.cs
protected override void SetToClipboardInt(RImage image)
        {
            Clipboard.SetImage(((ImageAdapter)image).Image);
        }

11. Example

Project: QPAS
Source File: PlotExtensions.cs
public static void CopyToClipboard(this PlotView plot)
        {
            if (plot == null) return;

            BitmapSource bmp = plot.ToBitmap();
            Clipboard.SetImage(bmp.ToBitmap());
        }

12. Example

Project: Wolven-kit
Source File: frmImagePreview.cs
private void copyImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Clipboard.SetImage(ImagePreviewControl.Image);
        }

13. Example

Project: TweetDuck
Source File: FormNotificationScreenshotable.cs
public void TakeScreenshot(){
            IntPtr context = NativeMethods.GetDC(this.Handle);

            if (context == IntPtr.Zero){
                FormMessage.Error("Screenshot Failed", "Could not retrieve a graphics context handle for the notification window to take the screenshot.", FormMessage.OK);
            }
            else{
                using(Bitmap bmp = new Bitmap(ClientSize.Width, ClientSize.Height, PixelFormat.Format32bppRgb)){
                    try{
                        NativeMethods.RenderSourceIntoBitmap(context, bmp);
                    }finally{
                        NativeMethods.ReleaseDC(this.Handle, context);
                    }

                    Clipboard.SetImage(bmp);
                }
            }
        }

14. Example

Project: dp2
Source File: CameraClipDialog.cs
private void toolStripButton_copy_Click(object sender, EventArgs e)
        {
            string strError = "";
            if (this.tabControl_main.SelectedTab == this.tabPage_preview)
            {
                if (this.qrRecognitionControl1.Image == null)
                {
                    strError = "?????????";
                    goto ERROR1;
                }
                Clipboard.SetImage(this.qrRecognitionControl1.Image);
            }
            if (this.tabControl_main.SelectedTab == this.tabPage_clip)
            {
                if (this.pictureBox_clip.Image == null)
                {
                    strError = "?????????";
                    goto ERROR1;
                }
                Clipboard.SetImage(this.pictureBox_clip.Image);
            }
            if (this.tabControl_main.SelectedTab == this.tabPage_result)
            {
                if (this.pictureBox_result.Image == null)
                {
                    strError = "?????????";
                    goto ERROR1;
                }
                Clipboard.SetImage(this.pictureBox_result.Image);
            }
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }

15. Example

Project: ElectronicObserver
Source File: DialogShipGraphicViewer.cs
private void TopMenu_File_CopyToClipboard_Click(object sender, EventArgs e)
		{
			if (CurrentImage == null)
			{
				System.Media.SystemSounds.Exclamation.Play();
				return;
			}

			try
			{

				Clipboard.SetImage(CurrentImage);

			}
			catch (Exception)
			{

				System.Media.SystemSounds.Exclamation.Play();
			}
		}

16. Example

Project: mwinapi
Source File: ScreenshotForm.cs
private void copyButton_Click(object sender, EventArgs e)
        {
            Clipboard.Clear();
            Clipboard.SetImage(picture.Image);
        }

17. Example

Project: Cyotek.Windows.Forms.ImageBox
Source File: GeneralDemoForm.cs
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
    {
      try
      {
        Clipboard.Clear();
        Clipboard.SetImage(imageBox.GetSelectedImage() ?? imageBox.Image);
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }

18. Example

Project: DarkHider
Source File: Form1.cs
private void bunifuImageButton3_Click(object sender, EventArgs e)
        {
            try { 
            Clipboard.SetImage(MainPictureBox.Image);
            }
            catch(Exception ex)
            {
                MessageBox.Show("Open an Image first !");
                Console.WriteLine(ex);
            }
        }

19. Example

Project: My-FyiReporting
Source File: RdlViewer.cs
public void Copy()
        {
            if (!CanCopy)
                return;

            Image im = _DrawPanel.SelectImage;
            if (im == null)
                Clipboard.SetDataObject(SelectText, true);
            else
            {
                Clipboard.SetImage(im);
                im.Dispose();
            }
        }

20. Example

Project: Write-into-screen
Source File: Screenshot.cs
public static void CaptureImage(Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle)
        {

            using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
            {

                using (Graphics g = Graphics.FromImage(bitmap))
                {

                    g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);

                }
                    Image img = (Image)bitmap;
                    Clipboard.SetImage(img);
            }
        }

21. Example

Project: fabiano-swagger-of-doom
Source File: Test.cs
public static void Show(Image img)
        {
            Form frm = new Form
            {
                ClientSize = new Size(800, 800),
                BackColor = Color.Black,
                WindowState = FormWindowState.Maximized
            };
            PictureBox pic;
            frm.Controls.Add(pic = new PictureBox
            {
                Dock = DockStyle.Fill,
                Image = img,
                SizeMode = PictureBoxSizeMode.Zoom
            });
            pic.DoubleClick += (sender, e) => { Clipboard.SetImage(img); };
            frm.ShowDialog();
        }

22. Example

Project: EDDiscovery
Source File: ScreenShotConverter.cs
private void ConvertCompleted(ScreenShotImageConverter cp) // Called by the watcher when a convert had completed, in UI thread
        {
            System.Diagnostics.Debug.Assert(Application.MessageLoop);

            if (cp.Converted && cp.CopyToClipboard)
            {
                using (Image bmp = Bitmap.FromFile(cp.OutputFilename))
                {
                    try
                    {
                        Clipboard.SetImage(bmp);
                    }
                    catch
                    {
                        discoveryform.LogLineHighlight("Copying image to clipboard failed");
                    }
                }
            }

            OnScreenShot?.Invoke(cp.OutputFilename, cp.FinalSize);
        }

23. Example

Project: PowerPointLabs
Source File: PictureSlidesLabWindowViewModel.cs
private static void SaveClipboardPicture(IList<object> copiedObjs)
        {
            try
            {
                Logger.Log("Save clipboard begins.");
                foreach (var copiedObj in copiedObjs)
                {
                    if (copiedObj == null)
                    {
                        continue;
                    }

                    if (copiedObj is Image)
                    {
                        Clipboard.SetImage((Image)copiedObj);
                    }
                    else if (copiedObj is StringCollection)
                    {
                        Clipboard.SetFileDropList((StringCollection)copiedObj);
                    }
                    else if (!string.IsNullOrEmpty(copiedObj as string))
                    {
                        Clipboard.SetText((string)copiedObj);
                    }
                }
                Logger.Log("Save clipboard done.");
            }
            catch (Exception e)
            {
                // sometimes Clipboard may fail
                Logger.LogException(e, "SaveClipboardPicture");
            }
        }

24. Example

Project: Pscx
Source File: SetClipboardCommand.cs
protected override void EndProcessing()
        {
            ExecuteWrite(delegate
            {
                switch (ParameterSetName)
                {
                    case ParamSetFiles:
                        if (_paths.Count == 0)
                            WinFormsClipboard.Clear();
                        else
                            WinFormsClipboard.SetFileDropList(_paths);
                        break;

                    case ParamSetImage:
                        if (_image == null)
                            WinFormsClipboard.Clear();
                        else
                            WinFormsClipboard.SetImage(_image);
                        break;

                    case ParamSetRtf:
                        SetTextContents(_rtf, TextDataFormat.Rtf);
                        break;

                    case ParamSetHtml:
                        SetTextContents(_html, TextDataFormat.Html);
                        break;

                    default:
                        SetTextContents(_text, TextDataFormat.UnicodeText);
                        break;
                }
            });
        }

25. Example

Project: Rubberduck
Source File: CommandBarButton.cs
public void ApplyIcon()
        {
            if (IsWrappingNullReference) return;
            
            Button.FaceId = 0;
            if (Picture == null || Mask == null)
            {
                return;
            }

            if (!HasPictureProperty)
            {
                using (var image = CreateTransparentImage(Picture))
                {
                    Clipboard.SetImage(image);
                    Button.PasteFace();
                    Clipboard.Clear();
                }
                return;
            }

            Button.Picture = AxHostConverter.ImageToPictureDisp(Picture);
            Button.Mask = AxHostConverter.ImageToPictureDisp(Mask);
        }

26. Example

Project: Cropper
Source File: ClipboardFormat.cs
protected override void ImageCaptured(object sender, ImageCapturedEventArgs e)
        {
           /n ..... /n //View Source file for more details /n }

27. Example

Project: ElectronicObserver
Source File: FormBrowser.cs
private void ToolMenu_Other_LastScreenShot_CopyToClipboard_Click(object sender, EventArgs e)
		{

			if (_lastScreenShotPath != null && System.IO.File.Exists(_lastScreenShotPath))
			{
				try
				{
					using (var img = new Bitmap(_lastScreenShotPath))
					{
						Clipboard.SetImage(img);
						AddLog(2, string.Format("????????? {0} ?????????????????", _lastScreenShotPath));
					}
				}
				catch (Exception ex)
				{
					SendErrorReport(ex.Message, "??????????????????????????????");
				}
			}
		}

28. Example

Project: EmbroideryReader
Source File: frmMain.cs
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (DrawArea != null)
            {
                Clipboard.Clear();
                using (Bitmap temp = new Bitmap(DrawArea.Width, DrawArea.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb))
                {
                    using (Graphics tempGraph = Graphics.FromImage(temp))
                    {
                        tempGraph.FillRectangle(Brushes.White, 0, 0, temp.Width, temp.Height);
                        tempGraph.DrawImageUnscaled(DrawArea, 0, 0);
                    }
                    Clipboard.SetImage(temp);
                }
            }
        }

29. Example

Project: vimage
Source File: ImageViewer.cs
public void CopyAsImage()
        {
            Thread thread = new Thread(() =>
            {
                try
                {
                    System.Drawing.Bitmap bitmap;
                    if (File.IndexOf(".ico") == File.Length - 4)
                    {
                        // If .ico - copy largest version
                        System.Drawing.Icon icon = new System.Drawing.Icon(File, 256, 256);
                        bitmap = Graphics.ExtractVistaIcon(icon);
                        if (bitmap == null)
                            bitmap = icon.ToBitmap();
                    }
                    else
                        bitmap = new System.Drawing.Bitmap(File);
                    Clipboard.SetImage(bitmap);
                }
                catch (Exception) { }
            });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }

30. Example

Project: Cropper
Source File: ImageCapture.cs
private void CaptureByHdc(IntPtr hdc, bool cropAndColor)
        {
            OnImageCapturing(new ImageCapturingEventArgs());
            using (Image image = NativeMethods.GetDesktopBitmap(hdc, cropAndColor, Color.FromArgb(Configuration.Current.NonFormAreaColorArgb)))
            {
                if (Configuration.Current.LeavePrintScreenOnClipboard)
                    Clipboard.SetImage(image);

                ImageCapturedEventArgs imageCapturedEventArgs = ProcessCapturedImage(image, 0.0);
                OnImageCaptured(imageCapturedEventArgs);
            }
        }

31. Example

Project: NClass
Source File: ImageCreator.cs
public static void CopyAsImage(IPrintable document, bool selectedOnly)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			RectangleF areaF = document.GetPrintingArea(true);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			using (Bitmap image = new Bitmap(area.Width, area.Height, PixelFormat.Format24bppRgb))
			using (Graphics g = Graphics.FromImage(image))
			{
				// Set drawing parameters
				g.SmoothingMode = SmoothingMode.HighQuality;
				if (DiagramEditor.Settings.Default.UseClearTypeForImages)
					g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				else
					g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
				g.TranslateTransform(-area.Left, -area.Top);

				// Draw image
				g.Clear(Style.CurrentStyle.BackgroundColor);
				IGraphics graphics = new GdiGraphics(g);
				document.Print(graphics, selectedOnly, Style.CurrentStyle);

				try
				{
					System.Windows.Forms.Clipboard.SetImage(image);
				}
				catch
				{
					//UNDONE: exception handling of CopyAsImage()
				}
			}
		}

32. Example

Project: optimizer
Source File: Integrator.cs
internal static string ExtractIconFromExecutable(string itemName, string fileName)
        {
            string iconPath = string.Empty;

            if (File.Exists(fileName))
            {
                Icon ico = Icon.ExtractAssociatedIcon(fileName);

                Clipboard.SetImage(ico.ToBitmap());
                Clipboard.GetImage().Save(Required.ExtractedIcons + "\\" + itemName + ".ico", ImageFormat.Bmp);
                Clipboard.Clear();

                iconPath = Required.ExtractedIcons + "\\" + itemName + ".ico";
            }

            return iconPath;
        }

33. Example

Project: NClass
Source File: ImageCreator.cs
public static void CopyAsImage(IPrintable document, bool selectedOnly)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			RectangleF areaF = document.GetPrintingArea(true);
			areaF.Offset(0.5F, 0.5F);
			Rectangle area = Rectangle.FromLTRB((int) areaF.Left, (int) areaF.Top,
				(int) Math.Ceiling(areaF.Right), (int) Math.Ceiling(areaF.Bottom));

			using (Bitmap image = new Bitmap(area.Width, area.Height, PixelFormat.Format24bppRgb))
			using (Graphics g = Graphics.FromImage(image))
			{
				// Set drawing parameters
				g.SmoothingMode = SmoothingMode.HighQuality;
				if (DiagramEditor.Settings.Default.UseClearTypeForImages)
					g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				else
					g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
				g.TranslateTransform(-area.Left, -area.Top);

				// Draw image
				g.Clear(Style.CurrentStyle.BackgroundColor);
				IGraphics graphics = new GdiGraphics(g);
				document.Print(graphics, selectedOnly, Style.CurrentStyle);

				try
				{
					System.Windows.Forms.Clipboard.SetImage(image);
				}
				catch
				{
					//UNDONE: exception handling of CopyAsImage()
				}
			}
		}

34. Example

Project: Screna
Source File: Extensions.cs
public static void WriteToClipboard(this Bitmap BMP, bool PreserveTransparency = true)
        {
            if (PreserveTransparency)
            {
                using (var pngStream = new MemoryStream())
                {
                    BMP.Save(pngStream, ImageFormat.Png);
                    var pngClipboardData = new DataObject("PNG", pngStream);

                    using (var whiteS = new Bitmap(BMP.Width, BMP.Height, PixelFormat.Format24bppRgb))
                    {
                        using (var graphics = Graphics.FromImage(whiteS))
                        {
                            graphics.Clear(Color.White);
                            graphics.DrawImage(BMP, 0, 0, BMP.Width, BMP.Height);
                        }

                        // Add fallback for applications that don't support PNG from clipboard (eg. Photoshop or Paint)
                        pngClipboardData.SetData(DataFormats.Bitmap, whiteS);

                        Clipboard.Clear();
                        Clipboard.SetDataObject(pngClipboardData, true);
                    }
                }
            }
            else Clipboard.SetImage(BMP);
        }

35. Example

Project: Captura
Source File: Extensions.cs
public static void WriteToClipboard(this Bitmap BMP, bool PreserveTransparency = true)
        {
            if (PreserveTransparency)
            {
                using (var pngStream = new MemoryStream())
                {
                    BMP.Save(pngStream, ImageFormat.Png);
                    var pngClipboardData = new DataObject("PNG", pngStream);

                    using (var whiteS = new Bitmap(BMP.Width, BMP.Height, PixelFormat.Format24bppRgb))
                    {
                        using (var graphics = Graphics.FromImage(whiteS))
                        {
                            graphics.Clear(Color.White);
                            graphics.DrawImage(BMP, 0, 0, BMP.Width, BMP.Height);
                        }

                        // Add fallback for applications that don't support PNG from clipboard (eg. Photoshop or Paint)
                        pngClipboardData.SetData(DataFormats.Bitmap, whiteS);

                        Clipboard.Clear();
                        Clipboard.SetDataObject(pngClipboardData, true);
                    }
                }
            }
            else Clipboard.SetImage(BMP);
        }

36. Example

Project: ElectronicObserver
Source File: FormBrowser.cs
public void SaveScreenShot()
		{

			int savemode = Configuration.ScreenShotSaveMode;
			int format /n ..... /n //View Source file for more details /n }

37. Example

Project: ZXing.Net
Source File: Program.cs
[STAThread]
      static void Main(string[] args)
      {
         if (args.Length == 0)
         {
/n ..... /n //View Source file for more details /n }

38. Example

Project: gInk
Source File: FormDisplay.cs
public void SnapShot(Rectangle rect)
		{
			string snapbasepath = Root.SnapshotBasePath;
			snapbase/n ..... /n //View Source file for more details /n }

39. Example

Project: ElectronicObserver
Source File: DialogFleetImageGenerator.cs
private void ButtonOK_Click(object sender, EventArgs e)
		{

			var args = ApplyToArgument();

			///n ..... /n //View Source file for more details /n }

40. Example

Project: aeroshot
Source File: Screenshot.cs
internal static void CaptureWindow(ref ScreenshotTask data)
        {
            IntPtr start = Win/n ..... /n //View Source file for more details /n }