NDEVR
API Documentation
TightDecoder.h
1#pragma once
2#ifndef TIGHT_VNC
3#define TIGHT_VNC
4#include <QRect>
5#include <QImage>
6struct z_stream_s;
7class QTcpSocket;
8namespace NDEVR
9{
10 struct PixelFormat;
15 {
16 public:
19 : underlying(0)
20 , zs(NULL)
21 {
22 init();
23 }
24
27 {
28 deinit();
29 }
30
34 void setUnderlying(const uint01* is, size_t bytesIn_)
35 {
36 underlying.addAll(is, cast<uint04>(bytesIn_));
37 }
38
41 {
42 setUnderlying(NULL, 0);
43 }
44
46 void reset()
47 {
48 underlying.clear();
49 deinit();
50 init();
51 }
52
54 void init();
55
57 void deinit();
62 bool readBytes(uint01* data, size_t length);
63 private:
64 Buffer<uint01> underlying;
65 z_stream_s* zs;
66
67 };
68
71 class TightDecoder
72 {
73
74 public:
75 TightDecoder()
76 {
77
78 }
79 virtual ~TightDecoder()
80 {
81
82 }
87 static void ReadAll(QTcpSocket* is, uint01* os, uint04 size);
93 static void CopyToBuffer(uint01*& buffer, void* value, uint04 size, uint04& total_size)
94 {
95 memcpy(buffer, value, size);
96 buffer += size;
97 total_size += size;
98 }
99
105 static bool ReadRect(const QRect& r, QTcpSocket* is, const PixelFormat& pf, QImage& pb);
106
107
108 private:
109 static uint04 ReadCompact(QTcpSocket* is);
110 static void FilterGradient(const uint01* inbuf, const PixelFormat& pf, uint04* outbuf, int stride, const QRect& r);
111
112 static void FilterPalette(const uint01* palette, uint04 palSize, const uint01* inbuf, uint01* outbuf, int stride, const QRect& r, uint04 pixel_size);
113
114 private:
115 static ZlibInStream zis[4];
116 };
117}
118#endif
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
static void CopyToBuffer(uint01 *&buffer, void *value, uint04 size, uint04 &total_size)
Copies a value into a byte buffer and advances the pointer.
static bool ReadRect(const QRect &r, QTcpSocket *is, const PixelFormat &pf, QImage &pb)
Decodes a Tight-encoded rectangle from the VNC stream into an image.
static void ReadAll(QTcpSocket *is, uint01 *os, uint04 size)
Reads exactly the requested number of bytes from a TCP socket.
A zlib decompression stream wrapper used by TightDecoder to inflate compressed VNC data.
void deinit()
Releases the zlib inflate state.
~ZlibInStream()
Destructor.
bool readBytes(uint01 *data, size_t length)
Reads and decompresses bytes from the stream.
void init()
Initializes the zlib inflate state.
void reset()
Resets the stream, clearing buffered data and reinitializing zlib.
ZlibInStream()
Constructs and initializes the zlib stream.
void flushUnderlying()
Flushes any remaining data in the underlying buffer.
void setUnderlying(const uint01 *is, size_t bytesIn_)
Appends compressed data to the internal buffer.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
Describes the pixel format of a VNC remote framebuffer, including color depth, endianness,...