Skip to content

Commit 343b97d

Browse files
committed
Fixewd possible out of range exception in the black-bar detection
1 parent df1b575 commit 343b97d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ScreenCapture.NET/Model/BlackBarDetection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private int CalculateBottom()
9494
{
9595
int threshold = Threshold;
9696
int stride = _captureZone.Stride;
97-
for (int row = _captureZone.Height; row >= 0; row--)
97+
for (int row = _captureZone.Height - 1; row >= 0; row--)
9898
{
9999
Span<byte> data = new(_captureZone.Buffer, row * stride, stride);
100100
for (int i = 0; i < data.Length; i += 4)
@@ -125,7 +125,7 @@ private int CalculateRight()
125125
int threshold = Threshold;
126126
int stride = _captureZone.Stride;
127127
byte[] buffer = _captureZone.Buffer;
128-
for (int column = _captureZone.Width; column >= 0; column--)
128+
for (int column = _captureZone.Width - 1; column >= 0; column--)
129129
for (int row = 0; row < _captureZone.Height; row++)
130130
{
131131
int offset = (stride * row) + (column * 4);

0 commit comments

Comments
 (0)