]> git.lyx.org Git - features.git/commitdiff
Use the new LyXLength::inBP method to resolve rounding error problems.
authorAngus Leeming <leeming@lyx.org>
Thu, 11 Apr 2002 18:40:20 +0000 (18:40 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 11 Apr 2002 18:40:20 +0000 (18:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3976 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/GraphicsParams.C

index f8dea4bd094cc422d165feced8b3d1651b314070..22fec5f3c8ad7cc2a9b2f4fafa26e0a05b232d62 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-09  Herbert Voss  <voss@lyx.org>
+
+       * GraphicsParams.C (BoundingBox c-tor): fix rounding errors by using
+       LyXLength::inBP instead of inPixels.
+
 2002-04-10  Herbert Voss  <voss@perce.de>
 
        * GraphicsCache.[Ch]:
index 7a5a06c4e16dc24af59f2bdf5d21656d72fc2361..e2782973d7f8d7c3727663dcac79703fc4f48b8d 100644 (file)
@@ -15,6 +15,7 @@
 #include "GraphicsParams.h"
 #include "insets/insetgraphicsParams.h"
 #include "lyxrc.h"
+#include "debug.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/LAssert.h"
@@ -37,6 +38,7 @@ GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
 
                // Get the original Bounding Box from the file
                string const tmp = readBB_from_PSFile(filename);
+               lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
                if (!tmp.empty()) {
                        int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
                        int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
@@ -147,23 +149,12 @@ BoundingBox::BoundingBox(string const & bb)
        string a, b, c, d;
        is >> a >> b >> c >> d;
 
-       // Don't need to check that the strings are valid LyXLength's
-       // because this is done in the LyXLength c-tor.
-       LyXLength const length_xl(a);
-       LyXLength const length_yb(b);
-       LyXLength const length_xr(c);
-       LyXLength const length_yt(d);
-
-       // inPixels returns the length in inches, scaled by
-       // lyxrc.dpi and lyxrc.zoom.
-       // We want, therefore, to undo all this lyxrc nonsense because we
-       // want the bounding box in Postscript pixels.
+       // inBP returns the length in Postscript points.
        // Note further that there are 72 Postscript pixels per inch.
-       double const scaling_factor = 7200.0 / (lyxrc.dpi * lyxrc.zoom);
-       int const xl_tmp = int(scaling_factor * length_xl.inPixels(1, 1));
-       int const yb_tmp = int(scaling_factor * length_yb.inPixels(1, 1));
-       int const xr_tmp = int(scaling_factor * length_xr.inPixels(1, 1));
-       int const yt_tmp = int(scaling_factor * length_yt.inPixels(1, 1));
+       int const xl_tmp = LyXLength(a).inBP();
+       int const yb_tmp = LyXLength(b).inBP();
+       int const xr_tmp = LyXLength(c).inBP();
+       int const yt_tmp = LyXLength(d).inBP();
 
        if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
                return;