From 25c7e56c31f0ae7595c29c88575f4ad435e8ce09 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 8 Mar 2013 11:18:49 +0000 Subject: [PATCH] Fixed a bug when cropping a large image which was scrolled, we didn't consider the scrolling offset. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2527 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/ImageEditorForm.cs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index c07a4f26c..b92b1f27d 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -1281,24 +1281,23 @@ namespace Greenshot { return; } Size imageSize = this.Surface.Image.Size; - Size currentImageClientSize = this.panel1.ClientSize; + Size currentClientSize = this.panel1.ClientSize; var canvas = this.Surface as Control; - if (currentImageClientSize.Width > imageSize.Width) { - if (canvas != null) { - canvas.Left = (currentImageClientSize.Width - imageSize.Width) / 2; - } - } else { - if (canvas != null) { - canvas.Left = 0; + Panel panel = (Panel)canvas.Parent; + int offsetX = -panel.HorizontalScroll.Value; + int offsetY = -panel.VerticalScroll.Value; + if (canvas != null) { + if (currentClientSize.Width > imageSize.Width) { + canvas.Left = offsetX + ((currentClientSize.Width - imageSize.Width) / 2); + } else { + canvas.Left = offsetX + 0; } } - if (currentImageClientSize.Height > imageSize.Height) { - if (canvas != null) { - canvas.Top = (currentImageClientSize.Height - imageSize.Height) / 2; - } - } else { - if (canvas != null) { - canvas.Top = 0; + if (canvas != null) { + if (currentClientSize.Height > imageSize.Height) { + canvas.Top = offsetY + ((currentClientSize.Height - imageSize.Height) / 2); + } else { + canvas.Top = offsetY + 0; } } }