From: Niki Roo Date: Mon, 4 May 2020 16:31:40 +0000 (+0200) Subject: fix rotation in images viewer X-Git-Tag: fanfix-swing-1.2.0~21 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=3ff2fb115f0a60e00c5566a8fcdfcaf973e60894;p=fanfix-swing.git fix rotation in images viewer --- diff --git a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java index db072ddc..554c3504 100644 --- a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java +++ b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java @@ -366,13 +366,22 @@ public class ViewerImages extends JFrame { new SwingWorker() { @Override protected ImageIcon doInBackground() throws Exception { + Rotation rotation = ViewerImages.this.rotation; + boolean turn = (rotation == Rotation.LEFT + || rotation == Rotation.RIGHT); + BufferedImage image = ImageUtilsAwt.fromImage(img, rotation); BufferedImage resizedImage = ImageUtilsAwt.scaleImage( areaSize, image, zoom, zoomSnapWidth); - currentZoom = (1.0 * resizedImage.getWidth()) - / image.getWidth(); + if (!turn) { + currentZoom = (1.0 * resizedImage.getWidth()) + / image.getWidth(); + } else { + currentZoom = (1.0 * resizedImage.getHeight()) + / image.getWidth(); + } return new ImageIcon(resizedImage); }