diff --git a/src/d/t/totp/misc/ImageUtils.java b/src/d/t/totp/misc/ImageUtils.java index b8fd229..98dbb1b 100644 --- a/src/d/t/totp/misc/ImageUtils.java +++ b/src/d/t/totp/misc/ImageUtils.java @@ -14,20 +14,22 @@ public static final BufferedImage scaleDownToMax(BufferedImage rawImage, Vec2i m final int maxHeight = maxSize.y(); final float targetAspect = 1F * maxWidth / maxHeight; final float imageAspect = 1F * rawImage.getWidth() / rawImage.getHeight(); + + final float factor; + if (targetAspect > imageAspect) { if (rawImage.getHeight() <= maxHeight) return rawImage; - final float factor = 1F * maxHeight / rawImage.getHeight(); - return scale(factor, rawImage); + factor = 1F * maxHeight / rawImage.getHeight(); } else { if (rawImage.getWidth() <= maxWidth) return rawImage; - final float factor = 1F * maxWidth / rawImage.getWidth(); - return scale(factor, rawImage); + factor = 1F * maxWidth / rawImage.getWidth(); } + return scale(factor, rawImage); } private static final BufferedImage scale(float factor, BufferedImage rawImage) diff --git a/src/d/t/totp/ui/main/TotpComponent.java b/src/d/t/totp/ui/main/TotpComponent.java index 9286094..8bc0c23 100644 --- a/src/d/t/totp/ui/main/TotpComponent.java +++ b/src/d/t/totp/ui/main/TotpComponent.java @@ -99,8 +99,7 @@ public TotpComponent(TotpEntry entry, RemoveListener removeListener, char[] pass public void updateCategory(HashMap renameMap) { final var newName = renameMap.getOrDefault(entry.category, entry.category); - TinyTotp.config.getCategoryByName(newName).if_(cat -> - { + TinyTotp.config.getCategoryByName(newName).if_(cat -> { entry.category = cat.name; categoryPanel.setToolTipText(cat.name); categoryPanel.setBackground(cat.color); @@ -156,8 +155,7 @@ private void setIcon(String iconName) private ActionListener edit(char[] password) { - return ae -> EventQueue.invokeLater(() -> - { + return ae -> EventQueue.invokeLater(() -> { final var owner = SwingUtilities.getWindowAncestor(this); new AddKey( owner,