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/FrameEncoder.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Software/Visual_Studio/Tango.RemoteDesktop/FrameEncoder.cs (limited to 'Software/Visual_Studio/Tango.RemoteDesktop/FrameEncoder.cs') diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/FrameEncoder.cs b/Software/Visual_Studio/Tango.RemoteDesktop/FrameEncoder.cs new file mode 100644 index 000000000..a1413d9c9 --- /dev/null +++ b/Software/Visual_Studio/Tango.RemoteDesktop/FrameEncoder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.RemoteDesktop +{ + /// + /// Represents a base . + /// + /// + public abstract class FrameEncoder : IFrameEncoder + { + /// + /// Gets the frame instance. + /// + public IFrame Frame { get; private set; } + + /// + /// Initializes a new instance of the class using an existing . + /// + /// The frame. + public FrameEncoder(IFrame frame) + { + Frame = frame; + } + + /// + /// Returns a stream containing the encoded frame. + /// + /// + public abstract MemoryStream ToStream(); + + /// + /// Returns a byte array containing the encoded frame. + /// + /// + public byte[] ToArray() + { + using (var ms = ToStream()) + { + return ms.ToArray(); + } + } + + /// + /// Gets the image encoder by the specified image format. + /// + /// The format. + /// + protected ImageCodecInfo GetEncoder(ImageFormat format) + { + ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); + return codecs.Single(codec => codec.FormatID == format.Guid); + } + } +} -- cgit v1.3.1