home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume5 / pbm3 / part4 / libpbm3.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  1KB  |  43 lines

  1. /* libpbm3.c - pbm utility library part 3
  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. #include "libpbm.h"
  16.  
  17.  
  18. pbm_writepbm( file, bits, cols, rows )
  19. FILE *file;
  20. bit **bits;
  21. int cols, rows;
  22.     {
  23.     int row, col, linecount;
  24.  
  25.     fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, PBM_MAGIC2, cols, rows );
  26.  
  27.     for ( row = 0; row < rows; row++ )
  28.     {
  29.     linecount = 0;
  30.         for ( col = 0; col < cols; col++ )
  31.         {
  32.         if ( linecount >= 70 )
  33.         {
  34.         putc( '\n', file );
  35.         linecount = 0;
  36.         }
  37.         putc( bits[row][col] ? '1' : '0', file );
  38.         linecount++;
  39.         }
  40.     putc( '\n', file );
  41.         }
  42.     }
  43.