Compare commits

..

No commits in common. "f314a4128b0c4083fa9536b48f6f0849a630162f" and "fd228af17041cc43e588ba33d897d80b56434b71" have entirely different histories.

5 changed files with 21 additions and 23 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 on the screen // Register the regions you want to capture om 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 separate thread as CaptureScreen blocks if the screen is not updated (still image). // This should be done in a loop on a seperate 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
IImageRow row = image.Rows[0]; IImage.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
IImageColumn column = image.Columns[0]; IImage.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,20 +88,17 @@ screenCapture.CaptureScreen();
using (fullscreen.Lock()) using (fullscreen.Lock())
{ {
IImage<ColorBGRA> image = fullscreen.Image; RefImage<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];
ImageRow<ColorBGRA> row = image.Rows[0]; ReadOnlyRefEnumerable<ColorBGRA> row = image.Rows[0];
ColorBGRA rowColorExample = row[10]; ColorBGRA rowColorExample = row[10];
ImageColumn<ColorBGRA> column = image.Columns[0]; ReadOnlyRefEnumerable<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,11 +27,12 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes> <PackageReleaseNotes>
- Fixed a memory-leak when disposing the ScreenCapture
</PackageReleaseNotes> </PackageReleaseNotes>
<Version>3.0.0</Version> <Version>2.0.4</Version>
<AssemblyVersion>3.0.0</AssemblyVersion> <AssemblyVersion>2.0.4</AssemblyVersion>
<FileVersion>3.0.0</FileVersion> <FileVersion>2.0.4</FileVersion>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

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

View File

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

View File

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