forked from julianperrott/WowClassicGrindBot
-
-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathScreenCaptureHelper.cs
More file actions
32 lines (27 loc) · 865 Bytes
/
Copy pathScreenCaptureHelper.cs
File metadata and controls
32 lines (27 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Runtime.CompilerServices;
namespace Core;
internal static class ScreenCaptureHelper
{
public const int Bgra32Size = 4;
[SkipLocalsInit]
public static void CopyRegion(
ReadOnlySpan<byte> src, int srcRowPitch,
int srcX, int srcY,
Span<byte> dest,
int width, int height)
{
int bytesPerRow = width * Bgra32Size;
// Fast path: source region is contiguous (no X offset, no pitch padding)
if (srcX == 0 && srcRowPitch == bytesPerRow)
{
src.Slice(srcY * srcRowPitch, bytesPerRow * height).CopyTo(dest);
return;
}
for (int y = 0; y < height; y++)
{
src.Slice((srcY + y) * srcRowPitch + srcX * Bgra32Size, bytesPerRow)
.CopyTo(dest.Slice(y * bytesPerRow, bytesPerRow));
}
}
}