https://github.com/reupen/svg-services
foobar2000 component that provides an API for rendering SVGs
https://github.com/reupen/svg-services
foobar2000
Last synced: 5 months ago
JSON representation
foobar2000 component that provides an API for rendering SVGs
- Host: GitHub
- URL: https://github.com/reupen/svg-services
- Owner: reupen
- License: 0bsd
- Created: 2022-08-19T20:08:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-24T08:37:43.000Z (over 1 year ago)
- Last Synced: 2024-12-24T09:33:18.062Z (over 1 year ago)
- Topics: foobar2000
- Language: C++
- Homepage: https://yuo.be/svg-services
- Size: 188 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SVG services
[](https://github.com/reupen/svg-services/actions/workflows/build.yml?query=branch%3Amain)
This component provides an SVG renderer, for use by other foobar2000 components.
The [resvg library](https://github.com/RazrFalcon/resvg) is used to render SVGs.
## API usage (for component developers)
You only need to include the [`api/api.h`](api/api.h) header to use the API. You
can copy it to your source tree, or you can add this repository as a Git
submodule if you prefer.
A simple usage example:
```cpp
abort_callback_dummy aborter;
const auto render_height = 512;
const auto render_width = 512;
const auto file_path = "R(c:\path\to\svg\file)";
svg_services::svg_services::ptr svg_api;
if (!fb2k::std_api_try_get(svg_api)) {
// Handle the case when the API isn’t available
}
const auto svg_data = filesystem::g_readWholeFile(file_path, 10'000'000, aborter);
std::vector bitmap_data(
static_cast(render_width) * static_cast(render_height) * size_t{4});
const auto svg_document = svg_api->open(svg_data->data(), svg_data->size());
svg_document->render(render_width, render_height, svg_services::Position::Centred, svg_services::ScalingMode::Fit,
svg_services::PixelFormat::BGRA, bitmap_data.data(), bitmap_data.size());
// Pass data contained in bitmap_data to CreateDIBSection(), WIC etc.
```