about summary refs log tree commit diff
path: root/editor/pamditherbw.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-24 21:10:18 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-24 21:10:18 +0000
commite2587d242781506d62ca74c9c3ab96a07d225bce (patch)
tree6fe3d08508d4cde2cf76870467f7499fde84dcb4 /editor/pamditherbw.c
parent7e9a53b695db3bbaaea907a6ce00b6d97a9ab951 (diff)
downloadnetpbm-mirror-e2587d242781506d62ca74c9c3ab96a07d225bce.tar.gz
netpbm-mirror-e2587d242781506d62ca74c9c3ab96a07d225bce.tar.xz
netpbm-mirror-e2587d242781506d62ca74c9c3ab96a07d225bce.zip
Add -randomseed
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1782 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pamditherbw.c')
-rw-r--r--editor/pamditherbw.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/editor/pamditherbw.c b/editor/pamditherbw.c
index ec221def..36eb7d9e 100644
--- a/editor/pamditherbw.c
+++ b/editor/pamditherbw.c
@@ -41,6 +41,8 @@ struct cmdlineInfo {
     unsigned int  clusterRadius;  
         /* Defined only for halftone == QT_CLUSTER */
     float         threshval;
+    unsigned int  randomseed;
+    unsigned int  randomseedSpec;
 };
 
 
@@ -83,6 +85,8 @@ parseCommandLine(int argc, char ** argv,
             &valueSpec, 0);
     OPTENT3(0, "clump",     OPT_UINT,  &cmdlineP->clumpSize, 
             &clumpSpec, 0);
+    OPTENT3(0,   "randomseed",   OPT_UINT,    &cmdlineP->randomseed,
+            &cmdlineP->randomseedSpec,      0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -518,7 +522,6 @@ createFsConverter(struct pam * const graypamP,
     /* Initialize Floyd-Steinberg error vectors. */
     MALLOCARRAY_NOFAIL(stateP->thiserr, graypamP->width + 2);
     MALLOCARRAY_NOFAIL(stateP->nexterr, graypamP->width + 2);
-    srand(pm_randseed());
 
     {
         /* (random errors in [-1/8 .. 1/8]) */
@@ -661,8 +664,6 @@ createAtkinsonConverter(struct pam * const graypamP,
     for (relRow = 0; relRow < 3; ++relRow)
         MALLOCARRAY_NOFAIL(stateP->error[relRow], graypamP->width + 2);
 
-    srand(pm_randseed());
-
     {
         /* (random errors in [-1/8 .. 1/8]) */
         unsigned int col;
@@ -857,6 +858,8 @@ main(int argc, char *argv[]) {
 
     parseCommandLine(argc, argv, &cmdline);
 
+    srand(cmdline.randomseedSpec ? cmdline.randomseed : pm_randseed());
+
     ifP = pm_openr(cmdline.inputFilespec);
 
     if (cmdline.halftone == QT_HILBERT)