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.
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