From c62bc930f1e85d3ab19fb474653ad2db9a41eca5 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 8 Oct 2014 13:05:26 -0400 Subject: avoid round-off error when calculating viewbox transform c2p (Bug 1374614 and Bug 1235279) Fixed bugs: - https://launchpad.net/bugs/1374614 (bzr r13581) --- src/viewbox.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index f59909abc..6d677d57d 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -164,16 +164,16 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { void SPViewBox::apply_viewbox(const Geom::Rect& in) { /* Determine actual viewbox in viewport coordinates */ - double x = 0.0; - double y = 0.0; - double width = in.width(); - double height = in.height(); + float x = 0.0; + float y = 0.0; + float width = in.width(); + float height = in.height(); // std::cout << " width: " << width << " height: " << height << std::endl; if (this->aspect_align != SP_ASPECT_NONE) { /* Things are getting interesting */ - double scalex = in.width() / this->viewBox.width(); - double scaley = in.height() / this->viewBox.height(); + double scalex = in.width() / ((float) this->viewBox.width()); + double scaley = in.height() / ((float) this->viewBox.height()); double scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); width = this->viewBox.width() * scale; height = this->viewBox.height() * scale; @@ -217,12 +217,12 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) { /* Viewbox transform from scale and position */ Geom::Affine q; - q[0] = width / this->viewBox.width(); + q[0] = width / ((float) this->viewBox.width()); q[1] = 0.0; q[2] = 0.0; - q[3] = height / this->viewBox.height(); - q[4] = x - q[0] * this->viewBox.left(); - q[5] = y - q[3] * this->viewBox.top(); + q[3] = height / ((float) this->viewBox.height()); + q[4] = x - q[0] * ((float) this->viewBox.left()); + q[5] = y - q[3] * ((float) this->viewBox.top()); // std::cout << " q\n" << q << std::endl; -- cgit v1.2.3