Skip to content

Commit 797a2bb

Browse files
committed
Removed useless switches to calculate blocksize when downscaling
1 parent c9ef361 commit 797a2bb

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

ScreenCapture.NET.DX9/DX9ScreenCapture.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,7 @@ private void DownscaleZone(CaptureZone<ColorBGRA> captureZone, in Span<byte> buf
131131
ReadOnlySpan<byte> source = _buffer;
132132
Span<byte> target = buffer;
133133

134-
int blockSize = captureZone.DownscaleLevel switch
135-
{
136-
1 => 2,
137-
2 => 4,
138-
3 => 8,
139-
4 => 16,
140-
5 => 32,
141-
6 => 64,
142-
7 => 128,
143-
8 => 256,
144-
_ => (int)Math.Pow(2, captureZone.DownscaleLevel),
145-
};
134+
int blockSize = 1 << captureZone.DownscaleLevel;
146135

147136
int offsetX = captureZone.X;
148137
int offsetY = captureZone.Y;

ScreenCapture.NET.X11/X11ScreenCapture.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,7 @@ private void DownscaleZone(CaptureZone<ColorBGRA> captureZone, in Span<byte> buf
9696
ReadOnlySpan<byte> source = Data;
9797
Span<byte> target = buffer;
9898

99-
int blockSize = captureZone.DownscaleLevel switch
100-
{
101-
1 => 2,
102-
2 => 4,
103-
3 => 8,
104-
4 => 16,
105-
5 => 32,
106-
6 => 64,
107-
7 => 128,
108-
8 => 256,
109-
_ => (int)Math.Pow(2, captureZone.DownscaleLevel),
110-
};
99+
int blockSize = 1 << captureZone.DownscaleLevel;
111100

112101
int offsetX = captureZone.X;
113102
int offsetY = captureZone.Y;

0 commit comments

Comments
 (0)