Here are the examples of the csharp api class System.Windows.Forms.Clipboard.GetImage() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
24 Examples
0
1. Example
View licensepublic static BitmapSource GetWpfImage() { return WinForms.Clipboard.GetImage().ToWpfBitmap(); }
0
2. Example
View licensepublic static Image GetImage() { try { lock (ClipboardLock) { if (HelpersOptions.UseAlternativeGetImage) { return GetImageAlternative(); } return Clipboard.GetImage(); } } catch (Exception e) { DebugHelper.WriteException(e, "Clipboard get image failed."); } return null; }
0
3. Example
View licenseprivate ImageContent getImageContentFromClipboard() { ImageContent contentToReturn = new ImageContent(); contentToReturn.index = view.ImageRowCount + 1; contentToReturn.image = Clipboard.GetImage(); contentToReturn.time = System.DateTime.Now.ToShortTimeString(); return contentToReturn; }
0
4. Example
View licenseprivate void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e) { Image img = Clipboard.GetImage(); if (img != null) { if (DefaultImage != null) DefaultImage.Dispose(); DefaultImage = img; UpdatePreview(); } }
0
5. Example
View licensepublic void loadClipboard() { IDataObject iData = Clipboard.GetDataObject(); if (iData.GetDataPresent(DataFormats.Bitmap)) { lastFile = ""; fileLoaded = true; loadedImage = new Bitmap(Clipboard.GetImage()); originalImage = new Bitmap(Clipboard.GetImage()); processLoading(); } }
0
6. Example
View licenseprivate void PasteButton_Click(System.Object sender, System.EventArgs e) { try { if (Clipboard.ContainsImage()) { this.unpackers.Clear(); this.DragAndDropLabel.Visible = false; this.ControlsHelpLabel.Visible = false; this.CreateUnpacker(new Bitmap(Clipboard.GetImage()), "clipboard"); this.StartUnpackers(); } else { MessageBox.Show("No image found in Clipboard"); } } catch (Exception ex) { ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "[email protected]"); } }
0
7. Example
View licenseprivate static Image GetImage(IDataObject dataObject) { Image returnImage = null/n ..... /n //View Source file for more details /n }
0
8. Example
View licensepublic static void OpenImageEditor(string filePath = null) { if (string.IsNullOrEmpty(filePath)) { if (Clipboard.ContainsImage() && MessageBox.Show(Resources.TaskHelpers_OpenImageEditor_Your_clipboard_contains_image, Resources.TaskHelpers_OpenImageEditor_Image_editor___How_to_load_image_, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (Image img = Clipboard.GetImage()) { if (img != null) { AnnotateImage(img, null); return; } } } filePath = ImageHelpers.OpenImageFileDialog(); } if (!string.IsNullOrEmpty(filePath)) { AnnotateImage(filePath); } }
0
9. Example
View licensepublic void IconClicked(HTMLEditorButtonArgs doc) { var image = Clipboard.GetImage(); if (image != null) { using (var memoryStream = new MemoryStream()) { image.Save(memoryStream, ImageFormat.Png); var base64 = Convert.ToBase64String(memoryStream.ToArray()); var html = string.Format("<img src=\"data:image/png;base64,{0}\" alt=\"{1}\" />", base64, Guid.NewGuid()); var insertHtmlButton = new InsertHtmlButton(html); insertHtmlButton.IconClicked(doc); } } else { MessageBox.Show(Resources.NoImageInClipboard, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
0
10. Example
View licenseinternal 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; }
0
11. Example
View licenseprivate static IList<object> LoadClipboardPicture() { try { Logger.Log("Load clipboard begins."); var result = new List<object>(); if (Clipboard.ContainsImage()) { result.Add(Clipboard.GetImage()); } if (Clipboard.ContainsFileDropList()) { result.Add(Clipboard.GetFileDropList()); } if (Clipboard.ContainsText()) { result.Add(Clipboard.GetText()); } Logger.Log("Load clipboard done."); return result; } catch (Exception e) { // sometimes Clipboard may fail Logger.LogException(e, "LoadClipboardPicture"); return new List<object>(); } }
0
12. Example
View licenseBitmap GetBitmap() { switch (CaptureMethod) { case ECapture.Clipboard: { while (!Clipboard.ContainsImage()) Thread.Sleep(50); Bitmap ret = (Bitmap)Clipboard.GetImage(); Clipboard.Clear(); return ret; } case ECapture.ScreenShoot: { Rectangle bounds = Screen.GetBounds(Point.Empty); Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height); using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } return bitmap; } } return null; }
0
13. Example
View licensepublic static Bitmap GetImage() { Bitmap result; // http://csharphelper.com/blog/2014/09/paste-a-png-format-image-with-a-transparent-background-from-the-clipboard-in-c/ result = null; try { if (Clipboard.ContainsData(PngFormat)) { object data; data = Clipboard.GetData(PngFormat); if (data != null) { Stream stream; stream = data as MemoryStream; if (stream == null) { byte[] buffer; buffer = data as byte[]; if (buffer != null) { stream = new MemoryStream(buffer); } } if (stream != null) { result = Image.FromStream(stream).Copy(); stream.Dispose(); } } } if (result == null) { result = (Bitmap)Clipboard.GetImage(); } } catch (Exception ex) { MessageBox.Show(string.Format("Failed to obtain image. {0}", ex.GetBaseException().Message), "Paste Image", MessageBoxButtons.OK, MessageBoxIcon.Error); } return result; }
0
14. Example
View licenseprivate void btnImg_Click(object sender, EventArgs e) { int i = 0; var imgObj = Clipboard.GetImage(); var dataStr = GetHtmlStr(); int fileCount = GetFileDrop(); if (imgObj != null)//?HTML????? { CreateDirectory("Images"); imgObj.Save(string.Format(@"Images\{0}.png", GetNewName()), ImageFormat.Png); MessageBox.Show("???????Images????", "??????"); OpenDirectory(); } else if (!string.IsNullOrEmpty(dataStr)) { Stopwatch watch = new Stopwatch(); watch.Start(); i = DownloadImg(dataStr); watch.Stop(); MessageBox.Show(string.Format("????{0}???,??{1}????Images???", i, watch.Elapsed), "??????"); OpenDirectory(); } else if (fileCount > 0) { MessageBox.Show(string.Format("????{0}???,???Images???", fileCount), "??????"); OpenDirectory(); } else { MessageBox.Show("??????????", "??????"); } }
0
15. Example
View licenseprivate void ClipboardContentViewer_Load(object sender, EventArgs e) { pbClipboa/n ..... /n //View Source file for more details /n }
0
16. Example
View licensepublic static void GetFromClipboard() { Image image = null; // Load the image from a copied image if (Clipboard.ContainsImage()) { Log.Write(l.Info, "Clipboard mode, copied image"); image = Clipboard.GetImage(); } // Load the image from a copied image file else if (Clipboard.ContainsFileDropList()) { Log.Write(l.Info, "Clipboard mode, file list"); foreach (var localFile in Clipboard.GetFileDropList()) { SaveImage(localFile); } // raise CaptureComplete to start uploading CaptureComplete(null, EventArgs.Empty); } // Load the image from a copied image url else if (Common.ImageUrlInClipboard) { var url = Clipboard.GetText(); Log.Write(l.Info, $"Clipboard mode, url: {url}"); image = GetFromUrl(url); } // Prevent null reference exception if (image == null) return; Common.OtherFormOpen = true; SaveImage(image); }
0
17. Example
View licenseprivate void ClipboardContentViewer_Load(object sender, EventArgs e) { pbClipboa/n ..... /n //View Source file for more details /n }
0
18. Example
View licenseprivate void HandlePastedPicture(bool isUsingWinformMsgBox = false) { try /n ..... /n //View Source file for more details /n }
0
19. Example
View licenseprivate void mnuMainOpenImageData_Click(object sender, EventArgs e) { //Is there/n ..... /n //View Source file for more details /n }
0
20. Example
View licensepublic static Image GetImageFromClipboard() { var dataObject = Clipboard.GetDataObject(); if (dataObject == null) return null; if (dataObject.GetDataPresent(DataFormats.Dib)) { var dib = ((MemoryStream) Clipboard.GetData(DataFormats.Dib)).ToArray(); var width = BitConverter.ToInt32(dib, 4); var height = BitConverter.ToInt32(dib, 8); var bpp = BitConverter.ToInt16(dib, 14); if (bpp == 32) { var gch = GCHandle.Alloc(dib, GCHandleType.Pinned); Bitmap bmp = null; try { var ptr = new IntPtr((long) gch.AddrOfPinnedObject() + 40); bmp = new Bitmap(width, height, width*4, PixelFormat.Format32bppArgb, ptr); var newBmp = new Bitmap(bmp); newBmp.RotateFlip(RotateFlipType.Rotate180FlipX); return newBmp; } finally { gch.Free(); bmp?.Dispose(); } } } return Clipboard.ContainsImage() ? Clipboard.GetImage() : null; }
0
21. Example
View licensevoid GetClipboardContents() { if (_image) { if (WinF/n ..... /n //View Source file for more details /n }
0
22. Example
View licensepublic static byte[] ComputeHash() { try // This works always or never { bool bOpened = /n ..... /n //View Source file for more details /n }
0
23. Example
View license[STAThread] static void Main(string[] args) { if (args.Length == 0) { /n ..... /n //View Source file for more details /n }
0
24. Example
View licensepublic static void ClipboardUpload(TaskSettings taskSettings = null) { if (taskS/n ..... /n //View Source file for more details /n }