Skip to content

Commit

Permalink
While scrolling capturing ignore 50px bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex committed May 16, 2024
1 parent 0f96099 commit 6fb3a78
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ShareX.ScreenCaptureLib/ScrollingCaptureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,20 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage)
int matchIndex = 0;
int matchLimit = currentImage.Height / 2;
int ignoreSideOffset = Math.Max(50, currentImage.Width / 20);
int ignoreBottomOffset = Math.Max(50, currentImage.Height / 20);

if (currentImage.Width < ignoreSideOffset * 3)
{
ignoreSideOffset = 0;
}

Rectangle rect = new Rectangle(ignoreSideOffset, result.Height - currentImage.Height, currentImage.Width - ignoreSideOffset * 2, currentImage.Height);
if (currentImage.Height < ignoreBottomOffset * 3)
{
ignoreBottomOffset = 0;
}

Rectangle rect = new Rectangle(ignoreSideOffset, result.Height - currentImage.Height,
currentImage.Width - ignoreSideOffset * 2, currentImage.Height - ignoreBottomOffset);

BitmapData bdResult = result.LockBits(new Rectangle(0, 0, result.Width, result.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
BitmapData bdCurrentImage = currentImage.LockBits(new Rectangle(0, 0, currentImage.Width, currentImage.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Expand Down Expand Up @@ -300,16 +307,16 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage)
bestMatchIndex = matchIndex;
}

Bitmap newResult = new Bitmap(result.Width, result.Height + matchHeight);
Bitmap newResult = new Bitmap(result.Width, result.Height - ignoreBottomOffset + matchHeight);

using (Graphics g = Graphics.FromImage(newResult))
{
g.CompositingMode = CompositingMode.SourceCopy;
g.InterpolationMode = InterpolationMode.NearestNeighbor;

g.DrawImage(result, new Rectangle(0, 0, result.Width, result.Height),
new Rectangle(0, 0, result.Width, result.Height), GraphicsUnit.Pixel);
g.DrawImage(currentImage, new Rectangle(0, result.Height, currentImage.Width, matchHeight),
g.DrawImage(result, new Rectangle(0, 0, result.Width, result.Height - ignoreBottomOffset),
new Rectangle(0, 0, result.Width, result.Height - ignoreBottomOffset), GraphicsUnit.Pixel);
g.DrawImage(currentImage, new Rectangle(0, result.Height - ignoreBottomOffset, currentImage.Width, matchHeight),
new Rectangle(0, matchIndex + 1, currentImage.Width, matchHeight), GraphicsUnit.Pixel);
}

Expand Down

0 comments on commit 6fb3a78

Please sign in to comment.