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
This commit is contained in:
Angus Leeming 2002-04-11 18:40:20 +00:00
parent 510b77ac25
commit b9e3315265
2 changed files with 12 additions and 16 deletions

View 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]:

View 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;