diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2018-09-13 13:37:43 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2018-09-13 13:37:43 +0000 |
| commit | bda44805f365b0f4757a0f9c940d37d38ab4564b (patch) | |
| tree | aa42879fb9f10e7393fc8f457960b987ff06b953 /src | |
| parent | Add per embed/linked SVG a DPI value (diff) | |
| download | inkscape-bda44805f365b0f4757a0f9c940d37d38ab4564b.tar.gz inkscape-bda44805f365b0f4757a0f9c940d37d38ab4564b.zip | |
Fix DPI wrong code pointed by Mc
Diffstat (limited to 'src')
| -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 |
4 files changed, 20 insertions, 20 deletions
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; |
