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++.

  1. Install Aspose.Slides for C++ .

  2. Add a library reference to your C++ project.

  3. Create a Presentation instance and add the SVG image to a slide.

  4. Render the slide with GetImage and save the image with ImageFormat::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.