mirror of
https://github.com/DarthAffe/ScreenCapture.NET.git
synced 2026-11-11 11:26:31 +00:00
Added doc comments
This commit is contained in:
1 parent
e6202d88b5
commit
9bdb07fdc5
11 files changed
+346
-15
No files matched your search
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
using System;
|
||||
|
||||
namespace ScreenCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration for the detection and removal of black bars around the screen image.
|
||||
/// </summary>
|
||||
public sealed class BlackBarDetection
|
||||
{
|
||||
#region Properties & Fields
|
||||
@@ -9,18 +13,33 @@ namespace ScreenCapture
|
||||
private readonly CaptureZone _captureZone;
|
||||
|
||||
private int? _top;
|
||||
/// <summary>
|
||||
/// Gets the size of the detected black bar at the top of the image.
|
||||
/// </summary>
|
||||
public int Top => _top ??= CalculateTop();
|
||||
|
||||
private int? _bottom;
|
||||
/// <summary>
|
||||
/// Gets the size of the detected black bar at the bottom of the image.
|
||||
/// </summary>
|
||||
public int Bottom => _bottom ??= CalculateBottom();
|
||||
|
||||
private int? _left;
|
||||
/// <summary>
|
||||
/// Gets the size of the detected black bar at the left of the image.
|
||||
/// </summary>
|
||||
public int Left => _left ??= CalculateLeft();
|
||||
|
||||
private int? _right;
|
||||
/// <summary>
|
||||
/// Gets the size of the detected black bar at the right of the image.
|
||||
/// </summary>
|
||||
public int Right => _right ??= CalculateRight();
|
||||
|
||||
private int _theshold = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the threshold of "blackness" used to detect black bars. (e. g. Threshold 5 will consider a pixel of color [5,5,5] as black.) (default 0)
|
||||
/// </summary>
|
||||
public int Threshold
|
||||
{
|
||||
get => _theshold;
|
||||
@@ -35,7 +54,7 @@ namespace ScreenCapture
|
||||
|
||||
#region Constructors
|
||||
|
||||
public BlackBarDetection(CaptureZone captureZone)
|
||||
internal BlackBarDetection(CaptureZone captureZone)
|
||||
{
|
||||
this._captureZone = captureZone;
|
||||
}
|
||||
@@ -44,6 +63,9 @@ namespace ScreenCapture
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Invalidates the cached values and recalculates <see cref="Top"/>, <see cref="Bottom"/>, <see cref="Left"/> and <see cref="Right"/>.
|
||||
/// </summary>
|
||||
public void InvalidateCache()
|
||||
{
|
||||
_top = null;
|
||||
|
||||
@@ -1,45 +1,126 @@
|
||||
using System;
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
using System;
|
||||
|
||||
namespace ScreenCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a duplicated region on the screen.
|
||||
/// </summary>
|
||||
public sealed class CaptureZone
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique id of this <see cref="CaptureZone"/>.
|
||||
/// </summary>
|
||||
public int Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the x-location of the region on the screen.
|
||||
/// </summary>
|
||||
public int X { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the y-location of the region on the screen.
|
||||
/// </summary>
|
||||
public int Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of the region on the screen.
|
||||
/// </summary>
|
||||
public int Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the region on the screen.
|
||||
/// </summary>
|
||||
public int Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the level of downscaling applied to the image of this region before copying to local memory. The calculation is (width and height)/2^downscaleLevel.
|
||||
/// </summary>
|
||||
public int DownscaleLevel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original width of the region (this equals <see cref="Width"/> if <see cref="DownscaleLevel"/> is 0).
|
||||
/// </summary>
|
||||
public int UnscaledWidth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original height of the region (this equals <see cref="Height"/> if <see cref="DownscaleLevel"/> is 0).
|
||||
/// </summary>
|
||||
public int UnscaledHeight { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actually captured width of the region (this can be greated than <see cref="Width"/> due to size-constraints on the GPU).
|
||||
/// </summary>
|
||||
public int CaptureWidth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actually captured height of the region (this can be greated than <see cref="Height"/> due to size-constraints on the GPU).
|
||||
/// </summary>
|
||||
public int CaptureHeight { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of the buffer the capture is saved to.
|
||||
/// Equals <see cref="CaptureWidth"/> most of the time but can be bigger.
|
||||
/// </summary>
|
||||
public int BufferWidth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the buffer the capture is saved to.
|
||||
/// Equals <see cref="CaptureHeight"/> most of the time but can be bigger.
|
||||
/// </summary>
|
||||
public int BufferHeight { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the buffer containing the image data. Format depends on the specific capture but is most likely BGRA32.
|
||||
/// </summary>
|
||||
public byte[] Buffer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the config for black-bar detection.
|
||||
/// </summary>
|
||||
public BlackBarDetection BlackBars { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the <see cref="CaptureZone"/> should be automatically updated on every captured frame.
|
||||
/// </summary>
|
||||
public bool AutoUpdate { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets if an update for the <see cref="CaptureZone"/> is requested on the next captured frame.
|
||||
/// </summary>
|
||||
public bool IsUpdateRequested { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="CaptureZone"/> is updated.
|
||||
/// </summary>
|
||||
public event EventHandler? Updated;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CaptureZone"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique id of this <see cref="CaptureZone"/>.</param>
|
||||
/// <param name="x">The x-location of the region on the screen.</param>
|
||||
/// <param name="y">The y-location of the region on the screen.</param>
|
||||
/// <param name="width">The width of the region on the screen.</param>
|
||||
/// <param name="height">The height of the region on the screen.</param>
|
||||
/// <param name="downscaleLevel">The level of downscaling applied to the image of this region before copying to local memory.</param>
|
||||
/// <param name="unscaledWidth">The original width of the region.</param>
|
||||
/// <param name="unscaledHeight">The original height of the region</param>
|
||||
/// <param name="captureWidth">The actually captured width of the region.</param>
|
||||
/// <param name="captureHeight">The actually captured height of the region.</param>
|
||||
/// <param name="bufferWidth">The width of the buffer the capture is saved to.</param>
|
||||
/// <param name="bufferHeight">The height of the buffer the capture is saved to.</param>
|
||||
/// <param name="buffer">The buffer containing the image data.</param>
|
||||
public CaptureZone(int id, int x, int y, int width, int height, int downscaleLevel, int unscaledWidth, int unscaledHeight, int captureWidth, int captureHeight, int bufferWidth, int bufferHeight, byte[] buffer)
|
||||
{
|
||||
this.Id = id;
|
||||
@@ -63,8 +144,16 @@ namespace ScreenCapture
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Requests to update this <see cref="CaptureZone"/> when the next frame is captured.
|
||||
/// Only necessary if <see cref="AutoUpdate"/> is set to <c>false</c>.
|
||||
/// </summary>
|
||||
public void RequestUpdate() => IsUpdateRequested = true;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the <see cref="CaptureZone"/> as updated.
|
||||
/// WARNING: This should not be called outside of an <see cref="IScreenCapture"/>!
|
||||
/// </summary>
|
||||
public void SetUpdated()
|
||||
{
|
||||
IsUpdateRequested = false;
|
||||
@@ -73,10 +162,19 @@ namespace ScreenCapture
|
||||
Updated?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Id;
|
||||
/// <summary>
|
||||
/// Determines whether this <see cref="CaptureZone"/> equals the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="CaptureZone"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(CaptureZone other) => Id == other.Id;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object? obj) => obj is CaptureZone other && Equals(other);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => Id;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,51 @@
|
||||
namespace ScreenCapture
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
namespace ScreenCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a display connected to graphics-card.
|
||||
/// </summary>
|
||||
public readonly struct Display
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the <see cref="Display"/>.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the <see cref="Display"/>.
|
||||
/// </summary>
|
||||
public string DeviceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the with of the <see cref="Display"/>.
|
||||
/// </summary>
|
||||
public int Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the <see cref="Display"/>.
|
||||
/// </summary>
|
||||
public int Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GraphicsCard"/> this <see cref="Display"/> is connected to.
|
||||
/// </summary>
|
||||
public GraphicsCard GraphicsCard { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Display"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the <see cref="Display"/>.</param>
|
||||
/// <param name="deviceName">The name of the <see cref="Display"/>.</param>
|
||||
/// <param name="width">The with of the <see cref="Display"/>.</param>
|
||||
/// <param name="height">The height of the <see cref="Display"/>.</param>
|
||||
/// <param name="graphicsCard">The <see cref="GraphicsCard"/> this <see cref="Display"/> is connected to.</param>
|
||||
public Display(int index, string deviceName, int width, int height, GraphicsCard graphicsCard)
|
||||
{
|
||||
this.Index = index;
|
||||
@@ -28,11 +58,36 @@
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this <see cref="Display"/> equals the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Display"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(Display other) => Index == other.Index;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object? obj) => obj is Display other && Equals(other);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => Index;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="Display"/> are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first value.</param>
|
||||
/// <param name="right">The second value.</param>
|
||||
/// <returns><c>true</c> if the two specified displays are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(Display left, Display right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="Display"/> are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first value.</param>
|
||||
/// <param name="right">The second value.</param>
|
||||
/// <returns><c>true</c> if the two specified displays are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(Display left, Display right) => !(left == right);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,45 @@
|
||||
namespace ScreenCapture
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
namespace ScreenCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a graphics-card.
|
||||
/// </summary>
|
||||
public readonly struct GraphicsCard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the <see cref="GraphicsCard"/>.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the <see cref="GraphicsCard"/>.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vendor-id of the <see cref="GraphicsCard"/>.
|
||||
/// </summary>
|
||||
public int VendorId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device-id of the <see cref="GraphicsCard"/>.
|
||||
/// </summary>
|
||||
public int DeviceId { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GraphicsCard"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the <see cref="GraphicsCard"/>.</param>
|
||||
/// <param name="name">The name of the <see cref="GraphicsCard"/>.</param>
|
||||
/// <param name="vendorId">The vendor-id of the <see cref="GraphicsCard"/>.</param>
|
||||
/// <param name="deviceId">The device-id of the <see cref="GraphicsCard"/>.</param>
|
||||
public GraphicsCard(int index, string name, int vendorId, int deviceId)
|
||||
{
|
||||
this.Index = index;
|
||||
@@ -25,10 +52,35 @@
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this <see cref="Display"/> equals the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Display"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</returns>
|
||||
public bool Equals(GraphicsCard other) => Index == other.Index;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object? obj) => obj is GraphicsCard other && Equals(other);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => Index;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="GraphicsCard"/> are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first value.</param>
|
||||
/// <param name="right">The second value.</param>
|
||||
/// <returns><c>true</c> if the two specified graphics-cards are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(GraphicsCard left, GraphicsCard right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="GraphicsCard"/> are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first value.</param>
|
||||
/// <param name="right">The second value.</param>
|
||||
/// <returns><c>true</c> if the two specified graphics-cards are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(GraphicsCard left, GraphicsCard right) => !(left == right);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user