diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-01-15 20:23:36 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-01-15 20:23:36 +0000 |
commit | 71f0a053398f645c3bf92429f5bee8d21da25aa6 (patch) | |
tree | 9835577764796f7851fe06eb4ae8a8af9729e13d | |
parent | fc4f292f60ab17b24bbf2908626c103fbbcb83f9 (diff) | |
download | netpbm-mirror-71f0a053398f645c3bf92429f5bee8d21da25aa6.tar.gz netpbm-mirror-71f0a053398f645c3bf92429f5bee8d21da25aa6.tar.xz netpbm-mirror-71f0a053398f645c3bf92429f5bee8d21da25aa6.zip |
cleanup - remove unused libppmfloyd
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4247 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | common.mk | 2 | ||||
-rw-r--r-- | doc/HISTORY | 5 | ||||
-rw-r--r-- | lib/Makefile | 3 | ||||
-rw-r--r-- | lib/libppmfloyd.c | 312 | ||||
-rw-r--r-- | lib/ppmfloyd.h | 69 |
5 files changed, 7 insertions, 384 deletions
diff --git a/common.mk b/common.mk index 91b476b9..c86ef910 100644 --- a/common.mk +++ b/common.mk @@ -144,7 +144,7 @@ IMPORTINC_ROOT_HEADERS := pm_config.h inttypes_netpbm.h version.h IMPORTINC_LIB_HEADERS := \ pm.h pbm.h pgm.h ppm.h pnm.h pam.h pbmfont.h ppmcmap.h \ - pammap.h colorname.h ppmfloyd.h ppmdraw.h pm_system.h ppmdfont.h \ + pammap.h colorname.h ppmdraw.h pm_system.h ppmdfont.h \ pm_gamma.h lum.h dithers.h pamdraw.h IMPORTINC_LIB_UTIL_HEADERS := \ diff --git a/doc/HISTORY b/doc/HISTORY index bb11ee91..e58e690b 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -20,6 +20,11 @@ not yet BJH Release 10.98.00 ppmtoilbm: Fix wild memory references and hangs with -map . Introduced in Netpbm 9.12 (March 2001). + Remove Floyd-Steinberg dithering functions (ppm_fs_*) from + libnetpbm (libppmfloyd). No longer used. Floyd-Steinberg + dithering logic can be found in pnmremap. libppmfloyd + was previously used by ppmtoilbm. + 21.12.27 BJH Release 10.97.00 Add pbnnoise. diff --git a/lib/Makefile b/lib/Makefile index d42658a2..d7dfc993 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -33,7 +33,6 @@ LIBOBJECTS = libpm.o pmfileio.o fileio.o colorname.o \ libpgm1.o libpgm2.o \ libppm1.o libppm2.o libppmcmap.o libppmcolor.o libppmfuzzy.o \ libppmd.o ppmdfont.o standardppmdfont.o path.o \ - libppmfloyd.o \ libpnm1.o libpnm2.o libpnm3.o \ libpam.o libpamread.o libpamwrite.o \ libpamn.o libpammap.o libpamcolor.o \ @@ -63,7 +62,7 @@ MANUALS5 = pbm pgm ppm pnm pam INTERFACE_HEADERS = colorname.h \ pam.h pamdraw.h pammap.h pbm.h pbmfont.h pbmfontdata.h \ pgm.h pm.h pm_gamma.h pm_system.h pnm.h \ - ppm.h ppmcmap.h ppmdfont.h ppmdraw.h ppmfloyd.h \ + ppm.h ppmcmap.h ppmdfont.h ppmdraw.h \ util/mallocvar.h util/runlength.h util/shhopt.h \ DATAFILES = rgb.txt diff --git a/lib/libppmfloyd.c b/lib/libppmfloyd.c deleted file mode 100644 index a7117c8e..00000000 --- a/lib/libppmfloyd.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -These functions were taken from Ingo Wilken's ilbm package by Bryan -Henderson on 01.03.10. Because ppmtoilbm and ilbmtoppm are the only -programs that will use these in the foreseeable future, they remain -lightly documented and tested. - -But they look like they would be useful in other Netpbm programs that -do Floyd-Steinberg. -*/ - - - -/* libfloyd.c - generic Floyd-Steinberg error distribution routines for PBMPlus -** -** Copyright (C) 1994 Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "netpbm/mallocvar.h" -#include "ppm.h" -#include "ppmfloyd.h" - - - -static void -fs_adjust(ppm_fs_info * const fi, - int const col) { - - int const errcol = col+1; - pixel * const pP = &(fi->pixrow[col]); - pixval const maxval = fi->maxval; - - long r, g, b; - - /* Use Floyd-Steinberg errors to adjust actual color. */ - r = fi->thisrederr [errcol]; if( r < 0 ) r -= 8; else r += 8; r /= 16; - g = fi->thisgreenerr[errcol]; if( g < 0 ) g -= 8; else g += 8; g /= 16; - b = fi->thisblueerr [errcol]; if( b < 0 ) b -= 8; else b += 8; b /= 16; - - r += PPM_GETR(*pP); if ( r < 0 ) r = 0; else if ( r > maxval ) r = maxval; - g += PPM_GETG(*pP); if ( g < 0 ) g = 0; else if ( g > maxval ) g = maxval; - b += PPM_GETB(*pP); if ( b < 0 ) b = 0; else if ( b > maxval ) b = maxval; - - PPM_ASSIGN(*pP, r, g, b); - fi->red = r; fi->green = g; fi->blue = b; -} - - - -static ppm_fs_info * -allocateFi(int const cols) { - - ppm_fs_info * fi; - - MALLOCVAR(fi); - - if (fi != NULL) { - MALLOCARRAY(fi->thisrederr , cols + 2); - MALLOCARRAY(fi->thisgreenerr, cols + 2); - MALLOCARRAY(fi->thisblueerr , cols + 2); - MALLOCARRAY(fi->nextrederr , cols + 2); - MALLOCARRAY(fi->nextgreenerr, cols + 2); - MALLOCARRAY(fi->nextblueerr , cols + 2); - - if (fi->thisrederr == NULL || - fi->thisgreenerr == NULL || - fi->thisblueerr == NULL || - fi->nextrederr == NULL || - fi->nextgreenerr == NULL || - fi->nextblueerr == NULL) - pm_error("out of memory allocating " - "Floyd-Steinberg control structure"); - } else - pm_error("out of memory allocating Floyd-Steinberg control structure"); - - return(fi); -} - - - -ppm_fs_info * -ppm_fs_init(unsigned int const cols, - pixval const maxval, - unsigned int const flags) { - - ppm_fs_info * fiP; - - fiP = allocateFi(cols); - - fiP->lefttoright = 1; - fiP->cols = cols; - fiP->maxval = maxval; - fiP->flags = flags; - - if (flags & FS_RANDOMINIT) { - unsigned int i; - srand(pm_randseed()); - for (i = 0; i < cols +2; ++i) { - /* random errors in [-1..+1] */ - fiP->thisrederr[i] = rand() % 32 - 16; - fiP->thisgreenerr[i] = rand() % 32 - 16; - fiP->thisblueerr[i] = rand() % 32 - 16; - } - } else { - unsigned int i; - - for (i = 0; i < cols + 2; ++i) - fiP->thisrederr[i] = fiP->thisgreenerr[i] = - fiP->thisblueerr[i] = 0; - } - return fiP; -} - - - -void -ppm_fs_free(ppm_fs_info * const fiP) { - - if (fiP) { - free(fiP->thisrederr); free(fiP->thisgreenerr); free(fiP->thisblueerr); - free(fiP->nextrederr); free(fiP->nextgreenerr); free(fiP->nextblueerr); - free(fiP); - } -} - - - -int -ppm_fs_startrow(ppm_fs_info * const fiP, - pixel * const pixrow) { - - int retval; - - if (!fiP) - retval = 0; - else { - unsigned int col; - - fiP->pixrow = pixrow; - - for (col = 0; col < fiP->cols + 2; ++col) { - fiP->nextrederr [col] = 0; - fiP->nextgreenerr[col] = 0; - fiP->nextblueerr [col] = 0; - } - - if(fiP->lefttoright) { - fiP->col_end = fiP->cols; - col = 0; - } else { - fiP->col_end = -1; - col = fiP->cols - 1; - } - fs_adjust(fiP, col); - - retval = col; - } - return retval; -} - - - -int -ppm_fs_next(ppm_fs_info * const fiP, - int const startCol) { - - int col; - - col = startCol; /* initial value */ - - if (!fiP) - ++col; - else { - if (fiP->lefttoright) - ++col; - else - --col; - if (col == fiP->col_end) - col = fiP->cols; - else - fs_adjust(fiP, col); - } - return col; -} - - - -void -ppm_fs_endrow(ppm_fs_info * const fiP) { - - if (fiP) { - { - long * const tmp = fiP->thisrederr; - fiP->thisrederr = fiP->nextrederr; - fiP->nextrederr = tmp; - } - { - long * const tmp = fiP->thisgreenerr; - fiP->thisgreenerr = fiP->nextgreenerr; - fiP->nextgreenerr = tmp; - } - { - long * const tmp = fiP->thisblueerr; - fiP->thisblueerr = fiP->nextblueerr; - fiP->nextblueerr = tmp; - } - if (fiP->flags & FS_ALTERNATE) - fiP->lefttoright = !fiP->lefttoright; - } -} - - - -void -ppm_fs_update(ppm_fs_info * const fiP, - int const col, - pixel * const pP) { - - if (fiP) - ppm_fs_update3(fiP, col, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP)); -} - - - -void -ppm_fs_update3(ppm_fs_info * const fiP, - int const col, - pixval const r, - pixval const g, - pixval const b) { - - int const errcol = col + 1; - - if (fiP) { - long const rerr = (long)(fiP->red) - (long)r; - long const gerr = (long)(fiP->green) - (long)g; - long const berr = (long)(fiP->blue) - (long)b; - - if ( fiP->lefttoright ) { - { - long const two_err = 2*rerr; - - long err; - - err = rerr; fiP->nextrederr[errcol+1] += err; /* 1/16 */ - err += two_err; fiP->nextrederr[errcol-1] += err; /* 3/16 */ - err += two_err; fiP->nextrederr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisrederr[errcol+1] += err; /* 7/16 */ - } - { - long const two_err = 2*gerr; - - long err; - - err = gerr; fiP->nextgreenerr[errcol+1] += err; /* 1/16 */ - err += two_err; fiP->nextgreenerr[errcol-1] += err; /* 3/16 */ - err += two_err; fiP->nextgreenerr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisgreenerr[errcol+1] += err; /* 7/16 */ - } - { - long const two_err = 2*berr; - - long err; - - err = berr; fiP->nextblueerr[errcol+1] += err; /* 1/16 */ - err += two_err; fiP->nextblueerr[errcol-1] += err; /* 3/16 */ - err += two_err; fiP->nextblueerr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisblueerr[errcol+1] += err; /* 7/16 */ - } - } else { - { - long const two_err = 2*rerr; - - long err; - - err = rerr; fiP->nextrederr[errcol-1] += err; /* 1/16 */ - err += two_err; fiP->nextrederr[errcol+1] += err; /* 3/16 */ - err += two_err; fiP->nextrederr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisrederr[errcol-1] += err; /* 7/16 */ - } - { - long const two_err = 2*gerr; - - long err; - - err = gerr; fiP->nextgreenerr[errcol-1] += err; /* 1/16 */ - err += two_err; fiP->nextgreenerr[errcol+1] += err; /* 3/16 */ - err += two_err; fiP->nextgreenerr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisgreenerr[errcol-1] += err; /* 7/16 */ - } - { - long const two_err = 2*berr; - - long err; - - err = berr; fiP->nextblueerr[errcol-1] += err; /* 1/16 */ - err += two_err; fiP->nextblueerr[errcol+1] += err; /* 3/16 */ - err += two_err; fiP->nextblueerr[errcol ] += err; /* 5/16 */ - err += two_err; fiP->thisblueerr[errcol-1] += err; /* 7/16 */ - } - } - } -} - - - diff --git a/lib/ppmfloyd.h b/lib/ppmfloyd.h deleted file mode 100644 index 264fc0b6..00000000 --- a/lib/ppmfloyd.h +++ /dev/null @@ -1,69 +0,0 @@ -/* These declarations were supposed to be in the libfloyd.h file in the ilbm - package, but that file was missing, so I made them up myself. - - Bryan 01.03.10. -*/ - - -#ifdef __cplusplus -extern "C" { -#endif -#if 0 -} /* to fake out automatic code indenters */ -#endif - -struct ppm_fs_info { - /* thisXerr and nextXerr are dynamically allocated arrays each of whose - dimension is the width of the image plus 2 - */ - long * thisrederr; - long * thisgreenerr; - long * thisblueerr; - long * nextrederr; - long * nextgreenerr; - long * nextblueerr; - int lefttoright; - int cols; - pixval maxval; - int flags; - pixel * pixrow; - int col_end; - pixval red, green, blue; -}; - -typedef struct ppm_fs_info ppm_fs_info; - -/* Bitmasks for ppm_fs_info.flags */ -#define FS_RANDOMINIT 0x01 -#define FS_ALTERNATE 0x02 - -ppm_fs_info * -ppm_fs_init(unsigned int const cols, - pixval const maxval, - unsigned int const flags); - -void -ppm_fs_free(ppm_fs_info *fi); - -int -ppm_fs_startrow(ppm_fs_info *fi, pixel *pixrow); - -int -ppm_fs_next(ppm_fs_info *fi, int col); - -void -ppm_fs_endrow(ppm_fs_info *fi); - -void -ppm_fs_update( ppm_fs_info *fi, int col, pixel *pP); - - -void -ppm_fs_update3(ppm_fs_info * const fi, - int const col, - pixval const r, - pixval const g, - pixval const b); - -#ifdef __cplusplus -} -#endif |