Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/fuzzymatch/fuzzymatch.c

Issue 14187: Allow command-line argument to fuzzy matcher for output file. (Closed)
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* Fuzzy pixel test matching. 5 /* Fuzzy pixel test matching.
6 * 6 *
7 * This is designed to compare two layout test images (RGB 800x600) and manage 7 * This is designed to compare two layout test images (RGB 800x600) and manage
8 * to ignore the noise caused by the font renderers choosing slightly different 8 * to ignore the noise caused by the font renderers choosing slightly different
9 * pixels. 9 * pixels.
10 * 10 *
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * consideration 46 * consideration
47 */ 47 */
48 48
49 #include <unistd.h> 49 #include <unistd.h>
50 #include <stdio.h> 50 #include <stdio.h>
51 #include <leptonica/allheaders.h> 51 #include <leptonica/allheaders.h>
52 52
53 static int 53 static int
54 usage(const char *argv0) { 54 usage(const char *argv0) {
55 fprintf(stderr, "Usage: %s [--highlight] [--no-ignore-scrollbars] " 55 fprintf(stderr, "Usage: %s [--highlight] [--no-ignore-scrollbars] "
56 "[--output filename] "
56 "<input a> <input b>\n", argv0); 57 "<input a> <input b>\n", argv0);
57 return 1; 58 return 1;
58 } 59 }
59 60
60 int 61 int
61 main(int argc, char **argv) { 62 main(int argc, char **argv) {
62 if (argc < 3) 63 if (argc < 3)
63 return usage(argv[0]); 64 return usage(argv[0]);
64 65
65 char highlight = 0; 66 char highlight = 0;
66 char ignore_scrollbars = 1; 67 char ignore_scrollbars = 1;
68 char *output_filename = "highlight.png"; /* Default output filename. */
agl 2008/12/17 03:18:58 const
67 69
68 int argi = 1; 70 int argi = 1;
69 71
70 for (; argi < argc; ++argi) { 72 for (; argi < argc; ++argi) {
71 if (strcmp("--highlight", argv[argi]) == 0) { 73 if (strcmp("--highlight", argv[argi]) == 0) {
72 highlight = 1; 74 highlight = 1;
73 } else if (strcmp("--no-ignore-scrollbars", argv[argi]) == 0) { 75 } else if (strcmp("--no-ignore-scrollbars", argv[argi]) == 0) {
74 ignore_scrollbars = 0; 76 ignore_scrollbars = 0;
77 } else if (strcmp("--output", argv[argi]) == 0) {
78 output_filename = argv[++argi];
agl 2008/12/17 03:18:58 if (argi + 1 >= argc) { fprintf(stderr, "--outpu
75 } else { 79 } else {
76 break; 80 break;
77 } 81 }
78 } 82 }
79 83
80 if (argc - argi < 2) 84 if (argc - argi < 2)
81 return usage(argv[0]); 85 return usage(argv[0]);
82 86
83 PIX *a = pixRead(argv[argi]); 87 PIX *a = pixRead(argv[argi]);
84 PIX *b = pixRead(argv[argi + 1]); 88 PIX *b = pixRead(argv[argi + 1]);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 l_int32 count; 139 l_int32 count;
136 pixCountPixels(opened, &count, NULL); 140 pixCountPixels(opened, &count, NULL);
137 fprintf(stderr, "%d\n", count); 141 fprintf(stderr, "%d\n", count);
138 142
139 if (count && highlight) { 143 if (count && highlight) {
140 PIX *d1 = pixDilateBrick(NULL, opened, 7, 7); 144 PIX *d1 = pixDilateBrick(NULL, opened, 7, 7);
141 PIX *d2 = pixDilateBrick(NULL, opened, 3, 3); 145 PIX *d2 = pixDilateBrick(NULL, opened, 3, 3);
142 pixInvert(d2, d2); 146 pixInvert(d2, d2);
143 pixAnd(d1, d1, d2); 147 pixAnd(d1, d1, d2);
144 pixPaintThroughMask(a, d1, 0, 0, 0xff << 24); 148 pixPaintThroughMask(a, d1, 0, 0, 0xff << 24);
145 pixWrite("highlight.png", a, IFF_PNG); 149 pixWrite(output_filename, a, IFF_PNG);
146 } 150 }
147 151
148 return count > 0; 152 return count > 0;
149 } 153 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698