|
47 | 47 | // ------------------------------------------------------------------------
|
48 | 48 |
|
49 | 49 | bool g_verbose = false;
|
| 50 | +long g_channel_tolerance = 0; |
50 | 51 |
|
51 | 52 | // Resolution to use for rasterization, in DPI
|
52 | 53 | #define RESOLUTION 300
|
@@ -189,7 +190,11 @@ cairo_surface_t *diff_images(cairo_surface_t *s1, cairo_surface_t *s2,
|
189 | 190 | unsigned char cg2 = *(data2 + x + 1);
|
190 | 191 | unsigned char cb2 = *(data2 + x + 2);
|
191 | 192 |
|
192 |
| - if ( cr1 != cr2 || cg1 != cg2 || cb1 != cb2 ) |
| 193 | + |
| 194 | + if ( cr1 > (cr2+g_channel_tolerance) || cr2 < (cr2-g_channel_tolerance) |
| 195 | + || cg1 > (cg2+g_channel_tolerance) || cg2 < (cg2-g_channel_tolerance) |
| 196 | + || cb1 > (cb2+g_channel_tolerance) || cb2 < (cb2-g_channel_tolerance) |
| 197 | + ) |
193 | 198 | {
|
194 | 199 | changes = true;
|
195 | 200 | if ( thumbnail )
|
@@ -863,6 +868,10 @@ int main(int argc, char *argv[])
|
863 | 868 | NULL, wxT28("output-diff"), wxT28("output differences to given PDF file"),
|
864 | 869 | wxCMD_LINE_VAL_STRING },
|
865 | 870 |
|
| 871 | + { wxCMD_LINE_OPTION, |
| 872 | + NULL, wxT28("channel-tolerance"), wxT28("consider channel values to be equal if within specified tolerance"), |
| 873 | + wxCMD_LINE_VAL_NUMBER }, |
| 874 | + |
866 | 875 | { wxCMD_LINE_SWITCH,
|
867 | 876 | NULL, wxT28("view"), wxT28("view the differences in a window") },
|
868 | 877 |
|
@@ -919,6 +928,15 @@ int main(int argc, char *argv[])
|
919 | 928 | return 3;
|
920 | 929 | }
|
921 | 930 |
|
| 931 | + if ( parser.Found(wxT("channel-tolerance"), &g_channel_tolerance) ) |
| 932 | + { |
| 933 | + if (g_channel_tolerance < 0 || g_channel_tolerance > 255) { |
| 934 | + fprintf(stderr, "Invalid channel-tolerance: %ld. Valid range is 0(default, exact matching)-255\n", g_channel_tolerance); |
| 935 | + return 2; |
| 936 | + } |
| 937 | + } |
| 938 | + |
| 939 | + |
922 | 940 | int retval = 0;
|
923 | 941 |
|
924 | 942 | wxString pdf_file;
|
|
0 commit comments