Compare commits

...

2 Commits

Author SHA1 Message Date
f314a4128b Updated readme 2024-07-22 23:21:41 +02:00
e9eb490607 Bumped version to 3.0.0 2024-07-22 23:12:34 +02:00
5 changed files with 23 additions and 21 deletions

View File

@ -26,14 +26,14 @@ IEnumerable<Display> displays = screenCaptureService.GetDisplays(graphicsCards.F
// Create a screen-capture for all screens you want to capture // Create a screen-capture for all screens you want to capture
IScreenCapture screenCapture = screenCaptureService.GetScreenCapture(displays.First()); IScreenCapture screenCapture = screenCaptureService.GetScreenCapture(displays.First());
// Register the regions you want to capture om the screen // Register the regions you want to capture on the screen
// Capture the whole screen // Capture the whole screen
ICaptureZone fullscreen = screenCapture.RegisterCaptureZone(0, 0, screenCapture.Display.Width, screenCapture.Display.Height); ICaptureZone fullscreen = screenCapture.RegisterCaptureZone(0, 0, screenCapture.Display.Width, screenCapture.Display.Height);
// Capture a 100x100 region at the top left and scale it down to 50x50 // Capture a 100x100 region at the top left and scale it down to 50x50
ICaptureZone topLeft = screenCapture.RegisterCaptureZone(0, 0, 100, 100, downscaleLevel: 1); ICaptureZone topLeft = screenCapture.RegisterCaptureZone(0, 0, 100, 100, downscaleLevel: 1);
// Capture the screen // Capture the screen
// This should be done in a loop on a seperate thread as CaptureScreen blocks if the screen is not updated (still image). // This should be done in a loop on a separate thread as CaptureScreen blocks if the screen is not updated (still image).
screenCapture.CaptureScreen(); screenCapture.CaptureScreen();
// Do something with the captured image - e.g. access all pixels (same could be done with topLeft) // Do something with the captured image - e.g. access all pixels (same could be done with topLeft)
@ -57,12 +57,12 @@ using (fullscreen.Lock())
IColor imageColorExample = image[10, 20]; IColor imageColorExample = image[10, 20];
// Get the first row // Get the first row
IImage.IImageRow row = image.Rows[0]; IImageRow row = image.Rows[0];
// Get the 10th pixel of the row // Get the 10th pixel of the row
IColor rowColorExample = row[10]; IColor rowColorExample = row[10];
// Get the first column // Get the first column
IImage.IImageColumn column = image.Columns[0]; IImageColumn column = image.Columns[0];
// Get the 10th pixel of the column // Get the 10th pixel of the column
IColor columnColorExample = column[10]; IColor columnColorExample = column[10];
@ -73,7 +73,7 @@ using (fullscreen.Lock())
} }
``` ```
IF you know which Capture-provider you're using it performs a bit better to not use the abstraction but a more low-level approach instead. If you know which Capture-provider you're using it performs a bit better to not use the abstraction but a more low-level approach instead.
This is the same example as above but without using the interfaces: This is the same example as above but without using the interfaces:
```csharp ```csharp
DX11ScreenCaptureService screenCaptureService = new DX11ScreenCaptureService(); DX11ScreenCaptureService screenCaptureService = new DX11ScreenCaptureService();
@ -88,17 +88,20 @@ screenCapture.CaptureScreen();
using (fullscreen.Lock()) using (fullscreen.Lock())
{ {
RefImage<ColorBGRA> image = fullscreen.Image; IImage<ColorBGRA> image = fullscreen.Image;
// You can also get a ref image which has a slight performance benefit in some cases
// RefImage<ColorBGRA> refImage = image.AsRefImage();
foreach (ColorBGRA color in image) foreach (ColorBGRA color in image)
Console.WriteLine($"A: {color.A}, R: {color.R}, G: {color.G}, B: {color.B}"); Console.WriteLine($"A: {color.A}, R: {color.R}, G: {color.G}, B: {color.B}");
ColorBGRA imageColorExample = image[10, 20]; ColorBGRA imageColorExample = image[10, 20];
ReadOnlyRefEnumerable<ColorBGRA> row = image.Rows[0]; ImageRow<ColorBGRA> row = image.Rows[0];
ColorBGRA rowColorExample = row[10]; ColorBGRA rowColorExample = row[10];
ReadOnlyRefEnumerable<ColorBGRA> column = image.Columns[0]; ImageColumn<ColorBGRA> column = image.Columns[0];
ColorBGRA columnColorExample = column[10]; ColorBGRA columnColorExample = column[10];
RefImage<ColorBGRA> subImage = image[100, 150, 400, 300]; RefImage<ColorBGRA> subImage = image[100, 150, 400, 300];

View File

@ -27,12 +27,11 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes> <PackageReleaseNotes>
- Fixed a memory-leak when disposing the ScreenCapture
</PackageReleaseNotes> </PackageReleaseNotes>
<Version>2.0.4</Version> <Version>3.0.0</Version>
<AssemblyVersion>2.0.4</AssemblyVersion> <AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>2.0.4</FileVersion> <FileVersion>3.0.0</FileVersion>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -29,9 +29,9 @@
<PackageReleaseNotes> <PackageReleaseNotes>
</PackageReleaseNotes> </PackageReleaseNotes>
<Version>2.0.4</Version> <Version>3.0.0</Version>
<AssemblyVersion>2.0.4</AssemblyVersion> <AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>2.0.4</FileVersion> <FileVersion>3.0.0</FileVersion>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -29,9 +29,9 @@
<PackageReleaseNotes> <PackageReleaseNotes>
</PackageReleaseNotes> </PackageReleaseNotes>
<Version>2.0.4</Version> <Version>3.0.0</Version>
<AssemblyVersion>2.0.4</AssemblyVersion> <AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>2.0.4</FileVersion> <FileVersion>3.0.0</FileVersion>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -28,9 +28,9 @@
<PackageReleaseNotes> <PackageReleaseNotes>
</PackageReleaseNotes> </PackageReleaseNotes>
<Version>2.0.4</Version> <Version>3.0.0</Version>
<AssemblyVersion>2.0.4</AssemblyVersion> <AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>2.0.4</FileVersion> <FileVersion>3.0.0</FileVersion>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>