[gs-cvs] gs/toolbin/tests
Igor Melichev
igor at ghostscript.com
Sun Nov 7 12:00:49 PST 2004
Update of /cvs/ghostscript/gs/toolbin/tests
In directory casper2:/tmp/cvs-serv18835/gs/toolbin/tests
Modified Files:
Tag: GS_8_1X
fuzzy.c
Log Message:
fuzzy.c : Propagate last changes from HEAD.
Index: fuzzy.c
===================================================================
RCS file: /cvs/ghostscript/gs/toolbin/tests/fuzzy.c,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -d -r1.9.2.2 -r1.9.2.3
--- fuzzy.c 12 May 2004 04:06:00 -0000 1.9.2.2
+++ fuzzy.c 7 Nov 2004 20:00:47 -0000 1.9.2.3
@@ -25,7 +25,8 @@
struct _Image {
int (*close) (Image *self);
int (*get_scan_line) (Image *self, uchar *buf);
- int (*seek) (Image *self, int y);
+ int (*seek) (Image *self, int y);
+ int (*feof_) (Image *self);
int width;
int height;
int maxval;
@@ -161,6 +162,14 @@
return pnm;
}
+static int
+image_pnm_feof (Image *self)
+{
+ ImagePnm *pnm = (ImagePnm *)self;
+
+ return feof (pnm->f);
+}
+
static void
write_int16(short v, FILE *f)
{
@@ -321,6 +330,7 @@
image->super.close = image_pnm_close;
image->super.get_scan_line = image_pnm_get_scan_line;
image->super.seek = no_seek;
+ image->super.feof_ = image_pnm_feof;
image->super.width = width;
image->super.height = height;
image->super.maxval = maxval;
@@ -553,13 +563,13 @@
int
main (int argc, char **argv)
{
- Image *image1, *image2;
+ Image *image1, *image2;
ImagePnm *image_out = NULL;
FuzzyParams fparams;
FuzzyReport freport;
const char *fn[3] = {0, 0, 0};
int fn_idx = 0;
- int i;
+ int i, page = 1, rcode = 0;
fparams.tolerance = 2;
fparams.window_size = 3;
@@ -620,20 +630,34 @@
(!strcmp(fn[2]+ strlen(fn[2]) - 4, ".bmp") ? create_bmp_image
: create_pnm_image)
(image1, fn[2]);
-
- fuzzy_diff_images (image1, image2, &fparams, &freport, image_out);
-
- if (image_out)
- image_pnm_close (&image_out->super);
-
-
- if (freport.n_outof_window > 0)
- {
- printf ("%s: %d different, %d out of tolerance, %d out of window\n",
- fn[0], freport.n_diff, freport.n_outof_tolerance,
- freport.n_outof_window);
- return 1;
+
+ while (!image1->feof_(image1) || !image2->feof_(image2))
+ {
+ if (image1->feof_(image1))
+ {
+ printf ("Extra data (maybe pages) in the image file 2.");
+ return 1;
}
- else
- return 0;
+ if (image2->feof_(image2))
+ {
+ printf ("Extra data (maybe pages) in the image file 1.");
+ return 1;
+ }
+ fuzzy_diff_images (image1, image2, &fparams, &freport, image_out);
+ if (image_out)
+ image_pnm_close (&image_out->super);
+ image_out = NULL;
+ if (freport.n_diff > 0)
+ {
+ printf ("%s: page %d: %d different, %d out of tolerance, %d out of window\n",
+ fn[0], page, freport.n_diff, freport.n_outof_tolerance,
+ freport.n_outof_window);
+ rcode = max(rcode, 1);
+ }
+ if (freport.n_outof_window > 0)
+ rcode = max(rcode, 2);
+ page++;
+ }
+
+ return rcode;
}
More information about the gs-cvs
mailing list