]> source.dussan.org Git - tigervnc.git/commitdiff
24 bpp "cutZeros" support for copy filter.
authorPeter Åstrand <astrand@cendio.se>
Mon, 13 Dec 2004 08:00:47 +0000 (08:00 +0000)
committerPeter Åstrand <astrand@cendio.se>
Mon, 13 Dec 2004 08:00:47 +0000 (08:00 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@41 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfb/tightDecode.h

index bc13a0d8e13adb9509f6dc2798b4a12a7301af3b..ac8b0a048e5fce355c1d9b644f64fd78e27bebac 100644 (file)
@@ -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;