diff options
author | Robin Watts <robin.watts@artifex.com> | 2010-01-27 19:08:07 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2010-01-27 19:08:07 +0000 |
commit | 4d710b61134c16a7115b32ed85c6c08df1efceaa (patch) | |
tree | 6680b3bb0c7ffb951f2c798b52e56234e8b71fa6 /gs/toolbin/bmpcmp.c | |
parent | b7dadc216c8c51de0b34458ceab132410e643557 (diff) |
Updated version of bmpcmp.c to support maxdiffs parameter. Also, bitmaps
are output numbered 00000, 00001, etc rather than 0, 1, etc to tidy
directory listings.
Updated htmldiff.pl file to cope with the rejigged number formats.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@10651 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/toolbin/bmpcmp.c')
-rwxr-xr-x | gs/toolbin/bmpcmp.c | 82 |
1 files changed, 55 insertions, 27 deletions
diff --git a/gs/toolbin/bmpcmp.c b/gs/toolbin/bmpcmp.c index ce631501f..28fc2b234 100755 --- a/gs/toolbin/bmpcmp.c +++ b/gs/toolbin/bmpcmp.c @@ -64,7 +64,7 @@ static unsigned char *bmp_load_sub(unsigned char *bmp, int *height_ret, int *span, int *bpp, - int image_offset,
+ int image_offset, int filelen) { int size, src_bpp, dst_bpp, comp, xdpi, ydpi, i, x, y, cols; @@ -160,7 +160,7 @@ static unsigned char *bmp_load_sub(unsigned char *bmp, word_width = width * (src_bpp>>3); word_width += 3; word_width &= ~3; -
+ dst = Malloc(word_width * height); /* Now we do the actual conversion */ @@ -857,20 +857,20 @@ static void diff_bmp(unsigned char *bmp, } } } -
-static void save_meta(BBox *bbox, char *str, int w, int h, int page)
-{
- FILE *file;
-
- file = fopen(str, "wb");
- if (file == NULL)
- return;
-
- fprintf(file, "PW=%d\nPH=%d\nX=%d\nY=%d\nW=%d\nH=%d\nPAGE=%d\n",
- w, h, bbox->xmin, h-bbox->ymax,
- bbox->xmax-bbox->xmin, bbox->ymax-bbox->ymin, page);
- fclose(file);
-}
+ +static void save_meta(BBox *bbox, char *str, int w, int h, int page) +{ + FILE *file; + + file = fopen(str, "wb"); + if (file == NULL) + return; + + fprintf(file, "PW=%d\nPH=%d\nX=%d\nY=%d\nW=%d\nH=%d\nPAGE=%d\n", + w, h, bbox->xmin, h-bbox->ymax, + bbox->xmax-bbox->xmin, bbox->ymax-bbox->ymin, page); + fclose(file); +} static void save_bmp(unsigned char *data, BBox *bbox, @@ -952,22 +952,25 @@ int main(int argc, char *argv[]) int nx, ny, n; int basenum; int imagecount; + int maxdiffs; unsigned char *bmp; unsigned char *bmp2; BBox bbox, bbox2; BBox *boxlist; char str1[256]; char str2[256]; - char str3[256];
- char str4[256];
+ char str3[256]; + char str4[256]; ImageReader image1, image2; if (argc < 4) { - fprintf(stderr, "Syntax: bmpcmp <file1> <file2> <outfile_root> [<basenum>]\n"); + fprintf(stderr, "Syntax: bmpcmp <file1> <file2> <outfile_root> [<basenum>] [<maxdiffs>]\n"); fprintf(stderr, " <file1> and <file2> can be bmp, ppm, pgm or pbm files.\n"); - fprintf(stderr, " This will produce a series of <outfile_root>.<number>.bmp files");
- fprintf(stderr, " and a series of <outfile_root>.<number>.meta files.\n");
+ fprintf(stderr, " This will produce a series of <outfile_root>.<number>.bmp files\n"); + fprintf(stderr, " and a series of <outfile_root>.<number>.meta files.\n"); + fprintf(stderr, " The maxdiffs value determines the maximum number of bitmaps\n"); + fprintf(stderr, " produced - 0 (or unsupplied) is taken to mean unlimited.\n"); exit(EXIT_FAILURE); } @@ -979,6 +982,15 @@ int main(int argc, char *argv[]) { basenum = 0; } + + if (argc > 5) + { + maxdiffs = atoi(argv[5]); + } + else + { + maxdiffs = 0; + } image_open(&image1, argv[1]); image_open(&image2, argv[2]); @@ -1092,12 +1104,12 @@ int main(int argc, char *argv[]) rediff(bmp, bmp2, s, bpp, boxlist); if (!BBox_valid(boxlist)) continue; - sprintf(str1, "%s.%d.bmp", argv[3], n);
- sprintf(str2, "%s.%d.bmp", argv[3], n+1); + sprintf(str1, "%s.%05d.bmp", argv[3], n); + sprintf(str2, "%s.%05d.bmp", argv[3], n+1); save_bmp(bmp, boxlist, s, bpp, str1); - save_bmp(bmp2, boxlist, s, bpp, str2);
- sprintf(str4, "%s.%d.meta", argv[3], n);
- save_meta(boxlist, str4, w, h, imagecount-1); + save_bmp(bmp2, boxlist, s, bpp, str2); + sprintf(str4, "%s.%05d.meta", argv[3], n); + save_meta(boxlist, str4, w, h, imagecount); n += 3; } } @@ -1111,12 +1123,28 @@ int main(int argc, char *argv[]) boxlist++; if (!BBox_valid(boxlist)) continue; - sprintf(str3, "%s.%d.bmp", argv[3], n+2); + sprintf(str3, "%s.%05d.bmp", argv[3], n+2); save_bmp(bmp, boxlist, s, bpp, str3); n += 3; } } basenum = n; + + boxlist -= nx*ny; + free(boxlist); + free(bmp); + free(bmp2); + + /* If there is a maximum set */ + if (maxdiffs > 0) + { + /* Check to see we haven't exceeded it */ + maxdiffs--; + if (maxdiffs == 0) + { + break; + } + } } /* If one loaded, and the other didn't - that's an error */ |