diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
commit | 1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch) | |
tree | 64c8c96cf54d8718847339a403e5e67b922e8c3f /editor/pnmtile.c | |
download | netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip |
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmtile.c')
-rw-r--r-- | editor/pnmtile.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/editor/pnmtile.c b/editor/pnmtile.c new file mode 100644 index 00000000..96bf658d --- /dev/null +++ b/editor/pnmtile.c @@ -0,0 +1,63 @@ +/* pnmtile.c - replicate a portable anymap into a specified size +** +** Copyright (C) 1989 by Jef Poskanzer. +** +** 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 "pnm.h" + +int +main( argc, argv ) + int argc; + char* argv[]; + { + FILE* ifp; + xel** xels; + register xel* xelrow; + xelval maxval; + int rows, cols, format, width, height, row, col; + const char* const usage = "width height [pnmfile]"; + + pnm_init( &argc, argv ); + + if ( argc < 3 || argc > 4 ) + pm_usage( usage ); + + if ( sscanf( argv[1], "%d", &width ) != 1 ) + pm_usage( usage ); + if ( sscanf( argv[2], "%d", &height ) != 1 ) + pm_usage( usage ); + + if ( width < 1 ) + pm_error( "width is less than 1" ); + if ( height < 1 ) + pm_error( "height is less than 1" ); + + if ( argc == 4 ) + ifp = pm_openr( argv[3] ); + else + ifp = stdin; + + xels = pnm_readpnm( ifp, &cols, &rows, &maxval, &format ); + pm_close( ifp ); + + xelrow = pnm_allocrow( width ); + + pnm_writepnminit( stdout, width, height, maxval, format, 0 ); + for ( row = 0; row < height; ++row ) + { + for ( col = 0; col < width; ++col ) + xelrow[col] = xels[row % rows][col % cols]; + pnm_writepnmrow( stdout, xelrow, width, maxval, format, 0 ); + } + + pm_close( stdout ); + + exit( 0 ); + } |