Skip to content

Commit

Permalink
getReductionFactor() ignores the ScaleConstraint argument (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dolski committed Jun 9, 2021
1 parent 0257274 commit b916ac2
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,27 @@ public Mode getMode() {
return scaleMode;
}

/**
* @param reducedSize Size of an image that has been halved {@literal
* n} times.
* @param scaleConstraint Ignored.
* @param maxFactor Maximum factor to return.
*/
@Override
public ReductionFactor getReductionFactor(final Dimension reducedSize,
final ScaleConstraint scaleConstraint,
final int maxFactor) {
final double scScale = scaleConstraint.getRational().doubleValue();
double rfScale = 1;
switch (getMode()) {
case ASPECT_FIT_WIDTH:
rfScale = getWidth() / reducedSize.width() * scScale;
rfScale = getWidth() / reducedSize.width();
break;
case ASPECT_FIT_HEIGHT:
rfScale = getHeight() / reducedSize.height() * scScale;
rfScale = getHeight() / reducedSize.height();
break;
case ASPECT_FIT_INSIDE:
double xScale = getWidth() / reducedSize.width() * scScale;
double yScale = getHeight() / reducedSize.height() * scScale;
double xScale = getWidth() / reducedSize.width();
double yScale = getHeight() / reducedSize.height();
rfScale = Math.min(xScale, yScale);
break;
}
Expand Down
Loading

0 comments on commit b916ac2

Please sign in to comment.