mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Combine improvements
This commit is contained in:
parent
d6243d0582
commit
687d03f86f
2 changed files with 22 additions and 15 deletions
|
@ -284,7 +284,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudCombineVertical.Location = new System.Drawing.Point(88, 16);
|
||||
this.nudCombineVertical.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -298,7 +298,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudCombineLastVertical.Location = new System.Drawing.Point(88, 40);
|
||||
this.nudCombineLastVertical.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -365,7 +365,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudTrimLeft.Location = new System.Drawing.Point(64, 16);
|
||||
this.nudTrimLeft.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -379,7 +379,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudTrimBottom.Location = new System.Drawing.Point(64, 88);
|
||||
this.nudTrimBottom.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -393,7 +393,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudTrimTop.Location = new System.Drawing.Point(64, 40);
|
||||
this.nudTrimTop.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -407,7 +407,7 @@ private void InitializeComponent()
|
|||
//
|
||||
this.nudTrimRight.Location = new System.Drawing.Point(64, 64);
|
||||
this.nudTrimRight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
5000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
|
|
@ -347,7 +347,7 @@ private Image CombineImages()
|
|||
Rectangle rect = new Rectangle(Options.TrimLeftEdge, Options.TrimTopEdge, image.Width - Options.TrimLeftEdge - Options.TrimRightEdge,
|
||||
image.Height - Options.TrimTopEdge - Options.TrimBottomEdge);
|
||||
|
||||
if (i == images.Count - 1)
|
||||
if (images.Count > 2 && i == images.Count - 1)
|
||||
{
|
||||
rect.Y += Options.CombineAdjustmentLastVertical;
|
||||
rect.Height -= Options.CombineAdjustmentLastVertical;
|
||||
|
@ -395,7 +395,7 @@ private void GuessEdges()
|
|||
Rectangle rect = new Rectangle(0, 0, images[0].Width, images[0].Height);
|
||||
|
||||
using (UnsafeBitmap bmp1 = new UnsafeBitmap((Bitmap)images[0], true, ImageLockMode.ReadOnly))
|
||||
using (UnsafeBitmap bmp2 = new UnsafeBitmap((Bitmap)images[1], true, ImageLockMode.ReadOnly))
|
||||
using (UnsafeBitmap bmp2 = new UnsafeBitmap((Bitmap)images[images.Count - 1], true, ImageLockMode.ReadOnly))
|
||||
{
|
||||
bool valueFound = false;
|
||||
|
||||
|
@ -475,7 +475,14 @@ private void GuessCombineAdjustments()
|
|||
{
|
||||
isBusy = true;
|
||||
|
||||
nudCombineVertical.Value = CalculateVerticalOffset(images[0], images[1]);
|
||||
int vertical = 0;
|
||||
|
||||
for (int i = 0; i < images.Count - 1; i++)
|
||||
{
|
||||
vertical = Math.Max(vertical, CalculateVerticalOffset(images[i], images[i + 1]));
|
||||
}
|
||||
|
||||
nudCombineVertical.Value = vertical;
|
||||
|
||||
if (images.Count > 2)
|
||||
{
|
||||
|
@ -495,13 +502,13 @@ private int CalculateVerticalOffset(Image img1, Image img2, int ignoreRightOffse
|
|||
using (UnsafeBitmap bmp1 = new UnsafeBitmap((Bitmap)img1, true, ImageLockMode.ReadOnly))
|
||||
using (UnsafeBitmap bmp2 = new UnsafeBitmap((Bitmap)img2, true, ImageLockMode.ReadOnly))
|
||||
{
|
||||
for (int y = rect.Y; y < rect.Height; y++)
|
||||
for (int y = rect.Y; y < rect.Bottom; y++)
|
||||
{
|
||||
bool isLineMatches = true;
|
||||
|
||||
for (int x = rect.X; x < rect.Width; x++)
|
||||
for (int x = rect.X; x < rect.Right; x++)
|
||||
{
|
||||
if (bmp2.GetPixel(x, y) != bmp1.GetPixel(x, rect.Height - 1))
|
||||
if (bmp2.GetPixel(x, y) != bmp1.GetPixel(x, rect.Bottom - 1))
|
||||
{
|
||||
isLineMatches = false;
|
||||
break;
|
||||
|
@ -517,9 +524,9 @@ private int CalculateVerticalOffset(Image img1, Image img2, int ignoreRightOffse
|
|||
{
|
||||
bool isLineMatches2 = true;
|
||||
|
||||
for (int x2 = rect.X; x2 < rect.Width; x2++)
|
||||
for (int x2 = rect.X; x2 < rect.Right; x2++)
|
||||
{
|
||||
if (bmp2.GetPixel(x2, y2) != bmp1.GetPixel(x2, rect.Height - y3))
|
||||
if (bmp2.GetPixel(x2, y2) != bmp1.GetPixel(x2, rect.Bottom - y3))
|
||||
{
|
||||
isLineMatches2 = false;
|
||||
break;
|
||||
|
@ -538,7 +545,7 @@ private int CalculateVerticalOffset(Image img1, Image img2, int ignoreRightOffse
|
|||
|
||||
if (lineMatchesCount == matchCount || y2 == rect.Y)
|
||||
{
|
||||
return y;
|
||||
return y - rect.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue