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 | |
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')
-rwxr-xr-x | gs/toolbin/bmpcmp.c | 82 | ||||
-rwxr-xr-x | gs/toolbin/htmldiff.pl | 41 |
2 files changed, 77 insertions, 46 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 */ diff --git a/gs/toolbin/htmldiff.pl b/gs/toolbin/htmldiff.pl index cd4263099..8e7b8a2ec 100755 --- a/gs/toolbin/htmldiff.pl +++ b/gs/toolbin/htmldiff.pl @@ -620,28 +620,31 @@ while (<>) unlink $tmp2; # Add the files to the HTML, converting to PNG if required. - while (stat($outdir."/out.".$images.".bmp")) + while (stat($outdir."/out.".sprintf("%05d",$images).".bmp")) { $suffix = ".bmp"; + $imstr1 = sprintf("%05d",$images); + $imstr2 = sprintf("%05d",$images+1); + $imstr3 = sprintf("%05d",$images+2); if ($pngize) { $cmd = $convertexe." "; - $cmd .= $outdir."/out.".$images.".bmp "; - $cmd .= $outdir."/out.".$images.".png"; + $cmd .= $outdir."/out.$imstr1.bmp "; + $cmd .= $outdir."/out.$imstr1.png"; $cmd2 = $convertexe." "; - $cmd2 .= $outdir."/out.".($images+1).".bmp "; - $cmd2 .= $outdir."/out.".($images+1).".png"; + $cmd2 .= $outdir."/out.$imstr2.bmp "; + $cmd2 .= $outdir."/out.$imstr2.png"; $cmd3 = $convertexe." "; - $cmd3 .= $outdir."/out.".($images+2).".bmp "; - $cmd3 .= $outdir."/out.".($images+2).".png"; + $cmd3 .= $outdir."/out.$imstr3.bmp "; + $cmd3 .= $outdir."/out.$imstr3.png"; runjobs3($cmd, $cmd2, $cmd3, $html, $iframe, "convert"); - unlink $outdir."/out.".$images.".bmp"; - unlink $outdir."/out.".($images+1).".bmp"; - unlink $outdir."/out.".($images+2).".bmp"; + unlink $outdir."/out.$imstr1.bmp"; + unlink $outdir."/out.$imstr2.bmp"; + unlink $outdir."/out.$imstr3.bmp"; $suffix = ".png"; } - $metafile = $outdir."/out.".$images.".meta"; + $metafile = $outdir."/out.$imstr.meta"; $meta{"X"} = 0; $meta{"Y"} = 0; $meta{"PW"} = 0; @@ -667,16 +670,16 @@ while (<>) $mousemove = "onmousemove=\"coord(event,this,".$images.",".$meta{"X"}.",".$meta{"Y"}.")\""; if (!$iframes) { - print $html "<TABLE><TR><TD><IMG SRC=\"$framedir/out.".$images.$suffix."\" onMouseOver=\"swap(".$images.")\" onMouseOut=\"swap(".($images+1).")\" NAME=\"compare".$images."\" BORDER=1 TITLE=\"Candidate<->Reference: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD>"; - print $html "<TD><IMG SRC=\"$framedir/out.".($images+1).$suffix."\" NAME=\"compare".($images+1)."\" BORDER=1 TITLE=\"Reference: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD>"; - print $html "<TD><IMG SRC=\"$framedir/out.".($images+2).$suffix."\" BORDER=1 TITLE=\"Diff: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD></TR>"; - print $html "<TR><TD COLSPAN=3><FORM name=\"Coord".$images."\"><LABEL for=\"X\">Page=".$page." PageSize=".$meta{"PW"}."x".$meta{"PH"}." Res=".$res." TopLeft=(".$meta{"X"}.",".$meta{"Y"}.") W=".$meta{"W"}." H=".$meta{"H"}." </LABEL><INPUT type=\"text\" name=\"X\" value=0 size=3>X<INPUT type=\"text\" name=\"Y\" value=0 size=3>Y</FORM></TD></TR></TABLE><BR>"; + print $html "<TABLE><TR><TD><IMG SRC=\"$framedir/out.$imstr1$suffix\" onMouseOver=\"swap($images)\" onMouseOut=\"swap($images)\" NAME=\"compare$images\" BORDER=1 TITLE=\"Candidate<->Reference: $file page=$page res=$res\" $mousemove></TD>"; + print $html "<TD><IMG SRC=\"$framedir/out.$imstr2$suffix\" NAME=\"compare".($images+1)."\" BORDER=1 TITLE=\"Reference: $file page=$page res=$res\" $mousemove></TD>"; + print $html "<TD><IMG SRC=\"$framedir/out.$imstr3$suffix\" BORDER=1 TITLE=\"Diff: $file page=$page res=$res\" $mousemove></TD></TR>"; + print $html "<TR><TD COLSPAN=3><FORM name=\"Coord$images\"><LABEL for=\"X\">Page=$page PageSize=".$meta{"PW"}."x".$meta{"PH"}." Res=$res TopLeft=(".$meta{"X"}.",".$meta{"Y"}.") W=".$meta{"W"}." H=".$meta{"H"}." </LABEL><INPUT type=\"text\" name=\"X\" value=0 size=3>X<INPUT type=\"text\" name=\"Y\" value=0 size=3>Y</FORM></TD></TR></TABLE><BR>"; } - print $iframe "<TABLE><TR><TD><IMG SRC=\"out.".$images.$suffix."\" onMouseOver=\"swap(".$images.")\" onMouseOut=\"swap(".($images+1).")\" NAME=\"compare".$images."\" BORDER=1 TITLE=\"Candidate<->Reference: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD>"; - print $iframe "<TD><IMG SRC=\"out.".($images+1).$suffix."\" NAME=\"compare".($images+1)."\" BORDER=1 TITLE=\"Reference: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD>"; - print $iframe "<TD><IMG SRC=\"out.".($images+2).$suffix."\" BORDER=1 TITLE=\"Diff: ".$file." page=".$page." res=".$res."\" ".$mousemove."></TD></TR>"; - print $iframe "<TR><TD COLSPAN=3><FORM name=\"Coord".$images."\"><LABEL for=\"X\">Page=".$page." PageSize=".$meta{"PW"}."x".$meta{"PH"}." Res=".$res." TopLeft=(".$meta{"X"}.",".$meta{"Y"}.") W=".$meta{"W"}." H=".$meta{"H"}." </LABEL><INPUT type=\"text\" name=\"X\" value=0 size=3>X<INPUT type=\"text\" name=\"Y\" value=0 size=3>Y</FORM></TD></TR></TABLE><BR>"; + print $iframe "<TABLE><TR><TD><IMG SRC=\"out.$imstr1$suffix\" onMouseOver=\"swap($images)\" onMouseOut=\"swap($images)\" NAME=\"compare$images\" BORDER=1 TITLE=\"Candidate<->Reference: $file page=$page res=$res\" $mousemove></TD>"; + print $iframe "<TD><IMG SRC=\"out.$imstr2$suffix\" NAME=\"compare".($images+1)."\" BORDER=1 TITLE=\"Reference: $file page=$page res=$res\" $mousemove></TD>"; + print $iframe "<TD><IMG SRC=\"out.$imstr3$suffix\" BORDER=1 TITLE=\"Diff: $file page=$page res=$res\" $mousemove></TD></TR>"; + print $iframe "<TR><TD COLSPAN=3><FORM name=\"Coord$images\"><LABEL for=\"X\">Page=$page PageSize=".$meta{"PW"}."x".$meta{"PH"}." Res=$res TopLeft=(".$meta{"X"}.",".$meta{"Y"}.") W=".$meta{"W"}." H=".$meta{"H"}." </LABEL><INPUT type=\"text\" name=\"X\" value=0 size=3>X<INPUT type=\"text\" name=\"Y\" value=0 size=3>Y</FORM></TD></TR></TABLE><BR>"; $images += 3; $diffs++; $setsthisfile++; |