Date:2010-08-27 11:44:10 (8 years 10 months ago)
Author:Werner Almesberger
Commit:0d537612c3df6d6f58cc93955bda9c8042e8052c
Message:Allow markup to be synchronized with other (better resolution) pair of images.

- scripts/ppmdiff/ppmdiff.c (usage, main): ppmdiff now accepts the name
of an output file as the last argument
- scripts/ppmdiff/ppmdiff.c (shadow_diff, usage, main): a second set of
images can be specified that will only be scanned for changes, without
otherwise becoming part of the merged image
- scripts/schhist2web (pngdiff): specify output name as last argument of
ppmdiff
- scripts/schhist2web: use shadow images to mark changes only visible
in regular version also in thumbnails
Files: scripts/ppmdiff/ppmdiff.c (5 diffs)
scripts/schhist2web (2 diffs)

Change Details

scripts/ppmdiff/ppmdiff.c
185185}
186186
187187
188static void shadow_diff(const uint8_t *a, const uint8_t *b, int xres, int yres)
189{
190    int x, y;
191
192    for (y = 0; y != yres; y++)
193        for (x = 0; x != xres; x++) {
194            if (memcmp(a, b, 3))
195                change(x, y);
196            a += 3;
197            b += 3;
198        }
199}
200
201
188202static void point(uint8_t *img, int x, int y, int xres, int yres)
189203{
190204    uint8_t *p;
...... 
267281    fprintf(stderr,
268282"usage: %s [-f] [-a color] [-b color] [-c color] [-d pixels]\n"
269283"%6s %*s [-m color] [-n color] [-w pixels] file_a.ppm file_b.ppm\n\n"
284"%6s %*s [file_a'.ppm file_b'.ppm] [out.ppm]\n\n"
285" file_a.ppm and file_b.ppm are two input images\n"
286" file_a'.ppm and file_b'.ppm if present, are searched for changes as well\n"
287" out.ppm output file (default: standard output)\n\n"
270288" -f generate output (and return success) even if there is no change\n"
271289" -a color color of items only in image A\n"
272290" -b color color of items only in image B\n"
...... 
279297" value from 0 to 1. E.g., 1,1,1 is white.\n\n"
280298" The images are expected to have dark colors on a perfectly white\n"
281299" background.\n"
282        , name, "", (int) strlen(name), "");
300        , name, "", (int) strlen(name), "", "", (int) strlen(name), "");
283301    exit(1);
284302}
285303
...... 
300318{
301319    int force = 0;
302320    int x = 0, y = 0;
303    uint8_t *old, *new, *d;
321    uint8_t *old, *new, *d, *a, *b;
322    char *shadow_old = NULL, *shadow_new = NULL, *out_name = NULL;
323    FILE *out;
304324    char *end;
305325    int c;
306326
...... 
337357        default:
338358            usage(*argv);
339359        }
340    if (argc-optind != 2)
360    switch (argc-optind) {
361    case 2:
362        break;
363    case 3:
364        out_name = argv[optind+2];
365        break;
366    case 5:
367        out_name = argv[optind+4];
368        /* fall through */
369    case 4:
370        shadow_old = argv[optind+2];
371        shadow_new = argv[optind+3];
372        break;
373    default:
341374        usage(*argv);
375    }
376
342377    old = load_ppm(argv[optind], &x, &y);
343378    new = load_ppm(argv[optind+1], &x, &y);
344379    d = diff(old, new, x, y);
380    if (shadow_old) {
381        a = load_ppm(shadow_old, &x, &y);
382        b = load_ppm(shadow_new, &x, &y);
383        shadow_diff(a, b, x, y);
384    }
345385    if (frame_dist)
346386        mark_areas(d, x, y);
347387    if (!areas && !force)
348388        return 1;
349    printf("P6\n%d %d\n255\n", x, y);
350    fwrite(d, 1, x*y*3, stdout);
351    if (fclose(stdout) == EOF) {
389
390    if (out_name) {
391        out = fopen(out_name, "w");
392        if (!out) {
393            perror(out_name);
394            exit(1);
395        }
396    } else {
397        out = stdout;
398    }
399    fprintf(out, "P6\n%d %d\n255\n", x, y);
400    fwrite(d, 1, x*y*3, out);
401    if (fclose(out) == EOF) {
352402        perror("fclose");
353403        exit(1);
354404    }
scripts/schhist2web
1515    pp="$1"
1616    of="$2"
1717    shift 2
18    if ! PATH=$PATH:`dirname $0`/ppmdiff ppmdiff "$@" >"$out/_tmp"; then
19    rm "$out/_tmp"
18    if ! PATH=$PATH:`dirname $0`/ppmdiff ppmdiff "$@" "$out/_tmp"; then
19    rm -f "$out/_tmp"
2020    return 1
2121    fi
2222    $pp "$out/_tmp" | pnmtopng >"$of"
23    rm -f "$out/_tmp"
23    rm "$out/_tmp"
2424}
2525
2626
...... 
128128    if [ -f "$a" -a -f "$b" ]; then
129129        s="$s<TD>"
130130        pngdiff cat "$diff" "$a" "$b" || continue
131        pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" || exit
131        pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \
132          "$a" "$b" || exit
132133    elif [ -f "$a" ]; then
133134        s="$s<TD>"
134135        pngdiff cat "$diff" -f -c 1,0,0 "$a" "$a" || exit

Archive Download the corresponding diff file



interactive