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
This commit is contained in:
RKrom 2013-03-08 11:18:49 +00:00
commit 25c7e56c31

View file

@ -1281,24 +1281,23 @@ namespace Greenshot {
return; return;
} }
Size imageSize = this.Surface.Image.Size; Size imageSize = this.Surface.Image.Size;
Size currentImageClientSize = this.panel1.ClientSize; Size currentClientSize = this.panel1.ClientSize;
var canvas = this.Surface as Control; var canvas = this.Surface as Control;
if (currentImageClientSize.Width > imageSize.Width) { Panel panel = (Panel)canvas.Parent;
if (canvas != null) { int offsetX = -panel.HorizontalScroll.Value;
canvas.Left = (currentImageClientSize.Width - imageSize.Width) / 2; int offsetY = -panel.VerticalScroll.Value;
} if (canvas != null) {
} else { if (currentClientSize.Width > imageSize.Width) {
if (canvas != null) { canvas.Left = offsetX + ((currentClientSize.Width - imageSize.Width) / 2);
canvas.Left = 0; } else {
canvas.Left = offsetX + 0;
} }
} }
if (currentImageClientSize.Height > imageSize.Height) { if (canvas != null) {
if (canvas != null) { if (currentClientSize.Height > imageSize.Height) {
canvas.Top = (currentImageClientSize.Height - imageSize.Height) / 2; canvas.Top = offsetY + ((currentClientSize.Height - imageSize.Height) / 2);
} } else {
} else { canvas.Top = offsetY + 0;
if (canvas != null) {
canvas.Top = 0;
} }
} }
} }