summaryrefslogtreecommitdiffstats
path: root/src/ui/svg-renderer.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /src/ui/svg-renderer.h
parentInitial commit. (diff)
downloadinkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.tar.xz
inkscape-c853ffb5b2f75f5a889ed2e3ef89b818a736e87a.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ui/svg-renderer.h')
-rw-r--r--src/ui/svg-renderer.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ui/svg-renderer.h b/src/ui/svg-renderer.h
new file mode 100644
index 0000000..aed6bf0
--- /dev/null
+++ b/src/ui/svg-renderer.h
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef SEEN_SVG_RENDERER_H
+#define SEEN_SVG_RENDERER_H
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#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);
+ // pass in document to render
+ svg_renderer(std::shared_ptr<SPDocument> document);
+
+ // 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);
+
+ // if set, draw checkerboard pattern before image
+ void set_checkerboard_color(uint32_t rgba);
+
+ double get_width_px() const;
+ double get_height_px() const;
+
+private:
+ Pixbuf* do_render(double scale);
+ std::shared_ptr<SPDocument> _document;
+ SPRoot* _root = nullptr;
+ std::optional<uint32_t> _checkerboard;
+};
+
+}
+
+#endif