1_7_Redis设计与实现读书记-对象
995 2023-04-03 03:09:14
在某些情况下,可能需要将 PowerPoint 演示文稿中的幻灯片转换为图像。例如,在您的 Web 或桌面应用程序中嵌入演示文稿、生成缩略图等。PNG是使用无损压缩的最流行的图像格式之一。因此,在本文中,您将学习如何使用 C# 将 PowerPoint PPTX 或 PPT 中的幻灯片转换为 PNG 图像。
为了将 PPTX 或 PPT 演示文稿转换为 PNG,我们将使用Aspose.Slides for .NET,它是一个功能丰富的 API,可让您使用 C# 创建、修改和转换 PowerPoint 和 OpenOffice 演示文稿。
以下是使用 C# 将 PowerPoint PPTX 中的幻灯片转换为 PNG 图像的步骤。
以下代码示例展示了如何将 PowerPoint PPTX 转换为 PNG。
// Load PowerPoint presentationusing (Presentation pres = new Presentation("presentation.pptx")){ // User defined dimension int desiredX = 1200; int desiredY = 800; // Getting scaled value of X and Y float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX; float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY; foreach (ISlide sld in pres.Slides) { // Create a full scale image Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY); // Save the image to disk in PNG format bmp.Save(String.Format("slide_{0}.webp", sld.SlideNumber), System.Drawing.Imaging.ImageFormat.Png); }}
如果您有任何疑问或需求,请随时加入Aspose技术交流群(761297826),我们很高兴为您提供查询和咨询。