diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-06-28 17:29:32 +0000 |
commit | 23ce26f64c34e30951ad9ade2151552ed77e7357 (patch) | |
tree | d73b31a0c2f7c7be4a69f8a8e84e00dd39c432b5 /editor/pnmremap.c | |
parent | 1b6e51a266008348ad93ed8b6ac9ec91b5024fea (diff) | |
download | netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.gz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.tar.xz netpbm-mirror-23ce26f64c34e30951ad9ade2151552ed77e7357.zip |
promote Advanced to Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4558 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmremap.c')
-rw-r--r-- | editor/pnmremap.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/editor/pnmremap.c b/editor/pnmremap.c index 0038f4d7..e5b59d04 100644 --- a/editor/pnmremap.c +++ b/editor/pnmremap.c @@ -28,6 +28,7 @@ #include "pm_c_util.h" #include "mallocvar.h" #include "nstring.h" +#include "rand.h" #include "shhopt.h" #include "pam.h" #include "ppm.h" @@ -399,20 +400,21 @@ randomizeError(long ** const err, Set a random error in the range [-1 .. 1] (normalized via FS_SCALE) in the error array err[][]. -----------------------------------------------------------------------------*/ - unsigned int const seed = (random.init == RANDOM_WITHSEED) ? - random.seed : pm_randseed(); - unsigned int col; + struct pm_randSt randSt; assert(random.init != RANDOM_NONE); - srand(seed); + pm_randinit(&randSt); + pm_srand2(&randSt, random.init == RANDOM_WITHSEED, random.seed); for (col = 0; col < width; ++col) { unsigned int plane; for (plane = 0; plane < depth; ++plane) - err[plane][col] = rand() % (FS_SCALE * 2) - FS_SCALE; + err[plane][col] = pm_rand(&randSt) % (FS_SCALE * 2) - FS_SCALE; } + + pm_randterm(&randSt); } @@ -1043,13 +1045,6 @@ copyRaster(struct pam * const inpamP, inrow = pnm_allocpamrow(inpamP); outrow = pnm_allocpamrow(&workpam); - if (outpamP->maxval != inpamP->maxval && defaultColor) - pm_error("The maxval of the colormap (%u) is not equal to the " - "maxval of the input image (%u). This is allowable only " - "if you are doing an approximate mapping (i.e. you don't " - "specify -firstisdefault or -missingcolor)", - (unsigned int)outpamP->maxval, (unsigned int)inpamP->maxval); - selectDepthAdjustment(inpamP, outpamP->depth, &depthAdjustment); usehash = TRUE; @@ -1120,6 +1115,13 @@ remap(FILE * const ifP, outpam.width = inpam.width; outpam.height = inpam.height; + if (outpam.maxval != inpam.maxval && defaultColor) + pm_error("The maxval of the colormap (%u) is not equal to the " + "maxval of the input image (%u). This is allowable only " + "if you are doing an approximate mapping (i.e. you don't " + "specify -firstisdefault or -missingcolor)", + (unsigned int)outpam.maxval, (unsigned int)inpam.maxval); + pnm_writepaminit(&outpam); /* Set up so input buffers have extra space as needed to |