Convert SVG to PNG in C++
Convert SVG images to PNG using Aspose.Slides for C++ without Microsoft PowerPoint.
Convert SVG to PNG in C++
Aspose.Slides for C++ can add SVG images to slides and render those slides as PNG files. Use this approach when you need to convert an SVG asset to a raster image in a C++ application.
Convert SVG to PNG Using C++
To convert SVG to PNG, create a Presentation, add the SVG image to a slide, render the slide with GetImage, and save the rendered image with ImageFormat::Png.
SVG to PNG C++ Conversion Source Code
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto svgContent = File::ReadAllText(u"image.svg");
auto svgImage = MakeObject<SvgImage>(svgContent);
auto presentationImage = presentation->get_Images()->AddImage(svgImage);
slide->get_Shapes()->AddPictureFrame(
ShapeType::Rectangle,
0,
0,
presentationImage->get_Width(),
presentationImage->get_Height(),
presentationImage);
auto image = slide->GetImage(2.0, 2.0);
image->Save(u"image.png", ImageFormat::Png);
image->Dispose();
presentation->Dispose();
How to Convert SVG to PNG Using Aspose.Slides for C++ API
These are the steps to convert SVG to PNG in C++.
Install Aspose.Slides for C++ .
Add a library reference to your C++ project.
Create a
Presentationinstance and add the SVG image to a slide.Render the slide with
GetImageand save the image withImageFormat::Png.
Free Online Converter
Convert presentations and slides online.
Convert SVG to Other Supported Formats
You can also convert SVG images and save them to other file formats.