summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2008-10-26 16:16:09 +0000
committerRoger Leigh <rleigh@debian.org>2008-10-26 16:16:09 +0000
commit3950c83c2919fe59dbf442c0d4859778fadd0e8d (patch)
treea94521b94f4a256b5b6d7f004f4afd5f9aae5db0 /test
parent97aedb05b271e9486f51eac1aee64fce92da64ca (diff)
Imported Upstream version 4.3.99+cvs20060521
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am3
-rw-r--r--test/Makefile.in7
-rw-r--r--test/escp2-weavetest.c11
-rwxr-xr-xtest/parse-escp2290
-rwxr-xr-xtest/run-testdither72
-rwxr-xr-xtest/run-weavetest12
-rw-r--r--test/testdither.c234
-rw-r--r--test/unprint.c6
8 files changed, 353 insertions, 282 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index a4a1d48..150e2c6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.44 2005/11/21 11:16:23 rleigh Exp $
+## $Id: Makefile.am,v 1.46 2006/05/12 01:10:19 rlk Exp $
## Copyright (C) 2000 Roger Leigh
##
## This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,6 @@ LOCAL_CPPFLAGS = -I$(top_srcdir)/src/main $(GUTENPRINT_CFLAGS)
TESTS = curve run-testdither run-weavetest
-
## Programs
if BUILD_TEST
diff --git a/test/Makefile.in b/test/Makefile.in
index 31a2f89..ddbb656 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -16,6 +16,9 @@
# Variables
+#export STP_MODULE_PATH = $(top_builddir)/src/main/.libs:$(top_builddir)/src/main
+#export STP_DATA_PATH = $(top_srcdir)/src/main
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@@ -284,6 +287,7 @@ USE_NLS = @USE_NLS@
USE_NLS_FALSE = @USE_NLS_FALSE@
USE_NLS_TRUE = @USE_NLS_TRUE@
VERSION = @VERSION@
+WHICH_PPDS = @WHICH_PPDS@
XGETTEXT = @XGETTEXT@
YACC = @YACC@
ac_ct_AR = @ac_ct_AR@
@@ -695,9 +699,6 @@ uninstall-am: uninstall-info-am
@SET_MAKE@
-export STP_MODULE_PATH = $(top_builddir)/src/main/.libs:$(top_builddir)/src/main
-export STP_DATA_PATH = $(top_srcdir)/src/main
-
# Rules
$(top_builddir)/src/main/libgutenprint.la:
diff --git a/test/escp2-weavetest.c b/test/escp2-weavetest.c
index 48ebea8..f63b956 100644
--- a/test/escp2-weavetest.c
+++ b/test/escp2-weavetest.c
@@ -1,5 +1,5 @@
/*
- * "$Id: escp2-weavetest.c,v 1.36 2005/05/27 02:11:51 rlk Exp $"
+ * "$Id: escp2-weavetest.c,v 1.37 2006/05/05 23:23:40 rlk Exp $"
*
* Print plug-in EPSON ESC/P2 driver for the GIMP.
*
@@ -379,6 +379,9 @@ run_weavetest_from_stdin(void)
int total_cases = 0;
int failures = 0;
char linebuf[4096];
+ const char *spinner = "/-\\|";
+ int rotor = 0;
+ int do_spinner = isatty(fileno(stdout));
while (fgets(linebuf, 4096, stdin))
{
int retval;
@@ -409,6 +412,12 @@ run_weavetest_from_stdin(void)
}
if (previous_separation != physsep)
printf(".");
+ if (do_spinner)
+ {
+ putchar((int) (spinner[rotor++]));
+ putchar((int) '\b');
+ rotor &= 3;
+ }
previous_strategy = strategy;
previous_jets = physjets;
previous_separation = physsep;
diff --git a/test/parse-escp2 b/test/parse-escp2
index 39ecf46..0a0d45c 100755
--- a/test/parse-escp2
+++ b/test/parse-escp2
@@ -1,12 +1,18 @@
#!/usr/bin/perl
-require("getopts.pl");
+use Getopt::Std;
+use strict;
-do Getopts('v');
+getopts('v');
-while (<>) {
- $stuff .= $_;
-}
+use vars qw($atend
+ $stuff
+ $opt_v
+ $curpos
+ $esc
+ %seqtable);
+
+$atend = 0;
%seqtable = ( "@", 0,
"(R", "REMOTE",
@@ -23,24 +29,61 @@ while (<>) {
$esc = "\033";
-$skipcount = 0;
$curpos = 0;
-$verbose = $opt_v;
-sub do_remote_command {
+sub get_stuff($) {
+ my ($where) = @_;
+ my ($end) = length $stuff;
+ if ($curpos == 0 && $end == 0) {
+ $stuff = <>; # Need to do this once to "activate" ARGV
+ $end = length $stuff;
+ }
+ my ($old_end) = length $stuff;
+ my ($tmp);
+ my ($bytes_to_read) = 4096;
+ if ($where - $end > $bytes_to_read) {
+ $bytes_to_read = $where - $end;
+ }
+ while ($end < $where) {
+ my $foo = read ARGV, $tmp, $bytes_to_read;
+# print STDERR length $tmp, " ", length $stuff, " $curpos $where $bytes_to_read $foo $!", "\n";
+ $stuff .= $tmp;
+# print STDERR length $tmp, " ", length $stuff, " $curpos $where $bytes_to_read $foo $!", "\n\n";
+ $end = length $stuff;
+ if ($old_end == $end) {
+ $atend = 1;
+ return 0;
+ } else {
+ $bytes_to_read -= $end - $old_end;
+ $old_end = $end;
+ }
+ }
+ return 1;
+}
+
+sub increment_curpos($) {
+ my ($curpos_increment) = @_;
+ substr($stuff, 0, $curpos_increment) = "";
+ $curpos += $curpos_increment;
+}
+
+sub do_remote_command() {
print "\n";
printf "%08x ", $curpos;
print "1b ( R ";
- substr($stuff, 0, 3) = "";
- $curpos += 3;
- $lchar = substr($stuff, 0, 1);
- $nlchar = unpack("C", $lchar);
- $hchar = substr($stuff, 1, 1);
- $nhchar = unpack("C", $hchar);
+ increment_curpos(3);
+ get_stuff(2);
+ my $lchar = substr($stuff, 0, 1);
+ my $nlchar = unpack("C", $lchar);
+ my $hchar = substr($stuff, 1, 1);
+ my $nhchar = unpack("C", $hchar);
printf "%02x %02x ", $nlchar, $nhchar;
- $skipchars = ($nhchar * 256) + $nlchar;
- substr($stuff, 0, 2) = "";
- $curpos += 2;
+ my $skipchars = ($nhchar * 256) + $nlchar;
+ increment_curpos(2);
+ my $i;
+ my $char;
+ my $nchar;
+ get_stuff($skipchars);
for ($i = 0; $i < $skipchars; $i++) {
$char = substr($stuff, $i, 1);
$nchar = unpack("C", $char);
@@ -50,15 +93,15 @@ sub do_remote_command {
printf "%02x ", $nchar;
}
}
- substr($stuff, 0, $skipchars) = "";
- $curpos += $skipchars;
- while (substr($stuff, 0, 2) =~ /[A-Z0-9][A-Z0-9]/) {
+ increment_curpos($skipchars);
+ while (get_stuff(2) &&
+ substr($stuff, 0, 2) =~ /[A-Z0-9][A-Z0-9]/) {
print "\n";
printf "%08x ", $curpos;
my ($cmd) = substr($stuff, 0, 2);
- print substr($stuff, 0, 2);
- substr($stuff, 0, 2) = "";
- $curpos += 2;
+ print $cmd;
+ increment_curpos(2);
+ get_stuff(2);
$lchar = substr($stuff, 0, 1);
$nlchar = unpack("C", $lchar);
$hchar = substr($stuff, 1, 1);
@@ -69,21 +112,25 @@ sub do_remote_command {
$skipchars = ($nhchar * 256) + $nlchar;
}
printf "%02x %02x ", $nlchar, $nhchar;
- substr($stuff, 0, 2) = "";
- $curpos += 2;
+ increment_curpos(2);
+ get_stuff($skipchars);
for ($i = 0; $i < $skipchars; $i++) {
printf "%02x ", unpack("C", substr($stuff, $i, 1));
}
- substr($stuff, 0, $skipchars) = "";
- $curpos += $skipchars;
+ increment_curpos($skipchars);
}
}
-sub do_special_command {
+sub print_prefix_bytes($) {
+ my ($bytes_to_print) = @_;
print "\n";
printf "%08x ", $curpos;
print "1b ";
- for ($i = 1; $i < 8; $i++) {
+ my $i;
+ my $char;
+ my $nchar;
+ get_stuff($bytes_to_print);
+ for ($i = 1; $i < $bytes_to_print; $i++) {
$char = substr($stuff, $i, 1);
$nchar = unpack("C", $char);
if ($i < 2 && $nchar >= 32 && $nchar < 127) {
@@ -92,130 +139,48 @@ sub do_special_command {
printf "%02x ", unpack("C", $char);
}
}
- $comptype = unpack("C", substr($stuff, 2, 1));
- $dots = unpack("v", substr($stuff, 6, 2));
- $something = unpack("C", substr($stuff, 5, 1));
- print " ($dots, $something) ";
- $savedots = $dots;
- $dots *= $something;
- $curpos += 8;
- substr($stuff, 0, 8) = "";
- if ($comptype == 0) {
- $bytes = ($dots + 7) / 8;
- if ($verbose) {
- for ($k = 0; $k < $bytes; $k++) {
- $char = substr($stuff, $k, 1);
- printf "%02x", unpack("C", $char);
- }
- }
- $curpos += $bytes;
- substr($stuff, 0, $bytes) = "";
- } elsif ($comptype == 1) {
- while ($something > 0) {
- $dots = $savedots;
- while ($dots > 0) {
- $counter = unpack("C", substr($stuff, 0, 1));
- $curpos++;
- substr($stuff, 0, 1) = "";
- if ($counter <= 127) {
- $counter++;
- if ($verbose) {
- for ($k = 0; $k < $counter; $k++) {
- $char = substr($stuff, $k, 1);
- printf "%02x ", unpack("C", $char);
- }
- }
- $curpos += $counter;
- substr($stuff, 0, $counter) = "";
- $dots -= 8 * $counter;
- } else {
- $counter = 257 - $counter;
- if ($verbose) {
- for ($k = 0; $k < $counter; $k++) {
- $char = substr($stuff, 0, 1);
- printf "%02x ", unpack("C", $char);
- }
- }
- $curpos++;
- substr($stuff, 0, 1) = "";
- $dots -= 8 * $counter;
- }
- }
- $something--;
- }
- } else {
- print "\nUnknown compression type $comptype!\n";
- }
}
-sub do_special1_command {
- print "\n";
- printf "%08x ", $curpos;
- print "1b ";
- for ($i = 1; $i < 9; $i++) {
- $char = substr($stuff, $i, 1);
- $nchar = unpack("C", $char);
- if ($i < 2 && $nchar >= 32 && $nchar < 127) {
- print " $char ";
- } else {
- printf "%02x ", unpack("C", $char);
- }
- }
- $comptype = unpack("C", substr($stuff, 3, 1));
- $bitsperpixel = unpack("C", substr($stuff, 4, 1));
- $dots = unpack("v", substr($stuff, 5, 2));
- $something = unpack("v", substr($stuff, 7, 2));
- print " ($dots, $something, $bitsperpixel) ";
+sub print_output_data($$$$$) {
+ my ($comptype, $bitsperpixel, $dots, $rows, $dot_scale) = @_;
+ my $counter;
+ my $fchar;
+ print " ($dots, $rows, $bitsperpixel) ";
$dots *= 8;
- $savedots = $dots;
- $dots *= $something;
- $curpos += 9;
- substr($stuff, 0, 9) = "";
+ $dots /= $dot_scale;
+ my $savedots = $dots;
if ($comptype == 0) {
- $bytes = ($dots + 7) / 8;
- if ($verbose) {
- for ($k = 0; $k < $bytes; $k++) {
- $char = substr($stuff, $k, 1);
- printf "%02x", unpack("C", $char);
- }
+ if ($opt_v) {
+ get_stuff($dots);
+ printf "%*v02x ", " ", substr($stuff, 0, $dots);
}
- $curpos += $bytes;
- substr($stuff, 0, $bytes) = "";
+ increment_curpos($dots);
} elsif ($comptype == 1) {
- while ($something > 0) {
+ while ($rows-- > 0) {
$dots = $savedots;
while ($dots > 0) {
- $counter = unpack("C", substr($stuff, 0, 1));
- $curpos++;
- substr($stuff, 0, 1) = "";
+ get_stuff(1);
+ $counter = ord(substr($stuff, 0, 1));
+ increment_curpos(1);
if ($counter <= 127) {
$counter++;
-# printf(" (%d) ", $counter);
- if ($verbose) {
- for ($k = 0; $k < $counter; $k++) {
- $char = substr($stuff, $k, 1);
- printf "%02x ", unpack("C", $char);
- }
+ get_stuff($counter);
+ if ($opt_v) {
+ printf "%*v02x ", " ", substr($stuff, 0, $counter);
}
- $curpos += $counter;
- substr($stuff, 0, $counter) = "";
- $dots -= 8 * $counter;
+ increment_curpos($counter);
} else {
$counter = 257 - $counter;
-# printf(" (%d %d) ", $counter, unpack("C", substr($stuff, 0, 1)));
- if ($verbose) {
- $char = substr($stuff, 0, 1);
- for ($k = 0; $k < $counter; $k++) {
- printf "%02x ", unpack("C", $char);
- }
+ get_stuff(1);
+ if ($opt_v) {
+ $fchar = sprintf "%v02x ", substr($stuff, 0, 1);
+ map { print $fchar } (0..$counter - 1);
}
- $curpos++;
- substr($stuff, 0, 1) = "";
- $dots -= 8 * $counter;
+ increment_curpos(1);
}
+ $dots -= $counter * 8;
}
- $something--;
- if ($something > 0 && $verbose) {
+ if ($rows > 0 && $opt_v) {
print "\n ";
}
}
@@ -224,10 +189,47 @@ sub do_special1_command {
}
}
-while ($stuff ne "") {
+sub do_special_command() {
+ get_stuff(8);
+ my $comptype = unpack("C", substr($stuff, 2, 1));
+ my $dots = unpack("v", substr($stuff, 6, 2));
+ my $rows = unpack("C", substr($stuff, 5, 1));
+ print_prefix_bytes(8);
+ increment_curpos(8);
+ print_output_data($comptype, 1, $dots, $rows, 8);
+}
+
+sub do_special1_command() {
+ get_stuff(9);
+ my $comptype = unpack("C", substr($stuff, 3, 1));
+ my $bitsperpixel = unpack("C", substr($stuff, 4, 1));
+ my $dots = unpack("v", substr($stuff, 5, 2));
+ my $rows = unpack("v", substr($stuff, 7, 2));
+ print_prefix_bytes(9);
+ increment_curpos(9);
+ print_output_data($comptype, $bitsperpixel, $dots, $rows, 1);
+}
+
+while (! $atend) {
+ my $found;
+ my $key;
+ my $skipchars;
+ my $startoff;
+ my $kchar;
+ my $nkchar;
+ my $lchar;
+ my $nlchar;
+ my $hchar;
+ my $nhchar;
+ my $i;
+ my $char;
+ my $nchar;
+ my $bytes;
+ get_stuff(2);
if (substr($stuff, 0, 1) eq "$esc") {
$found = 0;
foreach $key (sort { length $b <=> length $a } keys %seqtable) {
+ get_stuff(1 + length $key);
if (substr($stuff, 1, length $key) eq $key) {
$skipchars = $seqtable{$key};
if ($skipchars eq "SPECIAL") {
@@ -245,6 +247,7 @@ while ($stuff ne "") {
print "1b ";
$startoff = 0;
if ($skipchars eq "VARIABLE") {
+ get_stuff((length $key) + 3);
$kchar = substr($stuff, (length $key) + 1, 1);
$nkchar = unpack("C", $kchar);
$lchar = substr($stuff, (length $key) + 2, 1);
@@ -254,6 +257,7 @@ while ($stuff ne "") {
$skipchars = ($nhchar * 256) + $nlchar;
$startoff = 3;
}
+ get_stuff($skipchars + (length $key) + $startoff + 1);
for ($i = 0;
$i < $skipchars + (length $key) + $startoff;
$i++) {
@@ -275,14 +279,13 @@ while ($stuff ne "") {
print "\n";
printf "%08x ", $curpos;
print "1b ";
- substr($stuff, 0, 1) = "";
- $curpos += 1;
+ increment_curpos(1);
} elsif ($found == 1) {
- substr($stuff, 0, $bytes) = "";
- $curpos += $bytes;
+ increment_curpos($bytes);
} else {
}
} else {
+ get_stuff(1);
$char = substr($stuff, 0, 1);
$nchar = unpack("C", $char);
if ($nchar >= 32 && $nchar < 127) {
@@ -290,7 +293,6 @@ while ($stuff ne "") {
} else {
printf "*%02x ", unpack("C", $char);
}
- $curpos++;
- substr($stuff, 0, 1) = "";
+ increment_curpos(1);
}
}
diff --git a/test/run-testdither b/test/run-testdither
index b217788..9f592c2 100755
--- a/test/run-testdither
+++ b/test/run-testdither
@@ -2,30 +2,6 @@
out_status=0
-if [ $# -eq 0 ] ; then
- quiet=quiet
-fi
-
-if [ -z "$bits" ] ; then
- bits='1-bit 2-bit'
-fi
-
-if [ -z "$dither_types" ] ; then
- dither_types='gray color photo cmyk photocmyk'
-fi
-
-if [ -z "$image_types" ] ; then
- image_types='mixed white black colorimage random'
-fi
-
-if [ -z "$algos" ] ; then
- algos='Adaptive Ordered Fast VeryFast Floyd EvenTone'
-fi
-
-if [ -z "$print_image" ] ; then
- image='no-image'
-fi
-
if [ -z "$STP_DATA_PATH" ] ; then
STP_DATA_PATH=`pwd`/../src/main
export STP_DATA_PATH
@@ -36,21 +12,37 @@ if [ -z "$STP_MODULE_PATH" ] ; then
export STP_MODULE_PATH
fi
-for algo in $algos ; do
- echo -n "Testing $algo:"
- for bit in $bits ; do
- for dither_type in $dither_types ; do
- for image_type in $image_types ; do
- ./testdither $quiet $image $bit $dither_type $image_type $algo
- status=$?
- if [ "$status" -ne 0 ] ; then
- echo ./testdither $image $bit $dither_type $image_type $algo failed
- out_status=`expr $out_status + 1`
- fi
- done
- done
+valcount=0
+valgrind=
+valopts=''
+
+set_args() {
+ while true ; do
+ case "$1" in
+ -h*|--h*) usage ;;
+ -v|--valgrind) valopts='--tool=memcheck' ; valcount=`expr $valgrind + 1` ;;
+ -c|--cachegrind) valopts='--tool=cachegrind'; valcount=4 ;;
+ -g|--gdb-attach) valopts='--gdb-attach=yes' ;;
+ -V|--verbose) quiet= ;;
+ -q|--quiet) quiet=quiet ;;
+ --) shift; args="$@"; return ;;
+ *) return ;;
+ esac
+ shift
done
- echo
-done
+}
+
+set_args `getopt hgvqncV "$@"`
+
+case "$valcount" in
+ 1) valopts="$valopts -q --num-callers=100 --leak-check=yes";;
+ 2) valopts="$valopts --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes" ;;
+ 3) valopts="$valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes" ;;
+ *) ;;
+esac
+
+if [ -n "$valopts" ] ; then
+ valgrind="valgrind $valopts"
+fi
-exit $out_status
+$valgrind ./testdither
diff --git a/test/run-weavetest b/test/run-weavetest
index cde055f..f87315e 100755
--- a/test/run-weavetest
+++ b/test/run-weavetest
@@ -1,6 +1,14 @@
#!/bin/sh
-echo "$0 may take a very long time to complete. Please wait..."
+if [ -z "$STP_DATA_PATH" ] ; then
+ STP_DATA_PATH=`pwd`/../src/main
+ export STP_DATA_PATH
+fi
+
+if [ -z "$STP_MODULE_PATH" ] ; then
+ STP_MODULE_PATH=`pwd`/../src/main:`pwd`/../src/main/.libs
+ export STP_MODULE_PATH
+fi
passes='1,1,1 2,1,1 1,2,1 1,2,2 1,4,1 4,1,1 4,2,1 2,2,1 1,4,2 2,2,2 2,4,2 8,1,1 4,4,2 8,2,1 16,1,1'
@@ -8,7 +16,7 @@ passes='1,1,1 2,1,1 1,2,1 1,2,2 1,4,1 4,1,1 4,2,1 2,2,1 1,4,2 2,2,2 2,4,2 8,1,1
jets='1 2 4 8 15 16 20 21 24 29 32 47 48 59 60 64 90 96 128 144 180 192 208 360'
# All nozzle separations used by any printer at any resolution.
-separations='1 2 3 4 6 8 12 16'
+separations='1 2 3 4 6 8 12 16 24'
# Weave strategies
strategies='0 1 2 3 4'
diff --git a/test/testdither.c b/test/testdither.c
index de1da06..4a2d1f3 100644
--- a/test/testdither.c
+++ b/test/testdither.c
@@ -1,5 +1,5 @@
/*
- * "$Id: testdither.c,v 1.48 2005/05/07 14:46:41 rlk Exp $"
+ * "$Id: testdither.c,v 1.49 2006/05/07 13:26:27 rlk Exp $"
*
* Test/profiling program for dithering code.
*
@@ -61,11 +61,30 @@ int image_type = IMAGE_MIXED;
int stpi_dither_type = DITHER_COLOR;
const char *dither_name = NULL;
int dither_bits = 1;
+int write_image = 1;
+int quiet;
unsigned short white_line[IMAGE_WIDTH * 6],
black_line[IMAGE_WIDTH * 6],
color_line[IMAGE_WIDTH * 6],
random_line[IMAGE_WIDTH * 6];
+static const char *stpi_dither_types[] = /* Different dithering modes */
+ {
+ "gray",
+ "color",
+ "photo",
+ "cmyk",
+ "photocmyk"
+ };
+static const char *image_types[] = /* Different image types */
+ {
+ "mixed",
+ "white",
+ "black",
+ "colorimage",
+ "random"
+ };
+
#define SHADE(density, name) \
{ density, sizeof(name)/sizeof(stp_dotsize_t), name }
@@ -150,12 +169,11 @@ static stp_image_t theImage =
* 'main()' - Test dithering code for performance measurement.
*/
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+static int
+run_one_testdither(void)
{
int print_progress = 0;
- int i, j; /* Looping vars */
+ int i; /* Looping vars */
unsigned char black[BUFFER_SIZE], /* Black bitmap data */
cyan[BUFFER_SIZE], /* Cyan bitmap data */
magenta[BUFFER_SIZE], /* Magenta bitmap data */
@@ -164,29 +182,11 @@ main(int argc, /* I - Number of command-line arguments */
yellow[BUFFER_SIZE]; /* Yellow bitmap data */
unsigned short rgb[IMAGE_WIDTH * 6], /* RGB buffer */
gray[IMAGE_WIDTH]; /* Grayscale buffer */
- int write_image; /* Write the image to disk? */
FILE *fp = NULL; /* PPM/PGM output file */
char filename[1024]; /* Name of file */
stp_vars_t *v; /* Dither variables */
stp_parameter_t desc;
- static const char *stpi_dither_types[] = /* Different dithering modes */
- {
- "gray",
- "color",
- "photo",
- "cmyk",
- "photocmyk"
- };
- static const char *image_types[] = /* Different image types */
- {
- "mixed",
- "white",
- "black",
- "colorimage",
- "random"
- };
struct timeval tv1, tv2;
- int quiet = 0;
/*
* Initialise libgutenprint
@@ -198,66 +198,6 @@ main(int argc, /* I - Number of command-line arguments */
stp_describe_parameter(v, "DitherAlgorithm", &desc);
/*
- * Get command-line args...
- */
-
- write_image = 1;
-
- for (i = 1; i < argc; i ++)
- {
- if (strcmp(argv[i], "no-image") == 0)
- {
- write_image = 0;
- continue;
- }
-
- if (strcmp(argv[i], "quiet") == 0)
- {
- quiet = 1;
- continue;
- }
-
- if (strcmp(argv[i], "1-bit") == 0)
- {
- dither_bits = 1;
- continue;
- }
-
- if (strcmp(argv[i], "2-bit") == 0)
- {
- dither_bits = 2;
- continue;
- }
-
- for (j = 0; j < 5; j ++)
- if (strcmp(argv[i], stpi_dither_types[j]) == 0)
- break;
-
- if (j < 5)
- {
- stpi_dither_type = j;
- continue;
- }
-
- for (j = 0; j < 5; j ++)
- if (strcmp(argv[i], image_types[j]) == 0)
- break;
-
- if (j < 5)
- {
- image_type = j;
- continue;
- }
-
- for (j = 0; j < stp_string_list_count(desc.bounds.str); j ++)
- if (strcmp(argv[i], stp_string_list_param(desc.bounds.str,j)->name) == 0)
- dither_name = stp_string_list_param(desc.bounds.str, j)->name;
-
- if (!dither_name)
- printf("Unknown option \"%s\" ignored!\n", argv[i]);
- }
-
- /*
* Setup the image and color functions...
*/
@@ -426,6 +366,8 @@ main(int argc, /* I - Number of command-line arguments */
dither_name ? dither_name : desc.deflt.str, dither_bits,
(stpi_dither_type == DITHER_GRAY) ? "pgm" : "ppm");
+ stp_parameter_description_destroy(&desc);
+
if (isatty(1))
print_progress = 1;
@@ -489,9 +431,7 @@ main(int argc, /* I - Number of command-line arguments */
if (fp != NULL)
fclose(fp);
- if (quiet)
- fputc('.', stdout);
- else
+ if (!quiet)
{
if (print_progress)
fputc('\r', stdout);
@@ -503,6 +443,126 @@ main(int argc, /* I - Number of command-line arguments */
return 0;
}
+static int
+run_testdither_from_cmdline(int argc, char **argv)
+{
+ int i, j;
+ int status;
+ for (i = 1; i < argc; i ++)
+ {
+ if (strcmp(argv[i], "no-image") == 0)
+ {
+ write_image = 0;
+ continue;
+ }
+
+ if (strcmp(argv[i], "quiet") == 0)
+ {
+ quiet = 1;
+ continue;
+ }
+
+ if (strcmp(argv[i], "1-bit") == 0)
+ {
+ dither_bits = 1;
+ continue;
+ }
+
+ if (strcmp(argv[i], "2-bit") == 0)
+ {
+ dither_bits = 2;
+ continue;
+ }
+
+ for (j = 0; j < 5; j ++)
+ if (strcmp(argv[i], stpi_dither_types[j]) == 0)
+ break;
+
+ if (j < 5)
+ {
+ stpi_dither_type = j;
+ continue;
+ }
+
+ for (j = 0; j < 5; j ++)
+ if (strcmp(argv[i], image_types[j]) == 0)
+ break;
+
+ if (j < 5)
+ {
+ image_type = j;
+ continue;
+ }
+
+ dither_name = argv[i];
+ }
+ status = run_one_testdither();
+ if (status)
+ return 1;
+ else
+ return 0;
+}
+
+static int
+run_standard_testdithers(void)
+{
+ stp_vars_t *v = stp_vars_create();
+ stp_parameter_t desc;
+ int j;
+ int failures = 0;
+ int status;
+
+ stp_set_driver(v, "escp2-ex");
+ stp_describe_parameter(v, "DitherAlgorithm", &desc);
+
+ write_image = 0;
+ quiet = 1;
+ for (j = 0; j < stp_string_list_count(desc.bounds.str); j ++)
+ {
+ dither_name = stp_string_list_param(desc.bounds.str, j)->name;
+ if (strcmp(dither_name, "None") == 0)
+ continue;
+ printf("%s", dither_name);
+ fflush(stdout);
+ for (dither_bits = 1; dither_bits <= 2; dither_bits++)
+ for (stpi_dither_type = 0;
+ stpi_dither_type < sizeof(stpi_dither_types) / sizeof(const char *);
+ stpi_dither_type++)
+ for (image_type = 0;
+ image_type < sizeof(image_types) / sizeof(const char *);
+ image_type++)
+ {
+ status = run_one_testdither();
+ if (status)
+ {
+ printf("%s %d %s %s\n", dither_name, dither_bits,
+ stpi_dither_types[stpi_dither_type],
+ image_types[image_type]);
+ failures++;
+ }
+ else
+ printf(".");
+ fflush(stdout);
+ }
+ printf("\n");
+ fflush(stdout);
+ }
+ stp_parameter_description_destroy(&desc);
+ stp_vars_destroy(v);
+ return (failures ? 1 : 0);
+}
+
+int
+main(int argc, char **argv)
+{
+ stp_init();
+
+ if (argc == 1)
+ return run_standard_testdithers();
+ else
+ return run_testdither_from_cmdline(argc, argv);
+}
+
void
image_get_row(unsigned short *data,
@@ -949,5 +1009,5 @@ write_photo(FILE *fp,
/*
- * End of "$Id: testdither.c,v 1.48 2005/05/07 14:46:41 rlk Exp $".
+ * End of "$Id: testdither.c,v 1.49 2006/05/07 13:26:27 rlk Exp $".
*/
diff --git a/test/unprint.c b/test/unprint.c
index aed2c65..bdc0003 100644
--- a/test/unprint.c
+++ b/test/unprint.c
@@ -1,4 +1,4 @@
-/* $Id: unprint.c,v 1.36 2005/10/23 19:43:14 rlk Exp $ */
+/* $Id: unprint.c,v 1.37 2006/04/13 12:09:15 rlk Exp $ */
/*
* Generate PPM files from printer output
*
@@ -432,8 +432,8 @@ write_output(FILE *fp_w, int dontwrite, int allblack)
right = pstate.right_edge;
height = oversample * (last - first + 1);
- fprintf(stderr, "Image from (%d,%d) to (%d,%d).\n",
- left, first, right, last);
+ fprintf(stderr, "Image from (%d,%d) to (%d,%d) (%dx%d).\n",
+ left, first, right, last, right - left, last - first);
width = right - left + 1;
if (width < 0)