// 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;
// 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);
}
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));
-
- bb.xl -= bb_orig.xl;
- bb.xr -= bb_orig.xl;
- bb.yb -= bb_orig.yb;
- bb.yt -= bb_orig.yb;
+ 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 = 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;