diff options
author | DRC <dcommander@users.sourceforge.net> | 2011-08-19 04:57:18 +0000 |
---|---|---|
committer | DRC <dcommander@users.sourceforge.net> | 2011-08-19 04:57:18 +0000 |
commit | b4a8323c25f6440c3051f98439d8246c3e170ce4 (patch) | |
tree | 5332faf29b104f1ab5bf5c8eca4b9d8fbd065511 /common/rfb/TightEncoder.cxx | |
parent | 887c5fd86e052f31a4cd039b5634a16af7c8e780 (diff) | |
download | tigervnc-b4a8323c25f6440c3051f98439d8246c3e170ce4.tar.gz tigervnc-b4a8323c25f6440c3051f98439d8246c3e170ce4.zip |
Add support for TurboVNC pseudo-encodings and Grayscale JPEG compression so that, when a TurboVNC viewer is connected, the TigerVNC Server will behave exactly like the TurboVNC Server.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4641 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/TightEncoder.cxx')
-rw-r--r-- | common/rfb/TightEncoder.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx index e35bad62..b7ef2236 100644 --- a/common/rfb/TightEncoder.cxx +++ b/common/rfb/TightEncoder.cxx @@ -117,9 +117,21 @@ void TightEncoder::setCompressLevel(int level) void TightEncoder::setQualityLevel(int level) { if (level >= 0 && level <= 9) { - pjconf = &conf[level]; + jpegQuality = conf[level].jpegQuality; + jpegSubsampling = conf[level].jpegSubsampling; } else { - pjconf = NULL; + jpegQuality = -1; + jpegSubsampling = SUBSAMP_UNDEFINED; + } +} + +void TightEncoder::setFineQualityLevel(int quality, JPEG_SUBSAMP subsampling) +{ + if (quality >= 1 && quality <= 100) { + jpegQuality = quality; + } + if (subsampling >= SUBSAMP_NONE && subsampling <= SUBSAMP_GRAY) { + jpegSubsampling = subsampling; } } @@ -333,6 +345,14 @@ bool TightEncoder::writeRect(const Rect& _r, TransImageGetter* _ig, sr.setXYWH(dx, dy, dw, dh); if (checkSolidTile(sr, &colorValue, false)) { + if (jpegSubsampling == SUBSAMP_GRAY && jpegQuality != -1) { + Colour rgb; + serverpf.rgbFromPixel(colorValue, NULL, &rgb); + rdr::U32 lum = ((257 * rgb.r) + (504 * rgb.g) + (98 * rgb.b) + + 16500) / 1000; + colorValue = lum + (lum << 8) + (lum << 16); + } + // Get dimensions of solid-color area. sr.setXYWH(dx, dy, r.br.x - dx, r.br.y - dy); findBestSolidArea(sr, colorValue, bestr); |