From bf27e3accae0562a79467a7aecfff929aee0b15a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand?= Date: Mon, 13 Dec 2004 08:00:47 +0000 Subject: [PATCH] 24 bpp "cutZeros" support for copy filter. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@41 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfb/tightDecode.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rfb/tightDecode.h b/rfb/tightDecode.h index bc13a0d8..ac8b0a04 100644 --- a/rfb/tightDecode.h +++ b/rfb/tightDecode.h @@ -59,6 +59,7 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, #endif ) { + rdr::U8 *bytebuf = (rdr::U8*) buf; bool cutZeros = false; const rfb::PixelFormat& myFormat = handler->cp.pf(); #if BPP == 32 @@ -82,9 +83,8 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, if (comp_ctl == rfbTightFill) { 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]); + is->readBytes(bytebuf, 3); + pix = RGB24_TO_PIXEL32(bytebuf[0], bytebuf[1], bytebuf[2]); } else { pix = is->READ_PIXEL(); } @@ -142,6 +142,8 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, int bppp = BPP; if (palSize != 0) { bppp = (palSize <= 2) ? 1 : 8; + } else if (cutZeros) { + bppp = 24; } // Determine if the data should be decompressed or just copied. @@ -160,9 +162,16 @@ void TIGHT_DECODE (const Rect& r, rdr::InStream* is, if (palSize == 0) { // Truecolor data if (useGradient) { - FilterGradient(r, input, dataSize, buf, handler); + FilterGradient(r, input, dataSize, buf, handler); } else { - input->readBytes(buf, dataSize); + input->readBytes(buf, dataSize); + if (cutZeros) { + for (int p = r.height() * r.width() - 1; p >= 0; p--) { + buf[p] = RGB24_TO_PIXEL32(bytebuf[p*3], + bytebuf[p*3+1], + bytebuf[p*3+2]); + } + } } } else { int x, y, b, w; -- 2.39.5