1 /* imagediff - Compare two images
3 * Copyright © 2004 Richard D. Worth
4 * Copyright © 2006 Red Hat, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software
7 * and its documentation for any purpose is hereby granted without
8 * fee, provided that the above copyright notice appear in all copies
9 * and that both that copyright notice and this permission notice
10 * appear in supporting documentation, and that the name of the authors
11 * not be used in advertising or publicity pertaining to distribution
12 * of the software without specific, written prior permission.
13 * The authors make no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without express
15 * or implied warranty.
17 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
19 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * Authors: Richard D. Worth <richard@theworths.org>
26 * Carl Worth <cworth@cworth.org>
32 #include "cairo-test.h"
34 typedef struct _buffer_diff_result {
35 unsigned int pixels_changed;
36 unsigned int max_diff;
37 } buffer_diff_result_t;
39 /* Compares two image buffers ignoring the alpha channel.
41 * Provides number of pixels changed and maximum single-channel
42 * difference in result.
44 * Also fills in a "diff" buffer intended to visually show where the
48 buffer_diff_noalpha (const unsigned char *buf_a,
49 const unsigned char *buf_b,
50 unsigned char *buf_diff,
54 buffer_diff_result_t *result);
56 /* The central algorithm to compare two images, and return the differences
57 * in the surface_diff.
59 * Provides number of pixels changed and maximum single-channel
60 * difference in result.
63 image_diff (const cairo_test_context_t *ctx,
64 cairo_surface_t *surface_a,
65 cairo_surface_t *surface_b,
66 cairo_surface_t *surface_diff,
67 buffer_diff_result_t *result);
70 image_diff_is_failure (const buffer_diff_result_t *result,
71 unsigned int tolerance);