[cairo-commit] test/buffer-diff.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Aug 30 10:19:07 PDT 2006


 test/buffer-diff.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

New commits:
diff-tree a5f068e10d72c20a55d20ca9f79508361d13fb80 (from 3252ad5ca630fe292babc061c01b8759ef49cde4)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 30 13:17:08 2006 -0400

    [test] Add 128 to any diff component such that differences are visible

diff --git a/test/buffer-diff.c b/test/buffer-diff.c
index 45942c4..ade0cc8 100644
--- a/test/buffer-diff.c
+++ b/test/buffer-diff.c
@@ -91,13 +91,15 @@ buffer_diff_core (unsigned char *_buf_a,
 
 		/* calculate a difference value for all 4 channels */
 		for (channel = 0; channel < 4; channel++) {
-		    unsigned char value_a = (row_a[x] >> (channel*8));
-		    unsigned char value_b = (row_b[x] >> (channel*8));
+		    int value_a = (row_a[x] >> (channel*8)) & 0xff;
+		    int value_b = (row_b[x] >> (channel*8)) & 0xff;
 		    unsigned int diff;
 		    diff = abs (value_a - value_b);
-		    diff *= 4; /* emphasize */
+		    diff *= 4;  /* emphasize */
+		    if (diff)
+		        diff += 128; /* make sure it's visible */
 		    if (diff > 255)
-		      diff = 255;
+		        diff = 255;
 		    diff_pixel |= diff << (channel*8);
 		}
 


More information about the cairo-commit mailing list