From fd21d651ed97e25c739c204d7a8dc611c723ba2d Mon Sep 17 00:00:00 2001 From: Peter Åstrand Date: Sun, 12 Dec 2004 13:24:14 +0000 Subject: 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 --- rfb/tightDecode.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/rfb/tightDecode.h b/rfb/tightDecode.h index aa4b973e..bc13a0d8 100644 --- a/rfb/tightDecode.h +++ b/rfb/tightDecode.h @@ -59,6 +59,15 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, #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 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, // "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 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, 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: -- cgit v1.2.3