From b9e331526591667316d2e683b6ab029f27ab0a50 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 11 Apr 2002 18:40:20 +0000 Subject: [PATCH] Use the new LyXLength::inBP method to resolve rounding error problems. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3976 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/graphics/ChangeLog | 5 +++++ src/graphics/GraphicsParams.C | 23 +++++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index f8dea4bd09..22fec5f3c8 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2002-04-09 Herbert Voss + + * GraphicsParams.C (BoundingBox c-tor): fix rounding errors by using + LyXLength::inBP instead of inPixels. + 2002-04-10 Herbert Voss * GraphicsCache.[Ch]: diff --git a/src/graphics/GraphicsParams.C b/src/graphics/GraphicsParams.C index 7a5a06c4e1..e2782973d7 100644 --- a/src/graphics/GraphicsParams.C +++ b/src/graphics/GraphicsParams.C @@ -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; -- 2.39.2