From 4b8e20d7ac09b2b9e085c735494341138adfa8ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand?= Date: Wed, 10 Aug 2005 14:13:06 +0000 Subject: [PATCH] Modifications for DETECT_SMOOTH_IMAGE: Code to prevent jpeg on images with vertical or horizontal outer-bands with the same color, such as updates in response to window moves. Without this code, window movements leaves dark "trails". git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@303 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfb/tightEncode.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/rfb/tightEncode.h b/rfb/tightEncode.h index 7479d7e2..de0d3436 100644 --- a/rfb/tightEncode.h +++ b/rfb/tightEncode.h @@ -306,6 +306,35 @@ static bool DETECT_SMOOTH_IMAGE (PIXEL_T *buf, const Rect& r) s_pjconf == NULL) return 0; + // Quick-n-dirty code to prevent jpeg on images with vertical or + // horizontal outer-bands with the same color, such as updates in + // response to window moves. Without this code, window movements + // leaves dark "trails". The pixels used for this detection are + // illustrated below: + // * * + // + // * * + // + // * * + unsigned int row2_offset = r.height() / 2; row2_offset *= r.width(); + unsigned int row3_offset = r.width() * (r.height() - 1); + PIXEL_T row1_first = buf[0]; + PIXEL_T row1_middle = buf[r.width() / 2]; + PIXEL_T row2_first = buf[row2_offset]; + PIXEL_T row2_last = buf[row2_offset + r.width() - 1]; + PIXEL_T row3_middle = buf[row3_offset + r.width() / 2]; + PIXEL_T row3_last = buf[row3_offset + r.width() - 1]; + + if ( ((row1_first == row1_middle) || (row3_middle == row3_last)) + && (row1_first != row3_middle) ) { + return 0; + } + + if ( ((row1_first == row2_first) || (row2_last == row3_last)) + && (row2_first != row2_last) ) { + return 0; + } + return 1; } #endif -- 2.39.5