Skip to content

Commit

Permalink
Merge pull request #243 from koan00/open-dev-v1
Browse files Browse the repository at this point in the history
Fix #242 - Image with CSS max-width and max-height incorrectly scaled up
  • Loading branch information
danfickle authored Jul 7, 2018
2 parents 3491b7e + af20742 commit b8a6ab0
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ public ReplacedElement createReplacedElement(LayoutContext c, BlockBox box,
int intrinsicWidth = fsImage.getWidth();

if (hasMaxWidth && hasMaxHeight) {
double rw = (double) intrinsicWidth / (double) maxWidth;
double rh = (double) intrinsicHeight / (double) maxHeight;
if (intrinsicWidth > maxWidth || intrinsicHeight > maxHeight) {
double rw = (double) intrinsicWidth / (double) maxWidth;
double rh = (double) intrinsicHeight / (double) maxHeight;

if (rw > rh) {
fsImage.scale((int) maxWidth, -1);
} else {
fsImage.scale(-1, (int) maxHeight);
if (rw > rh) {
fsImage.scale((int) maxWidth, -1);
} else {
fsImage.scale(-1, (int) maxHeight);
}
}
} else if (hasMaxWidth && intrinsicWidth > maxWidth) {
fsImage.scale((int) maxWidth, -1);
Expand Down

0 comments on commit b8a6ab0

Please sign in to comment.