GetCurrentBounds() 공개 정적인 메소드

Returns the bounds IntRect of the monitor the position is located on.
public static GetCurrentBounds ( Vector2i pos ) : IntRect
pos Vector2i
리턴 IntRect
예제 #1
0
파일: ImageViewer.cs 프로젝트: arxae/vimage
        public void ToggleFitToMonitorHeight()
        {
            UnforceAlwaysOnTop();

            IntRect bounds;

            if (FitToMonitorHeightAlternative)
            {
                bounds = ImageViewerUtils.GetCurrentWorkingArea(Window.Position);
            }
            else
            {
                bounds = ImageViewerUtils.GetCurrentBounds(Window.Position);
            }

            if (CurrentZoom == 1)
            {
                // Fit to Monitor Height
                FitToMonitorHeight = true;
                if (Image.Rotation == 90 || Image.Rotation == 270)
                {
                    Zoom(1 + (((float)bounds.Height - Image.Texture.Size.X) / Image.Texture.Size.X), true);
                }
                else
                {
                    Zoom(1 + (((float)bounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                }
                NextWindowPos = new Vector2i(NextWindowPos.X, 0);
            }
            else
            {
                // Full Size
                FitToMonitorHeight = false;
                Zoom(1, true);
                NextWindowPos = new Vector2i(NextWindowPos.X < 0 ? 0 : NextWindowPos.X, NextWindowPos.Y < 0 ? 0 : NextWindowPos.Y);
            }


            if (Image.Texture.Size.X * CurrentZoom >= VideoMode.DesktopMode.Width)
            {
                NextWindowPos = new Vector2i(0, 0); // Position Window at 0,0 if the image is large (ie: a Desktop wallpaper)
            }
            else if (!FitToMonitorHeightAlternative)
            {
                ForceAlwaysOnTopNextTick = true;
            }

            AutomaticallyZoomed = false;
        }
예제 #2
0
파일: ImageViewer.cs 프로젝트: arxae/vimage
        public void ResetImage()
        {
            Zoom(1f);
            AutomaticallyZoomed = false;
            FlippedX            = false;
            RotateImage(DefaultRotation);

            // Force Fit To Monitor Height?
            Vector2i imagePos      = new Vector2i((int)NextWindowPos.X + ((int)Image.Texture.Size.X / 2), (int)NextWindowPos.Y + ((int)Image.Texture.Size.Y / 2));
            IntRect  currentBounds = ImageViewerUtils.GetCurrentBounds(imagePos);

            if (Config.Setting_LimitImagesToMonitorHeight && Image.Texture.Size.Y > Image.Texture.Size.X && Image.Texture.Size.Y > currentBounds.Height)
            {
                // Fit to monitor height if it's higher than monitor height.
                Zoom(1 + (((float)currentBounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                FitToMonitorHeightForced = true;
            }

            // Center image or place in top-left corner if it's a large/wide image.
            IntRect currentWorkingArea;

            if (!FitToMonitorHeightForced)
            {
                currentWorkingArea = ImageViewerUtils.GetCurrentWorkingArea(imagePos);
            }
            else
            {
                currentWorkingArea = currentBounds;
            }

            if (Config.Setting_PositionLargeWideImagesInCorner && Image.Texture.Size.X * CurrentZoom > Image.Texture.Size.Y * CurrentZoom && Image.Texture.Size.X * CurrentZoom >= currentWorkingArea.Width)
            {
                NextWindowPos = new Vector2i(currentWorkingArea.Left, currentWorkingArea.Top);
            }
            else
            {
                NextWindowPos = new Vector2i(currentWorkingArea.Left + (currentWorkingArea.Width / 2) - ((int)(Image.Texture.Size.X * CurrentZoom) / 2), currentWorkingArea.Top + (currentWorkingArea.Height / 2) - ((int)(Image.Texture.Size.Y * CurrentZoom) / 2));
            }

            // Force Always on Top?
            if (FitToMonitorHeightForced || (Image.Texture.Size.Y >= currentBounds.Height && Image.Texture.Size.X < currentBounds.Width))
            {
                ForceAlwaysOnTopNextTick = true;
            }
        }
예제 #3
0
        private bool ChangeImage(string fileName)
        {
            Dragging = false;
            Vector2u prevSize            = new Vector2u(Image.Texture.Size.X, Image.Texture.Size.Y);
            float    prevRotation        = Image.Rotation;
            int      prevDefaultRotation = DefaultRotation;

            IntRect bounds = ImageViewerUtils.GetCurrentBounds(Window.Position +
                                                               new Vector2i((int)(Image.Texture.Size.X * CurrentZoom) / 2, (int)(Image.Texture.Size.Y * CurrentZoom) / 2));

            if (AutomaticallyZoomed || FitToMonitorHeightForced)
            {
                // don't keep current zoom value if it wasn't set by user
                AutomaticallyZoomed      = false;
                FitToMonitorHeightForced = false;
                CurrentZoom = 1;
            }

            // Dispose of previous image
            Image.Dispose();
            Image = null;
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

            // Load new image
            if (!LoadImage(fileName))
            {
                return(false);
            }

            SFML.Graphics.View view = new SFML.Graphics.View(Window.DefaultView);
            view.Center = new Vector2f(Image.Texture.Size.X / 2, Image.Texture.Size.Y / 2);
            view.Size   = new Vector2f(Image.Texture.Size.X, Image.Texture.Size.Y);
            Window.SetView(view);

            // Rotation
            RotateImage(prevRotation == prevDefaultRotation ? DefaultRotation : (int)prevRotation, false);
            // Smoothing
            if (Image is AnimatedImage)
            {
                Image.Data.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }
            else
            {
                Image.Texture.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }

            bool wasFitToMonitorDimension = FitToMonitorHeightForced;

            if (Config.Setting_LimitImagesToMonitor != Config.NONE)
            {
                // Fit to monitor height/width
                int limit = Config.Setting_LimitImagesToMonitor;

                if (limit == Config.AUTO)
                {
                    if (bounds.Height < bounds.Width)
                    {
                        limit = Config.HEIGHT;
                    }
                    else
                    {
                        limit = Config.WIDTH;
                    }
                }

                if (limit == Config.HEIGHT && (FitToMonitorHeight || CurrentImageSize().Y *CurrentZoom > bounds.Height))
                {
                    Zoom(1 + (((float)bounds.Height - CurrentImageSize().Y) / CurrentImageSize().Y), true);

                    bounds = ImageViewerUtils.GetCurrentBounds(NextWindowPos +
                                                               new Vector2i((int)(CurrentImageSize().X *CurrentZoom) / 2, (int)(CurrentImageSize().Y *CurrentZoom) / 2));
                    NextWindowPos = new Vector2i(NextWindowPos.X, bounds.Top);

                    if (!FitToMonitorHeight)
                    {
                        FitToMonitorHeightForced = true;
                    }

                    wasFitToMonitorDimension = true;
                }
                else if (limit == Config.WIDTH && CurrentImageSize().X *CurrentZoom > bounds.Width)
                {
                    Zoom(1 + (((float)bounds.Width - CurrentImageSize().X) / CurrentImageSize().X), true);

                    bounds = ImageViewerUtils.GetCurrentBounds(NextWindowPos +
                                                               new Vector2i((int)(CurrentImageSize().X *CurrentZoom) / 2, (int)(CurrentImageSize().Y *CurrentZoom) / 2));
                    NextWindowPos = new Vector2i(bounds.Left, NextWindowPos.Y);

                    AutomaticallyZoomed      = true;
                    wasFitToMonitorDimension = true;
                }
            }
            if (!wasFitToMonitorDimension)
            {
                if (FitToMonitorHeightForced)
                {
                    Zoom(1, true);
                    FitToMonitorHeightForced = false;
                }
                else if (Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) * CurrentZoom < Config.Setting_MinImageSize)
                {
                    // Reisze images smaller than min size to min size
                    if (Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_MinImageSize)
                    {
                        AutomaticallyZoomed = true;
                        Zoom(Config.Setting_MinImageSize / Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y), true);
                    }
                    else
                    {
                        Zoom(1, true);
                    }
                }
                else
                {
                    Zoom(CurrentZoom, true);
                }
            }

            bounds = ImageViewerUtils.GetCurrentBounds(NextWindowPos +
                                                       new Vector2i((int)(Image.Texture.Size.X * CurrentZoom) / 2, (int)(Image.Texture.Size.Y * CurrentZoom) / 2));

            // Position Window at top-left if the image is wide (ie: a Desktop Wallpaper / Screenshot)
            // Otherwise, if image is hanging off monitor just center it.
            if (Config.Setting_PositionLargeWideImagesInCorner && CurrentImageSize().X > CurrentImageSize().Y&& CurrentImageSize().X *CurrentZoom >= bounds.Width)
            {
                NextWindowPos = new Vector2i(bounds.Left, bounds.Top);
            }
            else if (!prevSize.Equals(Image.Texture.Size) && (NextWindowPos.X + (Image.Texture.Size.X * CurrentZoom) >= bounds.Left + bounds.Width ||
                                                              NextWindowPos.Y + (Image.Texture.Size.Y * CurrentZoom) >= bounds.Top + bounds.Height))
            {
                NextWindowPos = new Vector2i(bounds.Left + (int)((bounds.Width - (Image.Texture.Size.X * CurrentZoom)) / 2), bounds.Top + (int)((bounds.Height - (Image.Texture.Size.Y * CurrentZoom)) / 2));
            }

            // Force Always On Top Mode (so it's above the task bar) - will only happen if height >= window height
            ForceAlwaysOnTopNextTick = true;

            Window.SetTitle(fileName + " - vimage");
            ContextMenu.Setup(false);

            return(true);
        }
예제 #4
0
        public void ResetImage()
        {
            Zoom(1f);
            AutomaticallyZoomed = false;
            FlippedX            = false;
            RotateImage(DefaultRotation);

            // Force Fit To Monitor Height?
            Vector2i imagePos      = new Vector2i((int)NextWindowPos.X + ((int)Image.Texture.Size.X / 2), (int)NextWindowPos.Y + ((int)Image.Texture.Size.Y / 2));
            IntRect  currentBounds = ImageViewerUtils.GetCurrentBounds(imagePos);

            if (Config.Setting_LimitImagesToMonitor != Config.NONE)
            {
                // Fit to monitor height/width
                int limit = Config.Setting_LimitImagesToMonitor;

                if (limit == Config.AUTO)
                {
                    if (currentBounds.Height < currentBounds.Width)
                    {
                        limit = Config.HEIGHT;
                    }
                    else
                    {
                        limit = Config.WIDTH;
                    }
                }

                if (limit == Config.HEIGHT && Image.Texture.Size.Y > currentBounds.Height)
                {
                    Zoom(1 + (((float)currentBounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                    FitToMonitorHeightForced = true;
                }
                else if (limit == Config.WIDTH && Image.Texture.Size.X > currentBounds.Width)
                {
                    Zoom(1 + (((float)currentBounds.Width - Image.Texture.Size.X) / Image.Texture.Size.X), true);
                    AutomaticallyZoomed = true;
                }
            }
            if (Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_MinImageSize)
            {
                // Reisze images smaller than min size to min size
                AutomaticallyZoomed = true;
                Zoom(Config.Setting_MinImageSize / Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y), true);
            }

            // Center image or place in top-left corner if it's a large/wide image.
            IntRect currentWorkingArea;

            if (!FitToMonitorHeightForced)
            {
                currentWorkingArea = ImageViewerUtils.GetCurrentWorkingArea(imagePos);
            }
            else
            {
                currentWorkingArea = currentBounds;
            }

            if (Config.Setting_PositionLargeWideImagesInCorner && Image.Texture.Size.X * CurrentZoom > Image.Texture.Size.Y * CurrentZoom && Image.Texture.Size.X * CurrentZoom >= currentWorkingArea.Width)
            {
                NextWindowPos = new Vector2i(currentWorkingArea.Left, currentWorkingArea.Top);
            }
            else
            {
                NextWindowPos = new Vector2i(currentWorkingArea.Left + (currentWorkingArea.Width / 2) - ((int)(Image.Texture.Size.X * CurrentZoom) / 2), currentWorkingArea.Top + (currentWorkingArea.Height / 2) - ((int)(Image.Texture.Size.Y * CurrentZoom) / 2));
            }

            // Force Always on Top?
            if (FitToMonitorHeightForced || (Image.Texture.Size.Y >= currentBounds.Height && Image.Texture.Size.X < currentBounds.Width))
            {
                ForceAlwaysOnTopNextTick = true;
            }
        }
예제 #5
0
        public ImageViewer(string file)
        {
            IL.Initialize();
            Graphics.Init();

            // Extension supported?
            if (!ImageViewerUtils.IsValidExtension(file, EXTENSIONS))
            {
                return;
            }

            // Save Mouse Position -> will open image at this position
            Vector2i mousePos = Mouse.GetPosition();

            // Get Image
            LoadImage(file);

            if (Image == null)
            {
                return;
            }

            // Load Config File
            Config = new Config();
            Config.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt"));

            if (Config.Setting_ListenForConfigChanges)
            {
                ConfigFileWatcher = new FileSystemWatcher(AppDomain.CurrentDomain.BaseDirectory, "config.txt");
                ConfigFileWatcher.NotifyFilter        = NotifyFilters.LastWrite;
                ConfigFileWatcher.Changed            += new FileSystemEventHandler(OnConfigChanged);
                ConfigFileWatcher.EnableRaisingEvents = true;
            }

            // Create Context Menu
            ContextMenu = new ContextMenu(this);
            ContextMenu.LoadItems(Config.ContextMenu, Config.ContextMenu_Animation, Config.ContextMenu_Animation_InsertAtIndex);
            ContextMenu.Setup(false);

            // Create Window
            Window = new RenderWindow(new VideoMode(Image.Texture.Size.X, Image.Texture.Size.Y), File + " - vimage", Styles.None);
            Window.SetActive();

            // Make Window Transparent (can only tell if image being viewed has transparency)
            DWM_BLURBEHIND bb = new DWM_BLURBEHIND(false);

            bb.dwFlags  = DWM_BB.Enable;
            bb.fEnable  = true;
            bb.hRgnBlur = new IntPtr();
            DWM.DwmEnableBlurBehindWindow(Window.SystemHandle, ref bb);

            bool _forceAlwaysOnTop = false;

            // Get Bounds
            IntRect bounds = ImageViewerUtils.GetCurrentBounds(mousePos);

            // Resize Window
            if (Config.Setting_LimitImagesToMonitor != Config.NONE)
            {
                // Fit to monitor height/width
                int limit = Config.Setting_LimitImagesToMonitor;

                if (limit == Config.AUTO)
                {
                    if (bounds.Height < bounds.Width)
                    {
                        limit = Config.HEIGHT;
                    }
                    else
                    {
                        limit = Config.WIDTH;
                    }
                }

                if (limit == Config.HEIGHT && Image.Texture.Size.Y > bounds.Height)
                {
                    Zoom(1 + (((float)bounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                    FitToMonitorHeightForced = true;
                }
                else if (limit == Config.WIDTH && Image.Texture.Size.X > bounds.Width)
                {
                    Zoom(1 + (((float)bounds.Width - Image.Texture.Size.X) / Image.Texture.Size.X), true);
                    AutomaticallyZoomed = true;
                }
            }
            if (Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_MinImageSize)
            {
                // Reisze images smaller than min size to min size
                AutomaticallyZoomed = true;
                Zoom(Config.Setting_MinImageSize / Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y), true);
            }
            // Use Texture Size * Zoom instead of Window.Size since it wouldn't have updated yet
            Vector2i winSize = new Vector2i((int)(Image.Texture.Size.X * CurrentZoom), (int)(Image.Texture.Size.Y * CurrentZoom));


            // Position Window
            Vector2i winPos;

            if (Config.Setting_PositionLargeWideImagesInCorner && CurrentImageSize().X > CurrentImageSize().Y&& CurrentImageSize().X *CurrentZoom >= bounds.Width)
            {
                // Position Window in top-left if the image is wide (ie: a Desktop Wallpaper / Screenshot)
                winPos = new Vector2i(bounds.Left, bounds.Top);
            }
            else if (Config.Setting_OpenAtMousePosition)
            {
                // At Mouse Position
                winPos = new Vector2i(mousePos.X - (int)(winSize.X / 2), mousePos.Y - (int)(winSize.Y / 2));

                if (!FitToMonitorHeightForced)
                {
                    if (winPos.Y < bounds.Top)
                    {
                        winPos.Y = 0;
                    }
                    else if (winPos.Y + winSize.Y > bounds.Height)
                    {
                        winPos.Y = bounds.Height - (int)winSize.Y;
                    }
                }
                else
                {
                    winPos.Y = bounds.Top;
                }

                if (winPos.X < bounds.Left)
                {
                    winPos.X = bounds.Left;
                }
                else if (winPos.X + winSize.X > bounds.Left + bounds.Width)
                {
                    winPos.X = bounds.Left + bounds.Width - (int)winSize.X;
                }
            }
            else
            {
                // At Monitor Center
                IntRect monitorBounds = ImageViewerUtils.GetCurrentBounds(mousePos);
                winPos = new Vector2i(monitorBounds.Left + (int)((monitorBounds.Width - winSize.X) / 2), monitorBounds.Top + (int)((monitorBounds.Height - winSize.Y) / 2));
            }

            Window.Position = winPos;

            // Force Always On Top Mode (so it's above the task bar)
            if (FitToMonitorHeightForced || (Image.Texture.Size.Y >= bounds.Height && Image.Texture.Size.X < bounds.Width))
            {
                _forceAlwaysOnTop = true;
            }

            // Defaults
            // Rotation (some images have a rotation set in their exif data)
            RotateImage(DefaultRotation, false);
            // Smoothing
            if (Image is AnimatedImage)
            {
                Image.Data.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }
            else
            {
                Image.Texture.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }
            // Backgrounds For Images With Transparency
            BackgroundsForImagesWithTransparency = Config.Setting_BackgroundForImagesWithTransparencyDefault;

            ForceAlwaysOnTopNextTick = _forceAlwaysOnTop;

            Redraw();
            NextWindowPos = Window.Position;

            // Interaction
            Window.Closed              += OnWindowClosed;
            Window.MouseButtonPressed  += OnMouseDown;
            Window.MouseButtonReleased += OnMouseUp;
            Window.MouseWheelMoved     += OnMouseWheelMoved;
            Window.MouseMoved          += OnMouseMoved;
            Window.KeyReleased         += OnKeyUp;
            Window.KeyPressed          += OnKeyDown;

            // Loop
            Stopwatch clock = new Stopwatch();

            clock.Start();

            while (Window.IsOpen())
            {
                // Add in some idle time to not thrash the CPU
                Thread.Sleep(1);

                if (CloseNextTick)
                {
                    Window.Close();
                    break;
                }

                // Process events
                Window.DispatchEvents();

                if (ReloadConfigNextTick)
                {
                    ReloadConfig();
                    ReloadConfigNextTick = false;
                }

                // Animated Image?
                if (Image is AnimatedImage)
                {
                    bool imageUpdated = Image.Update((float)clock.Elapsed.TotalMilliseconds);
                    if (!Updated && imageUpdated)
                    {
                        Update();
                    }
                }
                clock.Restart();

                // Drag Window
                if (Dragging)
                {
                    Window.Position = new Vector2i(Mouse.GetPosition().X - DragPos.X, Mouse.GetPosition().Y - DragPos.Y);
                }

                // Update
                if (Updated)
                {
                    Updated = false;
                    Redraw();
                    Window.Position = NextWindowPos;
                }

                if (ForceAlwaysOnTopNextTick)
                {
                    bounds = ImageViewerUtils.GetCurrentBounds(Window.Position);
                    if (Window.Size.Y >= bounds.Height && Window.Size.X < bounds.Width)
                    {
                        ForceAlwaysOnTop();
                    }
                    else
                    {
                        ForceAlwaysOnTopNextTick = false;
                    }
                }

                if (PreloadNextImageStart)
                {
                    PreloadNextImage();
                }
            }
        }
예제 #6
0
        public void ToggleFitToMonitor(int dimension)
        {
            UnforceAlwaysOnTop();

            IntRect bounds;

            if (FitToMonitorAlt)
            {
                bounds = ImageViewerUtils.GetCurrentWorkingArea(Mouse.GetPosition());
            }
            else
            {
                bounds = ImageViewerUtils.GetCurrentBounds(Mouse.GetPosition());
            }

            if (CurrentZoom == 1)
            {
                // Fit to Monitor Height
                if (dimension == Config.AUTO)
                {
                    if (bounds.Height < bounds.Width)
                    {
                        dimension = Config.HEIGHT;
                    }
                    else
                    {
                        dimension = Config.WIDTH;
                    }
                }

                if (dimension == Config.HEIGHT)
                {
                    FitToMonitorHeight = true;
                    if (Image.Rotation == 90 || Image.Rotation == 270)
                    {
                        Zoom(1 + (((float)bounds.Height - Image.Texture.Size.X) / Image.Texture.Size.X), true);
                    }
                    else
                    {
                        Zoom(1 + (((float)bounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                    }
                    NextWindowPos = new Vector2i(NextWindowPos.X, bounds.Top);
                }
                else if (dimension == Config.WIDTH)
                {
                    FitToMonitorWidth = true;
                    if (Image.Rotation == 90 || Image.Rotation == 270)
                    {
                        Zoom(1 + (((float)bounds.Width - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                    }
                    else
                    {
                        Zoom(1 + (((float)bounds.Width - Image.Texture.Size.X) / Image.Texture.Size.X), true);
                    }
                    NextWindowPos = new Vector2i(bounds.Left, NextWindowPos.Y);
                }
            }
            else
            {
                // Full Size
                FitToMonitorHeight = false;
                FitToMonitorWidth  = false;
                Zoom(1, true);
                NextWindowPos = new Vector2i(NextWindowPos.X < 0 ? 0 : NextWindowPos.X, NextWindowPos.Y < 0 ? 0 : NextWindowPos.Y);
            }


            if (CurrentImageSize().X *CurrentZoom >= bounds.Width)
            {
                NextWindowPos = new Vector2i(bounds.Left, bounds.Top); // Position Window at 0,0 if the image is large (ie: a Desktop wallpaper)
            }
            else if (!FitToMonitorAlt)
            {
                ForceAlwaysOnTopNextTick = true;
            }

            AutomaticallyZoomed = false;
        }
예제 #7
0
파일: ImageViewer.cs 프로젝트: arxae/vimage
        private bool ChangeImage(string fileName)
        {
            Image.Dispose();
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

            Dragging = false;
            float prevRotation        = Image.Rotation;
            int   prevDefaultRotation = DefaultRotation;

            if (AutomaticallyZoomed)
            {
                // don't keep current zoom value if it wasn't set by user
                AutomaticallyZoomed = false;
                CurrentZoom         = 1;
            }

            if (!LoadImage(fileName))
            {
                return(false);
            }

            SFML.Graphics.View view = new SFML.Graphics.View(Window.DefaultView);
            view.Center = new Vector2f(Image.Texture.Size.X / 2, Image.Texture.Size.Y / 2);
            view.Size   = new Vector2f(Image.Texture.Size.X, Image.Texture.Size.Y);
            Window.SetView(view);

            // Rotation
            RotateImage(prevRotation == prevDefaultRotation ? DefaultRotation : (int)prevRotation, false);
            // Smoothing
            if (Image is AnimatedImage)
            {
                Image.Data.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }
            else
            {
                Image.Texture.Smooth = Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) < Config.Setting_SmoothingMinImageSize ? false : Config.Setting_SmoothingDefault;
            }

            IntRect bounds = ImageViewerUtils.GetCurrentBounds(Window.Position);

            if (Config.Setting_LimitImagesToMonitorHeight && (FitToMonitorHeight || (Image.Texture.Size.Y * CurrentZoom >= bounds.Height || (FitToMonitorHeightForced && Image.Texture.Size.Y >= bounds.Height))))
            {
                // Fit to monitor height if it's higher than monitor height (or FitToMonitorHeight is true).
                Zoom(1 + (((float)bounds.Height - Image.Texture.Size.Y) / Image.Texture.Size.Y), true);
                NextWindowPos = new Vector2i(NextWindowPos.X, bounds.Top);
                if (!FitToMonitorHeight)
                {
                    FitToMonitorHeightForced = true;
                }
            }
            else if (FitToMonitorHeightForced)
            {
                Zoom(1, true);
                FitToMonitorHeightForced = false;
            }
            else if (Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y) * CurrentZoom < Config.Setting_MinImageSize)
            {
                // Reisze images smaller than min size to min size
                AutomaticallyZoomed = true;
                Zoom(Config.Setting_MinImageSize / Math.Min(Image.Texture.Size.X, Image.Texture.Size.Y), true);
            }
            else
            {
                Zoom(CurrentZoom, true);
            }

            // Position Window at 0,0 if the image is wide (ie: a Desktop Wallpaper / Screenshot)
            if (Config.Setting_PositionLargeWideImagesInCorner && Image.Texture.Size.X > Image.Texture.Size.Y && Image.Texture.Size.X * CurrentZoom >= VideoMode.DesktopMode.Width)
            {
                NextWindowPos = new Vector2i(0, 0);
            }

            // Force Always On Top Mode (so it's above the task bar) - will only happen if height >= window height
            ForceAlwaysOnTopNextTick = true;

            Window.SetTitle(fileName + " - vimage");
            ContextMenu.Setup(false);

            return(true);
        }