SHARE
TWEET

render.c

AnonymousNamefag Mar 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Program used to test the output of bitmap.c
  2. // Like bindump.c but more precise.
  3. // License: Michael Warren FSL
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <stdint.h>
  8. #include <errno.h>
  9.  
  10. int main( int argc, char **argv ){
  11.     FILE *fp;
  12.     int c;
  13.     int i = 0, j = 0;
  14.     if( !(fp = fopen( argv[1], "r" )) ){
  15.         perror( argv[0] );
  16.         exit( errno );
  17.     }
  18.     uint16_t width;
  19.     uint16_t height;
  20.     fread( &width, 2, 1, fp );
  21.     fread( &height, 2, 1, fp );
  22.     int size = width * height;
  23.     while( (c = fgetc( fp )) != EOF ){
  24.         uint8_t b = 0x80;
  25.         while( b ){
  26.             if( b & c ) putchar( '#' );
  27.             else putchar( ' ' );
  28.             b >>= 1;
  29.             if( ++i % width == 0 ) putchar( '\n' );
  30.             if( ++j >= size ) break;
  31.         }
  32.     }
  33.     fclose( fp );
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top