Word and Excel also have the same phenomenon.
- Code: Select all
private void ButtonPpt_Click(object sender, RoutedEventArgs e)
{
try
{
System.Drawing.Image image = null;
using (Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation())
{
presentation.LoadFromFile(@"E:\文档\颁奖胶片.pptx");
for (int i = 0; i < presentation.Slides.Count; i++)
{
image = presentation.Slides[i].SaveAsImage();
break;
}
presentation.Dispose();
}
BitmapImage bitmapImage = new BitmapImage();
using (MemoryStream stream = new MemoryStream())
{
image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Position = 0;
bitmapImage.SetSource(stream.AsRandomAccessStream());
}
ImageTest.Source = bitmapImage;
image.Dispose();
image = null;
}
catch (Exception ex)
{
}
}