diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-03-29 22:19:36 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-03-29 22:19:36 +0000 |
commit | ac138b159f6a208dd964a8147cb39a2571092008 (patch) | |
tree | 5a4dfa10a5923670c9e160e96a29967f9aa76700 /editor/pampop9.c | |
parent | 56fbd619bbac49a77ec0b48f06e6ed7bfb84468a (diff) | |
download | netpbm-mirror-ac138b159f6a208dd964a8147cb39a2571092008.tar.gz netpbm-mirror-ac138b159f6a208dd964a8147cb39a2571092008.tar.xz netpbm-mirror-ac138b159f6a208dd964a8147cb39a2571092008.zip |
Release 10.46.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@869 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pampop9.c')
-rw-r--r-- | editor/pampop9.c | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/editor/pampop9.c b/editor/pampop9.c deleted file mode 100644 index d6c61e4f..00000000 --- a/editor/pampop9.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * (c) Robert Tinsley, 2003 (http://www.thepoacher.net/contact) - * - * Released under the GPL (http://www.fsf.org/licenses/gpl.txt) - * - * - * CHANGES - * - * v1.00 2003-02-28 Original version - * - * v1.10 2003-03-02 - * + changed to use pam_* routines rather than ppm_* - * + changed to use pm_* rather than fopen()/fclose() - * + renamed from ppmgrid to pampup9 - * + wrote a man-page (actually, html) - * - * Changes by Bryan Henderson for inclusion in the Netpbm package (fully - * exploiting Netpbm library). Renamed to Pampop9. March 2003. - * - */ - -#include <stdio.h> -#include <stdlib.h> /* atoi() */ - -#include "pam.h" - -static const char * const copyright = - "(c) Robert Tinsley 2003 (http://www.thepoacher.net/contact)"; - -static const char *usagestr = "pnmfile|- xtiles ytiles xdelta ydelta"; - -int main(int argc, char *argv[]) -{ - const char *filename = "-"; - int xtiles, ytiles, xdelta, ydelta; - FILE *fp; - - struct pam spam, dpam; - tuple **spix, *dpix; - int xtilesize, ytilesize, sx, sy, dx, dy, p; - - - - pnm_init(&argc, argv); - - if (argc-1 != 5) { - pm_error("Wrong number of arguments. Program requires 5 arguments; " - "you supplied %d. Usage: %s", argc-1, usagestr); - } - - filename = argv[1]; - xtiles = atoi(argv[2]); - ytiles = atoi(argv[3]); - xdelta = atoi(argv[4]); - ydelta = atoi(argv[5]); - - if (filename == NULL || *filename == '\0' - || xtiles <= 0 || ytiles <= 0 || xdelta < 0 || ydelta < 0) - pm_error("invalid argument"); - - /* read src pam */ - - fp = pm_openr(filename); - - spix = pnm_readpam(fp, &spam, PAM_STRUCT_SIZE(tuple_type)); - - pm_close(fp); - - /* init dst pam */ - - xtilesize = spam.width - (xtiles - 1) * xdelta; - ytilesize = spam.height - (ytiles - 1) * ydelta; - - if (xtilesize <= 0) - pm_error("xtilesize must be positive. You specified %d", xtilesize); - if (ytilesize <= 0) - pm_error("ytilesize must be positive. You specified %d", ytilesize); - - dpam = spam; - dpam.file = stdout; - dpam.width = xtiles * xtilesize; - dpam.height = ytiles * ytilesize; - - dpix = pnm_allocpamrow(&dpam); - - pnm_writepaminit(&dpam); - - /* generate dst pam */ - - for (dy = 0; dy < dpam.height; dy++) { - sy = ((int) (dy / ytilesize)) * ydelta + (dy % ytilesize); - for (dx = 0; dx < dpam.width; dx++) { - sx = ((int) (dx / xtilesize)) * xdelta + (dx % xtilesize); - for (p = 0; p < spam.depth; ++p) { - dpix[dx][p] = spix[sy][sx][p]; - } - } - pnm_writepamrow(&dpam, dpix); - } - - /* all done */ - - pnm_freepamarray(spix, &spam); - pnm_freepamrow(dpix); - - exit(EXIT_SUCCESS); -} |