Fill compression type and palette reading now supports 24 bpp
"cutZero" pixel format.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@40 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb/tightDecode.h b/rfb/tightDecode.h
index aa4b973..bc13a0d 100644
--- a/rfb/tightDecode.h
+++ b/rfb/tightDecode.h
@@ -59,6 +59,15 @@
#endif
)
{
+ bool cutZeros = false;
+ const rfb::PixelFormat& myFormat = handler->cp.pf();
+#if BPP == 32
+ if (myFormat.depth == 24 && myFormat.redMax == 0xFF &&
+ myFormat.greenMax == 0xFF && myFormat.blueMax == 0xFF) {
+ cutZeros = true;
+ }
+#endif
+
rdr::U8 comp_ctl = is->readU8();
// Flush zlib streams if we are told by the server to do so.
@@ -71,7 +80,14 @@
// "Fill" compression type.
if (comp_ctl == rfbTightFill) {
- PIXEL_T pix = is->READ_PIXEL();
+ PIXEL_T pix;
+ if (cutZeros) {
+ rdr::U8 *fillColorBuf = (rdr::U8*)buf;
+ is->readBytes(fillColorBuf, 3);
+ pix = RGB24_TO_PIXEL32(fillColorBuf[0], fillColorBuf[1], fillColorBuf[2]);
+ } else {
+ pix = is->READ_PIXEL();
+ }
FILL_RECT(r, pix);
return;
}
@@ -99,10 +115,17 @@
switch (filterId) {
case rfbTightFilterPalette:
palSize = is->readU8() + 1;
- {
- for (int i = 0; i < palSize; i++) {
- palette[i] = is->READ_PIXEL();
- }
+ if (cutZeros) {
+ rdr::U8 *tightPalette = (rdr::U8*) palette;
+ is->readBytes(tightPalette, palSize*3);
+ for (int i = palSize - 1; i >= 0; i--) {
+ palette[i] = RGB24_TO_PIXEL32(tightPalette[i*3],
+ tightPalette[i*3+1],
+ tightPalette[i*3+2]);
+ }
+ } else {
+ for (int i = 0; i < palSize; i++)
+ palette[i] = is->READ_PIXEL();
}
break;
case rfbTightFilterGradient: