diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
commit | 367c9cb514c9da766488b9bdb218a18e31cb7624 (patch) | |
tree | f9e343be94161a4837f0f1c1d072a35538ae0f63 /converter/ppm/ppmtoilbm.c | |
parent | 6e88e3326cb0c7f7975b56189278cab3f84ba1bd (diff) | |
download | netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.gz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.xz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.zip |
Promote Stable (10.47) to Super Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@2691 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm/ppmtoilbm.c')
-rw-r--r-- | converter/ppm/ppmtoilbm.c | 66 |
1 files changed, 12 insertions, 54 deletions
diff --git a/converter/ppm/ppmtoilbm.c b/converter/ppm/ppmtoilbm.c index fcc6053f..d296f498 100644 --- a/converter/ppm/ppmtoilbm.c +++ b/converter/ppm/ppmtoilbm.c @@ -439,14 +439,14 @@ compute_ham_cmap(cols, rows, maxval, maxcolors, colorsP, hbits) tmp = hmap[i].b - b; dist += tmp * tmp; if( dist <= maxdist ) { - int sum = hmap[i].count + hmap[col].count; - - hmap[i].r = (hmap[i].r * hmap[i].count + - r * hmap[col].count + sum/2)/sum; - hmap[i].g = (hmap[i].g * hmap[i].count + - g * hmap[col].count + sum/2)/sum; - hmap[i].b = (hmap[i].b * hmap[i].count + - b * hmap[col].count + sum/2)/sum; + unsigned int sum = hmap[i].count + hmap[col].count; + + hmap[i].r = ROUNDDIV(hmap[i].r * hmap[i].count + + r * hmap[col].count, sum); + hmap[i].g = ROUNDDIV(hmap[i].g * hmap[i].count + + g * hmap[col].count, sum); + hmap[i].b = ROUNDDIV(hmap[i].b * hmap[i].count + + b * hmap[col].count, sum); hmap[i].count = sum; hmap[col] = hmap[i]; /* temp store */ @@ -641,20 +641,9 @@ ppm_to_ham(fp, cols, rows, maxval, colormap, colors, cmapmaxval, hamplanes) static long -#ifdef __STDC__ do_ham_body(FILE *ifP, FILE *ofp, int cols, int rows, pixval maxval, pixval hammaxval, int nPlanes, pixel *colormap, int colors) -#else -do_ham_body(ifP, ofp, cols, rows, maxval, hammaxval, nPlanes, colormap, colors) - FILE *ifP, *ofp; - int cols, rows; - pixval maxval; /* maxval of image color components */ - pixval hammaxval; /* maxval of HAM color changes */ - int nPlanes; - pixel *colormap; - int colors; -#endif { register int col, row, i; rawtype *raw_rowbuf; @@ -882,16 +871,8 @@ ppm_to_deep(fp, cols, rows, maxval, bitspercolor) static long -#if __STDC__ do_deep_body(FILE *ifP, FILE *ofp, int cols, int rows, pixval maxval, int bitspercolor) -#else -do_deep_body(ifP, ofp, cols, rows, maxval, bitspercolor) - FILE *ifP, *ofp; - int cols, rows; - pixval maxval; - int bitspercolor; -#endif { register int row, col; pixel *pP; @@ -1020,16 +1001,8 @@ ppm_to_dcol(fp, cols, rows, maxval, dcol) static long -#if __STDC__ do_dcol_body(FILE *ifP, FILE *ofp, int cols, int rows, pixval maxval, DirectColor *dcol) -#else -do_dcol_body(ifP, ofp, cols, rows, maxval, dcol) - FILE *ifP, *ofp; - int cols, rows; - pixval maxval; - DirectColor *dcol; -#endif { register int row, col; pixel *pP; @@ -1167,18 +1140,8 @@ ppm_to_std(fp, cols, rows, maxval, colormap, colors, cmapmaxval, static long -#if __STDC__ do_std_body(FILE *ifP, FILE *ofp, int cols, int rows, pixval maxval, pixel *colormap, int colors, int nPlanes) -#else -do_std_body(ifP, ofp, cols, rows, maxval, colormap, colors, nPlanes) - FILE *ifP, *ofp; - int cols, rows; - pixval maxval; - pixel *colormap; - int colors; - int nPlanes; -#endif { register int row, col, i; pixel *pP; @@ -1789,12 +1752,7 @@ runbyte1(size) /************ other utility functions ************/ static void -#if __STDC__ put_big_short(short s) -#else -put_big_short(s) - short s; -#endif { if ( pm_writebigshort( stdout, s ) == -1 ) pm_error( "write error" ); @@ -1824,12 +1782,12 @@ static int * make_val_table(oldmaxval, newmaxval) int oldmaxval, newmaxval; { - int i; - int *table; + unsigned int i; + int * table; MALLOCARRAY_NOFAIL(table, oldmaxval + 1); - for(i = 0; i <= oldmaxval; i++ ) - table[i] = (i * newmaxval + oldmaxval/2) / oldmaxval; + for (i = 0; i <= oldmaxval; ++i) + table[i] = ROUNDDIV(i * newmaxval, oldmaxval); return table; } |