home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / pbm / Part4 / pbmmake.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-07  |  1.1 KB  |  51 lines

  1. /* pbmmake.c - create a blank bitmap of a specified size
  2. **
  3. ** Copyright (C) 1988 by Jef Poskanzer.
  4. **
  5. ** Permission to use, copy, modify, and distribute this software and its
  6. ** documentation for any purpose and without fee is hereby granted, provided
  7. ** that the above copyright notice appear in all copies and that both that
  8. ** copyright notice and this permission notice appear in supporting
  9. ** documentation.  This software is provided "as is" without express or
  10. ** implied warranty.
  11. */
  12.  
  13. #include <stdio.h>
  14. #include "pbm.h"
  15.  
  16. main( argc, argv )
  17. int argc;
  18. char *argv[];
  19.     {
  20.     bit **bits;
  21.     int rows, cols, row, col;
  22.     char *usage = "usage:  %s <width> <height>\n";
  23.  
  24.     if ( argc != 3 )
  25.     {
  26.     fprintf( stderr, usage, argv[0] );
  27.     exit( 1 );
  28.     }
  29.  
  30.     if ( sscanf( argv[1], "%d", &cols ) != 1 )
  31.     {
  32.     fprintf( stderr, usage, argv[0] );
  33.     exit( 1 );
  34.     }
  35.     if ( sscanf( argv[2], "%d", &rows ) != 1 )
  36.     {
  37.     fprintf( stderr, usage, argv[0] );
  38.     exit( 1 );
  39.     }
  40.  
  41.     bits = pbm_allocarray( cols, rows );
  42.  
  43.     for ( row = 0; row < rows; row++ )
  44.         for ( col = 0; col < cols; col++ )
  45.         bits[row][col] = 0;
  46.  
  47.     pbm_writepbm( stdout, bits, cols, rows );
  48.  
  49.     exit( 0 );
  50.     }
  51.