diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-04 14:09:45 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-04 14:09:45 +0200 |
| commit | 565e48de649d3d14e6b82012b6aa2e3819a3c82c (patch) | |
| tree | 16e766f6bd45e62c48d6046a21841526aafaed73 /Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs | |
| parent | b0ccae10fa6025838195c42fa6c9dd72b4321579 (diff) | |
| download | Tango-565e48de649d3d14e6b82012b6aa2e3819a3c82c.tar.gz Tango-565e48de649d3d14e6b82012b6aa2e3819a3c82c.zip | |
Improved BitmapCliper.
Implemented auto throw when max differences reached.
Implemented fallback TurboJpeg encoder.
Fixed issue with UpdateMachine.xml script removing DISPENSERS before IDS_PACKS.
Added GlobalHost.Configuration.MaxIncomingWebSocketMessageSize for WebSockets support for large messages on SignalR.
Diffstat (limited to 'Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs new file mode 100644 index 000000000..b3909911f --- /dev/null +++ b/Software/Visual_Studio/Tango.RemoteDesktop/Encoders/TurboJpegEncoder.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TurboJpegWrapper; + +namespace Tango.RemoteDesktop.Encoders +{ + public class TurboJpegEncoder : FrameEncoder + { + private TJCompressor _compressor; + + /// <summary> + /// Initializes a new instance of the <see cref="TurboJpegEncoder"/> class. + /// </summary> + /// <param name="frame">The frame.</param> + public TurboJpegEncoder(IFrame frame) : base(frame) + { + _compressor = new TJCompressor(); + } + + /// <summary> + /// Returns a stream containing the encoded frame. + /// </summary> + /// <returns></returns> + public override MemoryStream ToStream() + { + return ToStream(100); + } + + /// <summary> + /// Returns a byte array containing the encoded frame. + /// </summary> + /// <returns></returns> + public override byte[] ToArray() + { + return ToArray(100); + } + + /// <summary> + /// Returns a stream containing the encoded frame with the specified quality. + /// </summary> + /// <param name="quality">The quality.</param> + /// <returns></returns> + public virtual MemoryStream ToStream(int quality) + { + return new MemoryStream(ToArray(quality)); + } + + /// <summary> + /// Returns a byte array containing the encoded frame with the specified quality. + /// </summary> + /// <param name="quality">The quality.</param> + /// <returns></returns> + public byte[] ToArray(int quality) + { + return _compressor.Compress(Frame.ToBitmap(), TJSubsamplingOption.Chrominance411, quality, TJFlags.None); + } + } +} |
