diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index dda36d298a..38866c2af4 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -578,7 +578,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) // the bb section } else if (!controller().bbChanged && - (ob == bbox_->choice_bb_units || + (ob == bbox_->check_clip || ob == bbox_->choice_bb_units || ob == bbox_->input_bb_x0 || ob == bbox_->input_bb_y0 || ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) { controller().bbChanged = true; diff --git a/src/frontends/xforms/xformsGImage.C b/src/frontends/xforms/xformsGImage.C index fadefb4c6f..ef0059e50b 100644 --- a/src/frontends/xforms/xformsGImage.C +++ b/src/frontends/xforms/xformsGImage.C @@ -261,10 +261,10 @@ void xformsGImage::clip(GParams const & params) // Bounds are unchanged. return; - int const xoffset_l = params.bb.xl; - int const xoffset_r = image_->w - params.bb.xr; - int const yoffset_t = image_->h - params.bb.yt; - int const yoffset_b = params.bb.yb; + int const xoffset_l = std::max(0, params.bb.xl); + int const xoffset_r = std::max(0, image_->w - params.bb.xr); + int const yoffset_t = std::max(0, image_->h - params.bb.yt); + int const yoffset_b = std::max(0, params.bb.yb); flimage_crop(image_, xoffset_l, yoffset_t, xoffset_r, yoffset_b); } diff --git a/src/graphics/GraphicsParams.C b/src/graphics/GraphicsParams.C index b130623134..7a5a06c4e1 100644 --- a/src/graphics/GraphicsParams.C +++ b/src/graphics/GraphicsParams.C @@ -36,20 +36,22 @@ GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath) bb = iparams.bb; // Get the original Bounding Box from the file - string const bb_orig_str = readBB_from_PSFile(filename); - if (!bb_orig_str.empty()) { - BoundingBox bb_orig; - bb_orig.xl = strToInt(token(bb_orig_str, ' ', 0)); - bb_orig.yb = strToInt(token(bb_orig_str, ' ', 1)); - bb_orig.xr = strToInt(token(bb_orig_str, ' ', 2)); - bb_orig.yt = strToInt(token(bb_orig_str, ' ', 3)); + string const tmp = readBB_from_PSFile(filename); + if (!tmp.empty()) { + int const bb_orig_xl = strToInt(token(tmp, ' ', 0)); + int const bb_orig_yb = strToInt(token(tmp, ' ', 1)); - bb.xl -= bb_orig.xl; - bb.xr -= bb_orig.xl; - bb.yb -= bb_orig.yb; - bb.yt -= bb_orig.yb; + bb.xl -= bb_orig_xl; + bb.xr -= bb_orig_xl; + bb.yb -= bb_orig_yb; + bb.yt -= bb_orig_yb; } + bb.xl = std::max(0, bb.xl); + bb.xr = std::max(0, bb.xr); + bb.yb = std::max(0, bb.yb); + bb.yt = std::max(0, bb.yt); + // Paranoia check. int const width = bb.xr - bb.xl; int const height = bb.yt - bb.yb;