Svg2b2d
Using blend2d vector library as backed to svg rendering
Install / Use
/learn @Wiladams/Svg2b2dREADME
svg2b2d
SVG parser, using blend2d as backend renderer
<img src="images/Accordion.png" alt="Accordion" width=340/></br>
look at projects/genimage to see how easy it is to construct a BLImage from an SVG
The main interface is in svg.h
#pragma once
#include "blend2d.h"
#ifdef __cplusplus
extern "C" {
#endif
bool parseSVG(const void *bytes, const size_t sz, BLImage &outImage);
#ifdef __cplusplus
}
#endif
The process of using it is as simple as this:
#include "blend2d.h"
#include "mmap.h"
#include "svg.h"
using namespace filemapper;
using namespace svg2b2d;
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("Usage: genimage <svg file> [output file]\n");
return 1;
}
// create an mmap for the specified file
const char *filename = argv[1];
auto mapped = mmap::createShared(filename);
if (mapped == nullptr)
return 0;
// Create the BLImage we're going to draw into
BLImage outImage(1000, 1000, BL_FORMAT_PRGB32);
// parse the svg, and draw it into the image
parseSVG(mapped->data(), mapped->size(), outImage);
// save the image to a png file
const char *output = argc > 2 ? argv[2] : "output.png";
outImage.writeToFile(output);
// close the mapped file
mapped->close();
return 0;
}
The generated image will be the size of the .svg.
If you want to try the svg2png.exe it's like this:
svg2png.exe filename.svg fileout.png
If you leave off the "fileout.png", it will use 'output.png' as the filename.
And that's it!
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
