diff options
| -rw-r--r-- | .vscode/settings.json | 62 | ||||
| -rw-r--r-- | src/display/cairo-utils.cpp | 12 | ||||
| -rw-r--r-- | src/display/cairo-utils.h | 4 | ||||
| -rw-r--r-- | src/extension/internal/svg.cpp | 6 | ||||
| -rw-r--r-- | src/object/sp-image.cpp | 18 |
5 files changed, 82 insertions, 20 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a4302e926 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,62 @@ +{ + "files.associations": { + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "atomic": "cpp", + "strstream": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "slist": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "mutex": "cpp", + "ratio": "cpp", + "system_error": "cpp", + "thread": "cpp", + "typeindex": "cpp", + "array": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "complex": "cpp", + "deque": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "fstream": "cpp", + "functional": "cpp", + "iomanip": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "memory": "cpp", + "new": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string_view": "cpp", + "type_traits": "cpp", + "tuple": "cpp", + "typeinfo": "cpp", + "utility": "cpp", + "valarray": "cpp", + "algorithm": "cpp" + } +}
\ No newline at end of file diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 7279ac052..965645b15 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, char const *svgdpi) +Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data, double svgdpi) { Pixbuf *pixbuf = nullptr; @@ -311,8 +311,8 @@ Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data, char const *svgdpi) } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); - if (svgdpi && atof(svgdpi) > 0) { - dpi = atof(svgdpi); + if (svgdpi && svgdpi > 0) { + dpi = svgdpi; } std::cout << dpi << "dpi" << std::endl; // Get the size of the document @@ -342,7 +342,7 @@ Pixbuf *Pixbuf::create_from_data_uri(gchar const *uri_data, char const *svgdpi) return pixbuf; } -Pixbuf *Pixbuf::create_from_file(std::string const &fn, char const *svgdpi) +Pixbuf *Pixbuf::create_from_file(std::string const &fn, double svgdpi) { Pixbuf *pb = nullptr; // test correctness of filename @@ -387,8 +387,8 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn, char const *svgdpi) } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double dpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", 96.0); - if (svgdpi && atof(svgdpi) > 0) { - dpi = atof(svgdpi); + if (svgdpi && svgdpi > 0) { + dpi = svgdpi; } std::cout << dpi << "dpi" << std::endl; // Get the size of the document diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 256bda94c..ada78ce51 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -117,8 +117,8 @@ public: PixelFormat pixelFormat() const { return _pixel_format; } void ensurePixelFormat(PixelFormat fmt); - static Pixbuf *create_from_data_uri(gchar const *uri, char const *svgdpi = NULL); - static Pixbuf *create_from_file(std::string const &fn, char const *svgddpi = NULL); + static Pixbuf *create_from_data_uri(gchar const *uri, double svgdpi = 0); + static Pixbuf *create_from_file(std::string const &fn, double svgddpi = 0); private: void _ensurePixelsARGB32(); diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index d39f5a960..e4586ec5f 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -245,8 +245,8 @@ Svg::open (Inkscape::Extension::Input *mod, const gchar *uri) // Added 11 Feb 2014 as we now honor "preserveAspectRatio" and this is // what Inkscaper's expect. image_node->setAttribute("preserveAspectRatio", "none"); - Glib::ustring svgdpi = Glib::ustring::format(mod->get_param_float("svgdpi")); - image_node->setAttribute("inkscape:svg-dpi", svgdpi.c_str()); + double svgdpi = mod->get_param_float("svgdpi"); + image_node->setAttribute("inkscape:svg-dpi", Glib::ustring::format(svgdpi).c_str()); image_node->setAttribute("width", Glib::ustring::format(width)); image_node->setAttribute("height", Glib::ustring::format(height)); Glib::ustring scale = prefs->getString("/dialogs/import/scale"); @@ -258,7 +258,7 @@ Svg::open (Inkscape::Extension::Input *mod, const gchar *uri) } // convert filename to uri if (embed) { - std::unique_ptr<Inkscape::Pixbuf> pb(Inkscape::Pixbuf::create_from_file(uri, svgdpi.c_str())); + std::unique_ptr<Inkscape::Pixbuf> pb(Inkscape::Pixbuf::create_from_file(uri, svgdpi)); if(pb) { sp_embed_svg(image_node, uri); } diff --git a/src/object/sp-image.cpp b/src/object/sp-image.cpp index 9c2fe9ac3..65643c701 100644 --- a/src/object/sp-image.cpp +++ b/src/object/sp-image.cpp @@ -73,7 +73,7 @@ static void sp_image_set_curve(SPImage *image); static Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base, - char const *svgdpi); + double svgdpi = 0); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); @@ -338,11 +338,11 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { this->pixbuf = nullptr; if (this->href) { Inkscape::Pixbuf *pixbuf = nullptr; - const gchar *svgdpi = this->getRepr()->attribute("inkscape:svg-dpi"); - if (!svgdpi) { - svgdpi = "96"; + double svgdpi = 96; + if (this->getRepr()->attribute("inkscape:svg-dpi")) { + svgdpi = atof(this->getRepr()->attribute("inkscape:svg-dpi")); } - this->dpi = atof(svgdpi); + this->dpi = svgdpi; pixbuf = sp_image_repr_read_image(this->getRepr()->attribute("xlink:href"), this->getRepr()->attribute("sodipodi:absref"), doc->getBase(), svgdpi); @@ -545,9 +545,9 @@ gchar* SPImage::description() const { this->document) { Inkscape::Pixbuf * pb = nullptr; - const gchar *svgdpi = this->getRepr()->attribute("inkscape:svg-dpi"); - if (!svgdpi) { - svgdpi = "96"; + double svgdpi = 96; + if (this->getRepr()->attribute("inkscape:svg-dpi")) { + svgdpi = atof(this->getRepr()->attribute("inkscape:svg-dpi")); } pb = sp_image_repr_read_image(this->getRepr()->attribute("xlink:href"), this->getRepr()->attribute("sodipodi:absref"), this->document->getBase(), svgdpi); @@ -573,7 +573,7 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* return ai; } -Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base, char const *svgdpi) +Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base, double svgdpi) { Inkscape::Pixbuf *inkpb = nullptr; |
