Issue 2480: side-stretching of fix-ratio crops now stop at image edges
This commit is contained in:
@@ -764,8 +764,9 @@ void Crop::cropWidth1Resized (int &X, int &Y, int &W, int &H) {
|
|||||||
if (fixr->get_active()) {
|
if (fixr->get_active()) {
|
||||||
double r = getRatio();
|
double r = getRatio();
|
||||||
H = (int)round(W / r);
|
H = (int)round(W / r);
|
||||||
if (H > maxh) {
|
int Hmax = min(ny + nh, maxh - ny);
|
||||||
H = maxh;
|
if (H > Hmax) {
|
||||||
|
H = Hmax;
|
||||||
W = H * r;
|
W = H * r;
|
||||||
}
|
}
|
||||||
ny = ny - (H - nh) / 2.0;
|
ny = ny - (H - nh) / 2.0;
|
||||||
@@ -788,8 +789,9 @@ void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H) {
|
|||||||
if (fixr->get_active()) {
|
if (fixr->get_active()) {
|
||||||
double r = getRatio();
|
double r = getRatio();
|
||||||
H = (int)round(W / r);
|
H = (int)round(W / r);
|
||||||
if (H > maxh) {
|
int Hmax = min(ny + nh, maxh - ny);
|
||||||
H = maxh;
|
if (H > Hmax) {
|
||||||
|
H = Hmax;
|
||||||
W = H * r;
|
W = H * r;
|
||||||
}
|
}
|
||||||
ny = ny - (H - nh) / 2.0;
|
ny = ny - (H - nh) / 2.0;
|
||||||
@@ -812,8 +814,9 @@ void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H) {
|
|||||||
if (fixr->get_active()) {
|
if (fixr->get_active()) {
|
||||||
double r = getRatio();
|
double r = getRatio();
|
||||||
W = (int)round(H * r);
|
W = (int)round(H * r);
|
||||||
if (W > maxw) {
|
int Wmax = min(nx + nw, maxw - nx);
|
||||||
W = maxw;
|
if (W > Wmax) {
|
||||||
|
W = Wmax;
|
||||||
H = W / r;
|
H = W / r;
|
||||||
}
|
}
|
||||||
nx = nx - (W - nw) / 2.0;
|
nx = nx - (W - nw) / 2.0;
|
||||||
@@ -836,8 +839,9 @@ void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H) {
|
|||||||
if (fixr->get_active()) {
|
if (fixr->get_active()) {
|
||||||
double r = getRatio();
|
double r = getRatio();
|
||||||
W = (int)round(H * r);
|
W = (int)round(H * r);
|
||||||
if (W > maxw) {
|
int Wmax = min(nx + nw, maxw - nx);
|
||||||
W = maxw;
|
if (W > Wmax) {
|
||||||
|
W = Wmax;
|
||||||
H = W / r;
|
H = W / r;
|
||||||
}
|
}
|
||||||
nx = nx - (W - nw) / 2.0; // nx must be floating point to avoid drifting
|
nx = nx - (W - nw) / 2.0; // nx must be floating point to avoid drifting
|
||||||
|
Reference in New Issue
Block a user