Skip to content

Commit

Permalink
Apply bicubic interpolation in scaled ImageComponent images.
Browse files Browse the repository at this point in the history
  • Loading branch information
nightm4re94 committed Sep 13, 2024
1 parent 123496f commit a81b385
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Point2D;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.util.Optional;
import javax.swing.JLabel;
Expand Down Expand Up @@ -142,15 +143,14 @@ public void rescaleImage() {
}
}

final String cacheKey =
String.format("%s_%dx%d_%b", this.baseImage.hashCode(), imageWidth, imageHeight, keepRatio);
final String cacheKey = String.format("%s_%dx%d_%b", this.baseImage.hashCode(), imageWidth, imageHeight, keepRatio);

Optional<BufferedImage> opt = Resources.images().tryGet(cacheKey);
if (opt.isPresent()) {
this.scaledImage = opt.get();
return;
} else {
this.scaledImage = Imaging.scale(this.baseImage, imageWidth, imageHeight, keepRatio);
this.scaledImage = Imaging.scale(this.baseImage, imageWidth, imageHeight, AffineTransformOp.TYPE_BICUBIC, keepRatio);
}
Resources.images().add(cacheKey, this.scaledImage);
}
Expand Down

0 comments on commit a81b385

Please sign in to comment.