How to Convert PNG to PowerPoint Slide in C#

This crisp tutorial provides information to convert PNG to PowerPoint Slide in C#. All the required information about the configuration, step-wise process, and a runnable sample code are provided to write a PNG to PPTX converter in C#. The sample code demonstrates the complete scenario and can be used in any of the operating systems like Windows, Linux, or macOS.

Steps to Convert PNG to PPTX in C#

  1. Establish the environment to add Aspose.Slides for .NET into your application
  2. Create a new Presentation object
  3. Get the reference to the first slide from the slides collection in the presentation
  4. Read all bytes from the PNG file
  5. Use PNG bytes data to add an image in the images collection of the presentation
  6. Add a picture frame in the shapes collection of the selected slide using the added image above
  7. Save the presentation as PPTX having a PNG image in it

The steps mentioned above guide to convert PNG to PPTX in C# where a new presentation is generated that contains a default slides collection, images collection, and a Save method. We need to get a reference to the first slide and then add an image using the bytes data read from the PNG file. Our ultimate goal is to add a picture frame having the image in it to the shapes collection of the selected slide.

Code to Convert PNG to PowerPoint in C#

While working with this feature to convert PNG file to PowerPoint in C# we have used the Slide object to hold the reference to the target slide and used IPPImage object to hold the reference to the new image added in the images collection. The AddImage method has a number of overloaded constructors that take different parameters like bytes, Image object, IPPImage object, stream, and memory stream.

In this tutorial, we have learnt to convert PNG to PPTX. If you want to learn the process of adding an image watermark in a PowerPoint presentation, refer to the article on how to add image watermark in PPTX presentation using C#.

 English