Skip to content

Commit 9be201c

Browse files
committed
Fixed black bar detection removing 1 pixel to much
1 parent 150c72e commit 9be201c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ScreenCapture.NET/Model/BlackBarDetection.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private int CalculateBottom()
9999
Span<byte> data = new(_captureZone.Buffer, row * stride, stride);
100100
for (int i = 0; i < data.Length; i += 4)
101101
if ((data[i] > threshold) || (data[i + 1] > threshold) || (data[i + 2] > threshold))
102-
return _captureZone.Height - row;
102+
return (_captureZone.Height - 1) - row;
103103
}
104104

105105
return 0;
@@ -114,7 +114,8 @@ private int CalculateLeft()
114114
for (int row = 0; row < _captureZone.Height; row++)
115115
{
116116
int offset = (stride * row) + (column * 4);
117-
if ((buffer[offset] > threshold) || (buffer[offset + 1] > threshold) || (buffer[offset + 2] > threshold)) return column;
117+
if ((buffer[offset] > threshold) || (buffer[offset + 1] > threshold) || (buffer[offset + 2] > threshold))
118+
return column;
118119
}
119120

120121
return 0;
@@ -129,7 +130,8 @@ private int CalculateRight()
129130
for (int row = 0; row < _captureZone.Height; row++)
130131
{
131132
int offset = (stride * row) + (column * 4);
132-
if ((buffer[offset] > threshold) || (buffer[offset + 1] > threshold) || (buffer[offset + 2] > threshold)) return _captureZone.Width - column;
133+
if ((buffer[offset] > threshold) || (buffer[offset + 1] > threshold) || (buffer[offset + 2] > threshold))
134+
return (_captureZone.Width - 1) - column;
133135
}
134136

135137
return 0;

0 commit comments

Comments
 (0)