Home:ALL Converter>Issue while saving clipboard data as image

Issue while saving clipboard data as image

Ask Time:2014-12-21T14:58:15         Author:slash shogdhe

Json Formatter

I have copied some data in Clipboard using MS-Word Com API

Range.CopyAsPicture();

and when I am pasting(Ctrl + v) it on window's paint software its getting displayed.

Issue is while converting Clipboard data to image Using c# I looked into various link on internet and tried following code which is not working

MemoryStream ms = Clipboard.GetData("DeviceIndependentBitmap") as MemoryStream;

above line returning null

clipboardData.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap)

Above line returning false

Can anyone please suggest how can convert the clipboard data to image.

Author:slash shogdhe,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/27587373/issue-while-saving-clipboard-data-as-image
JoefGoldstein :

If all you are looking for is getting the bitmap of the image in the clipboard (or the underlying binary data), look into using GetImage.\nHere is a code snippet you can try:\n\n BitmapSource bmpSource = Clipboard.GetImage();\n MemoryStream ms = new MemoryStream();\n BitmapEncoder encoder = new PngBitmapEncoder();\n encoder.Frames.Add(BitmapFrame.Create(bmpSource));\n encoder.Save(ms);\n ms.Seek(0, SeekOrigin.Begin);\n\n\nIn case that also doesn't seem to work, you can try looking into this workaround, it doesn't seem directly related, but it might be just what you need.",
2014-12-21T08:57:39
yy