[英]Decode svg from memory ImageMagick
How do I decode svg image from buffer?如何从缓冲区解码 svg 图像? I know SVGs are just text but I don't know how to parse them to Magick::Image other than reading from disk.
我知道 SVG 只是文本,但除了从磁盘读取之外,我不知道如何将它们解析为 Magick::Image。
#include <Magick++.h>
#include <stdio.h>
using namespace Magick;
int main() {
printf("EnableOpenCL ret: %d\n", Magick::EnableOpenCL());
Magick::Image svgImage;
svgImage.read("input.svg"); // first read file
svgImage.magick("png"); // then specify PNG format
svgImage.write("output.png");
return 0;
}
You would copy the buffer into Magick++'s Magick::Blob
and pass it to Magick::Image
constructor.您可以将缓冲区复制到 Magick++ 的
Magick::Blob
中并将其传递给Magick::Image
构造函数。
Magick::Blob svgData(memory_ptr, memory_length);
Magick::Image svgImage(svgData, svgRenderSize, "SVG");
Where memory_ptr
is the address of the svg data in memory, memory_length
is the total byte size of memory_ptr
, and svgRenderSize
is Magick::Geometry
instances the image size.其中
memory_ptr
是 memory 中 svg 数据的地址, memory_length
是svgRenderSize
memory_ptr
Magick::Geometry
实例的图像大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.