From 0dcd742a3c35527386a93e1b1ef761c2aeff8308 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 2 Mar 2020 23:30:34 +0200 Subject: Implemented Tango.RemoteDesktop. Implemented png 8 bit quantization. Implemented RasterFrame bounds clipping. Refactored VectorFrame to use indexed colors. --- .../Tango.RemoteDesktop/ScreenCaptureFrame.cs | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs (limited to 'Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs') diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs new file mode 100644 index 000000000..75e7a961f --- /dev/null +++ b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.RemoteDesktop.Frames; + +namespace Tango.RemoteDesktop +{ + /// + /// Represents a screen capture frame for holding the original bitmap and difference frame. + /// + /// The type of the frame. + /// + /// + public class ScreenCaptureFrame : RasterFrame, IDisposable where TFrame : IFrame + { + private TFrame _diffFrame; + + /// + /// Initializes a new instance of the class. + /// + /// The bitmap. + public ScreenCaptureFrame(Bitmap bitmap) : base(bitmap) + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The bitmap. + /// The difference frame. + public ScreenCaptureFrame(Bitmap bitmap, TFrame diffFrame) : this(bitmap) + { + _diffFrame = diffFrame; + } + + /// + /// Gets a value indicating whether a difference frame is available. + /// + public bool DifferenceAvailable + { + get { return _diffFrame != null; } + } + + /// + /// Gets or sets a value indicating whether the difference frame is available and contains any differences. + /// + private bool _hasDifference; + public bool HasDifference + { + get + { + return DifferenceAvailable && _hasDifference; + } + set { _hasDifference = value; } + } + + /// + /// Returns the difference frame. + /// + /// + /// No difference is available at this point. Please use the 'DifferenceAvailable' property before attempting to get the difference. + public TFrame ToDifference() + { + if (!DifferenceAvailable) + { + throw new InvalidOperationException("No difference is available at this point. Please use the 'DifferenceAvailable' property before attempting to get the difference."); + } + + return _diffFrame; + } + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + public override void Dispose() + { + base.Dispose(); + + if (_diffFrame != null) + { + _diffFrame.Dispose(); + } + } + } +} -- cgit v1.3.1