diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-03-03 03:19:18 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-03-03 03:19:18 +0000 |
commit | a0196314796de606fcd0a25fb865f55f02db09ea (patch) | |
tree | 4be2a3ae7be3f4b9a293375dcd38a0bc24aa838c | |
parent | 9595b0c55e6b5f819a6e7fbd6208ee97da64670f (diff) | |
download | netpbm-mirror-a0196314796de606fcd0a25fb865f55f02db09ea.tar.gz netpbm-mirror-a0196314796de606fcd0a25fb865f55f02db09ea.tar.xz netpbm-mirror-a0196314796de606fcd0a25fb865f55f02db09ea.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2910 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | generator/ppmpat.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/generator/ppmpat.c b/generator/ppmpat.c index 96c2853d..f4b066ee 100644 --- a/generator/ppmpat.c +++ b/generator/ppmpat.c @@ -46,9 +46,14 @@ typedef enum { } Pattern; typedef struct { +/*---------------------------------------------------------------------------- + An ordered list of colors with a cursor. +-----------------------------------------------------------------------------*/ unsigned int count; unsigned int index; + /* Current position in the list */ pixel * color; + /* Malloced array 'count' in size. */ } ColorTable; struct CmdlineInfo { @@ -552,7 +557,6 @@ clearBackgroundCamo(pixel ** const pixels, if (colorTableP->count > 0) { color = colorTableP->color[0]; - colorTableP->index = 1; } else if (antiflag) color = randomAnticamoColor(maxval); else @@ -564,6 +568,7 @@ clearBackgroundCamo(pixel ** const pixels, } + static void camoFill(pixel ** const pixels, unsigned int const cols, @@ -577,9 +582,8 @@ camoFill(pixel ** const pixels, if (colorTableP->count > 0) { color = colorTableP->color[colorTableP->index]; - nextColorBg(colorTableP); - } - else if (antiflag) + nextColorBg(colorTableP); + } else if (antiflag) color = randomAnticamoColor(maxval); else color = randomCamoColor(maxval); @@ -640,12 +644,17 @@ camo(pixel ** const pixels, pixval const maxval, bool const antiflag) { - unsigned int const n = (rows * cols) / (BLOBRAD * BLOBRAD) * 5; + unsigned int const n = (rows * cols) / SQR(BLOBRAD) * 5; unsigned int i; clearBackgroundCamo(pixels, cols, rows, maxval, colorTableP, antiflag); + if (colorTableP) { + assert(colorTableP->count > 1); + colorTableP->index = 1; /* Foreground colors start at 1 */ + } + for (i = 0; i < n; ++i) { unsigned int const pointCt = rand() % (MAX_POINTS - MIN_POINTS + 1) + MIN_POINTS; |