Example code for Magick++ and SVG file?
Posted: 2008-09-05T16:45:33-07:00
Hello,
I'm working on a project that needs to display SVG files so to that end, I've been trying to use the Magick++ API to read in the SVG file and then get the raw pixel data as RGBA and stuff it into a buffer to later display on the screen. This is what I've figured out I need so far:
Unfortunately, the pixel data I get is incorrect. My suspicion is that I'm missing a step in here but I can't for the life of me figure out what. The SVG file that I'm rendering is essentially a bar graph with a vertical gradient for the background so I don't think it's anything so complex that IM can handle it.
So basically, does anyone have any tips on using the Magick++ API to handle SVGs?
I'm working on a project that needs to display SVG files so to that end, I've been trying to use the Magick++ API to read in the SVG file and then get the raw pixel data as RGBA and stuff it into a buffer to later display on the screen. This is what I've figured out I need so far:
Code: Select all
using namespace Magick;
Image svgImage("test.svg");
Geometry geom = svgImage.size();
svgImage.modifyImage();
Pixels svgPixels(svgImage);
PixelPacket* pixels = svgPixels.get(0, 0, geom.width(), geom.height());
unsigned char* pixelBuffer = new unsigned char[geom.width() * geom.height() * 4];
svgImage.writePixels(RGBAQuantum, pixelBuffer);
So basically, does anyone have any tips on using the Magick++ API to handle SVGs?