buffer-diff.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* imagediff - Compare two images
  2. *
  3. * Copyright © 2004 Richard D. Worth
  4. * Copyright © 2006 Red Hat, Inc.
  5. *
  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.
  16. *
  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.
  24. *
  25. * Authors: Richard D. Worth <richard@theworths.org>
  26. * Carl Worth <cworth@cworth.org>
  27. */
  28. #ifndef BUFFER_DIFF_H
  29. #define BUFFER_DIFF_H
  30. #include "cairo-test.h"
  31. typedef struct _buffer_diff_result {
  32. unsigned int pixels_changed;
  33. unsigned int max_diff;
  34. } buffer_diff_result_t;
  35. /* Compares two image buffers ignoring the alpha channel.
  36. *
  37. * Provides number of pixels changed and maximum single-channel
  38. * difference in result.
  39. *
  40. * Also fills in a "diff" buffer intended to visually show where the
  41. * images differ.
  42. */
  43. void
  44. buffer_diff_noalpha (const unsigned char *buf_a,
  45. const unsigned char *buf_b,
  46. unsigned char *buf_diff,
  47. int width,
  48. int height,
  49. int stride,
  50. buffer_diff_result_t *result);
  51. /* The central algorithm to compare two images, and return the differences
  52. * in the surface_diff.
  53. *
  54. * Provides number of pixels changed and maximum single-channel
  55. * difference in result.
  56. */
  57. cairo_status_t
  58. image_diff (const cairo_test_context_t *ctx,
  59. cairo_surface_t *surface_a,
  60. cairo_surface_t *surface_b,
  61. cairo_surface_t *surface_diff,
  62. buffer_diff_result_t *result);
  63. cairo_bool_t
  64. image_diff_is_failure (const buffer_diff_result_t *result,
  65. unsigned int tolerance);
  66. #endif