How to: Save a Picture to a File
Use the following API to save pictures to separate files.
API | Description |
---|---|
Obtains shapes from the specified range | |
Retrieves the picture as an OfficeImage object. | |
Provides access to the Image object. | |
Exports an image to the file. |
The code sample below retrieves pictures from a specific range and save them as PNG images.
private void SaveImagesToFiles(Document document)
{
DocumentRange myRange = document.CreateRange(0, 100);
ReadOnlyShapeCollection images = document.Shapes.Get(myRange);
if (images.Count > 0)
{
if (images[0].Picture != null)
{
DevExpress.Office.Utils.OfficeImage myImage = images[0].Picture;
System.Drawing.Image image = myImage.NativeImage;
string imageName = String.Format("Image_at_pos_{0}.png", images[0].Range.Start.ToInt());
image.Save(imageName);
System.Diagnostics.Process.Start("explorer.exe", "/select," + imageName);
}
}
}