views:

23

answers:

2

I have an image copied to the clicpboard from the word using "Comment.Scope.CopyAsPicture()" How can i find the type of this image in the clipboard, so that i can write the image with proper extension in local file system?

+1  A: 

Using DataFormats.Bitmap you can get this as a bitmap and use the framework functions to save it.

if (iData.GetDataPresent(DataFormats.Bitmap)) Bitmap bImg = (Bitmap)iData.GetData();

Sascha
+2  A: 

In DataFromats we have only Bitmap member...

normally you choose the format to store

IDataObject data = Clipboard.GetDataObject();

if (data.GetDataPresent(DataFormats.Bitmap))
{
  Image image = (data.GetData(DataFormats.Bitmap,true) as Image);

  image.Save("image.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
  image.Save("image.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);

}

but You can create Your own format and use it

DataFormats.Format jepgFormat = DataFormats.GetFormat("jpgFormat");

Image image = new Image(); 
DataObject myDataObject = new DataObject(jpegFormat.Name, image );

// Copies myObject into the clipboard.
Clipboard.SetDataObject(myDataObject);
Vash
thanks, this solved my problem
Thiyaneshwaran S