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); } } }