diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2018-09-13 12:15:17 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2018-09-13 12:15:17 +0000 |
| commit | bfdf74d61f17dafc74d5d64f3224222718d6cddf (patch) | |
| tree | 0bdacdcdccf94b204cb494c78e654b98f61d4433 /src/display/cairo-utils.cpp | |
| parent | fixes and improvementes to power clip and powermask (diff) | |
| download | inkscape-bfdf74d61f17dafc74d5d64f3224222718d6cddf.tar.gz inkscape-bfdf74d61f17dafc74d5d64f3224222718d6cddf.zip | |
Add per embed/linked SVG a DPI value
Diffstat (limited to 'src/display/cairo-utils.cpp')
| -rw-r--r-- | src/display/cairo-utils.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index e34e4cd6b..7279ac052 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -207,7 +207,7 @@ Pixbuf::~Pixbuf() } } -Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data) +Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data, char const *svgdpi) { Pixbuf *pixbuf = nullptr; @@ -310,7 +310,11 @@ Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data) return nullptr; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); + double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); + if (svgdpi && atof(svgdpi) > 0) { + dpi = atof(svgdpi); + } + std::cout << dpi << "dpi" << std::endl; // Get the size of the document Inkscape::Util::Quantity svgWidth = svgDoc->getWidth(); Inkscape::Util::Quantity svgHeight = svgDoc->getHeight(); @@ -338,7 +342,7 @@ Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data) return pixbuf; } -Pixbuf *Pixbuf::create_from_file(std::string const &fn) +Pixbuf *Pixbuf::create_from_file(std::string const &fn, char const *svgdpi) { Pixbuf *pb = nullptr; // test correctness of filename @@ -350,7 +354,6 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn) if (val == 0 && stdir.st_mode & S_IFDIR){ return nullptr; } - // we need to load the entire file into memory, // since we'll store it as MIME data gchar *data = nullptr; @@ -383,7 +386,11 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn) return nullptr; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); + double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); + if (svgdpi && atof(svgdpi) > 0) { + dpi = atof(svgdpi); + } + std::cout << dpi << "dpi" << std::endl; // Get the size of the document Inkscape::Util::Quantity svgWidth = svgDoc->getWidth(); Inkscape::Util::Quantity svgHeight = svgDoc->getHeight(); |
