diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /src/ui/svg-renderer.h | |
parent | Initial commit. (diff) | |
download | inkscape-upstream/1.2.2.tar.xz inkscape-upstream/1.2.2.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/ui/svg-renderer.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ui/svg-renderer.h b/src/ui/svg-renderer.h new file mode 100644 index 0000000..b586ea9 --- /dev/null +++ b/src/ui/svg-renderer.h @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_SVG_RENDERER_H +#define SEEN_SVG_RENDERER_H + +#include <gtkmm.h> +#include <gdkmm/rgba.h> + +#include "document.h" +#include "color.h" + +namespace Inkscape { + +// utilities for set_style: +// Gdk color to CSS rgb (no alpha) +Glib::ustring rgba_to_css_color(const Gdk::RGBA& color); +Glib::ustring rgba_to_css_color(const SPColor& color); +// double to low precision string +Glib::ustring double_to_css_value(double value); +class Pixbuf; + +class svg_renderer +{ +public: + // load SVG document from file (abs path) + svg_renderer(const char* svg_file_path); + + // set inline style on selected elements; return number of elements modified + size_t set_style(const Glib::ustring& selector, const char* name, const Glib::ustring& value); + + // render document at given scale + Glib::RefPtr<Gdk::Pixbuf> render(double scale); + Cairo::RefPtr<Cairo::Surface> render_surface(double scale); + + double get_width_px() const; + double get_height_px() const; + +private: + Pixbuf* do_render(double scale); + std::unique_ptr<SPDocument> _document; + SPRoot* _root = nullptr; +}; + +} + +#endif |