diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-03 00:30:58 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-03 00:30:58 +0200 |
| commit | 90cd8600ddd80933a97612786c3a89a4eb299d1f (patch) | |
| tree | 6e61f33b2b1f791198a7a059dbe8d09ad4974a97 /Software/Visual_Studio | |
| parent | e02d0d2188f123618b7e394405769918a485309c (diff) | |
| download | Tango-90cd8600ddd80933a97612786c3a89a4eb299d1f.tar.gz Tango-90cd8600ddd80933a97612786c3a89a4eb299d1f.zip | |
synced from experiments.
Diffstat (limited to 'Software/Visual_Studio')
5 files changed, 15 insertions, 23 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/BitmapComparerResult.cs b/Software/Visual_Studio/Tango.RemoteDesktop/BitmapComparerResult.cs index 66a2f8660..1ebd4a529 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/BitmapComparerResult.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/BitmapComparerResult.cs @@ -18,8 +18,8 @@ namespace Tango.RemoteDesktop public TFrame Frame { get; set; } /// <summary> - /// Gets or sets a value indicating whether the <see cref="Frame"/> contains any differences. + /// Gets or sets the number of differences. /// </summary> - public bool ContainsDifference { get; set; } + public uint DifferenceCount { get; set; } } } diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/RasterBitmapComparer.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/RasterBitmapComparer.cs index 34250cc59..b1b186065 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/RasterBitmapComparer.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/RasterBitmapComparer.cs @@ -34,7 +34,7 @@ namespace Tango.RemoteDesktop.Comparers if (previousBitmap.Height != currentBitmap.Height || previousBitmap.Width != currentBitmap.Width) throw new InvalidOperationException("Cannot compare image of different size."); - bool hasDifference = false; + uint count = 0; Color matchColor = Color.Transparent; @@ -93,7 +93,7 @@ namespace Tango.RemoteDesktop.Comparers if (same != 4) { - hasDifference = true; + count++; } } @@ -113,7 +113,7 @@ namespace Tango.RemoteDesktop.Comparers return new BitmapComparerResult<RasterFrame>() { Frame = new RasterFrame(diffImage), - ContainsDifference = hasDifference + DifferenceCount = count }; } } diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/VectorBitmapComparer.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/VectorBitmapComparer.cs index 2500e8ac7..7f6dd9ccf 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/VectorBitmapComparer.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Comparers/VectorBitmapComparer.cs @@ -31,7 +31,7 @@ namespace Tango.RemoteDesktop.Comparers { VectorFrame vector = new VectorFrame(previousBitmap.Width, previousBitmap.Height); - bool hasDifference = false; + uint count = 0; if (previousBitmap == null | currentBitmap == null) throw new InvalidOperationException("Cannot compare image. They are the same instance"); @@ -104,7 +104,7 @@ namespace Tango.RemoteDesktop.Comparers Color = color }); - hasDifference = true; + count++; } } @@ -122,7 +122,7 @@ namespace Tango.RemoteDesktop.Comparers return new BitmapComparerResult<VectorFrame>() { Frame = vector, - ContainsDifference = hasDifference + DifferenceCount = count }; } } diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs index 915147d2a..1d7b4d7d4 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs @@ -151,19 +151,19 @@ namespace Tango.RemoteDesktop if (_previousBitmap == null) { _previousBitmap = bitmap.Clone() as Bitmap; - OnFrameReceived(bitmap, null, false); + OnFrameReceived(bitmap, null, 0); } else { var result = Comparer.CreateDifference(_previousBitmap, bitmap); _previousBitmap.Dispose(); _previousBitmap = bitmap.Clone() as Bitmap; - OnFrameReceived(bitmap, result.Frame, result.ContainsDifference); + OnFrameReceived(bitmap, result.Frame, result.DifferenceCount); } } else { - OnFrameReceived(bitmap, null, false); + OnFrameReceived(bitmap, null, 0); } int delay = Math.Max(5, (FrameRate * 10) - (int)watch.ElapsedMilliseconds); @@ -171,13 +171,13 @@ namespace Tango.RemoteDesktop } } - private void OnFrameReceived(Bitmap currentBitmap, TFrame diffFrame, bool hasDifference) + private void OnFrameReceived(Bitmap currentBitmap, TFrame diffFrame, uint differenceCount) { FrameReceived?.Invoke(this, new ScreenCaptureFrameReceivedEventArgs<TFrame>() { Frame = new ScreenCaptureFrame<TFrame>(currentBitmap, diffFrame) { - HasDifference = hasDifference + DifferenceCount = differenceCount } }); } diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs index 75e7a961f..12d749954 100644 --- a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs +++ b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs @@ -48,17 +48,9 @@ namespace Tango.RemoteDesktop } /// <summary> - /// Gets or sets a value indicating whether the difference frame is available and contains any differences. + /// Gets or sets the number differences. /// </summary> - private bool _hasDifference; - public bool HasDifference - { - get - { - return DifferenceAvailable && _hasDifference; - } - set { _hasDifference = value; } - } + public uint DifferenceCount { get; set; } /// <summary> /// Returns the difference frame. |
