Articles in this section
Category / Section

How custom resolution supported in WinForms PowerPoint slide to image conversion?

4 mins read

You can improve the image quality by providing custom image resolution while conversion.

The following code snippet demonstrates how to convert Presentation slides to images with custom image resolution.

C#

//Opens a PowerPoint presentation
IPresentation presentation = Presentation.Open("../../Data/SlidesSample.pptx");
//Iterates through the slide collection to convert as image
foreach (ISlide slide in presentation.Slides)
{
//Converts the slide as image
Image image = slide.ConvertToImage(Syncfusion.Drawing.ImageType.Bitmap);
//Creates a bitmap of specific width and height
Bitmap bitmap = new Bitmap((int)((image.Width * 500) / 96.0f), (int)((image.Height * 500) / 96.0f), PixelFormat.Format32bppPArgb);
//Sets the resolution
bitmap.SetResolution(500, 500);
//Gets graphics from the custom size bitmap image
Graphics graphics = Graphics.FromImage(bitmap);
//Recreate the image from stream using specified width and height
graphics.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
//Saves the image
image.Save("ImageOutput" + Guid.NewGuid().ToString() + ".jpeg");
}
//Closes the presentation
presentation.Close();

 

VB.NET

'Opens a PowerPoint presentation
Dim presentationDocument As IPresentation = Presentation.Open("../../Data/Test1.pptx")
'Iterates through the slide collection to convert as image
For Each slide As ISlide In presentationDocument.Slides
'Converts the slide as image
Dim image As Image = slide.ConvertToImage(Syncfusion.Drawing.ImageType.Bitmap)
'Creates a bitmap of specific width and height
Dim bitmap As New Bitmap(CInt((image.Width * 500) / 96.0F), CInt((image.Height * 500) / 96.0F), PixelFormat.Format32bppPArgb)
'Sets the resolution
bitmap.SetResolution(500, 500)
'Gets graphics from the custom size bitmap image
Dim gdiGraphics As Graphics = Graphics.FromImage(bitmap)
'Recreate the image from stream using specified width and height
gdiGraphics.DrawImage(image, New Rectangle(0, 0, bitmap.Width, bitmap.Height))
'Saves the image
image.Save("ImageOutput" + Guid.NewGuid().ToString() + ".jpeg")
Next
'Closes the presentation
presentationDocument.Close()

 

Sample Link - https://www.syncfusion.com/downloads/support/directtrac/172771/ze/Sample-1665031271

 

Conclusion

I hope you enjoyed learning about how custom resolution supported in WebForms PowerPoint slide to image conversion.

You can refer to our WinForms Presentation feature tour
page to know about its other groundbreaking feature representations. You can also explore our WinForms Presentation documentation
to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied