fix rotation in images viewer
authorNiki Roo <niki@nikiroo.be>
Mon, 4 May 2020 16:31:40 +0000 (18:31 +0200)
committerNiki Roo <niki@nikiroo.be>
Mon, 4 May 2020 16:31:40 +0000 (18:31 +0200)
src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java

index db072ddcc258a9141018151cd38da2ef60ff6fda..554c3504a9d43fa552acc1930ad6527affc15acc 100644 (file)
@@ -366,13 +366,22 @@ public class ViewerImages extends JFrame {
                                new SwingWorker<ImageIcon, Void>() {
                                        @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);
                                        }