Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program used to test the output of bitmap.c
- // Like bindump.c but more precise.
- // License: Michael Warren FSL
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <errno.h>
- int main( int argc, char **argv ){
- FILE *fp;
- int c;
- int i = 0, j = 0;
- if( !(fp = fopen( argv[1], "r" )) ){
- perror( argv[0] );
- exit( errno );
- }
- uint16_t width;
- uint16_t height;
- fread( &width, 2, 1, fp );
- fread( &height, 2, 1, fp );
- int size = width * height;
- while( (c = fgetc( fp )) != EOF ){
- uint8_t b = 0x80;
- while( b ){
- if( b & c ) putchar( '#' );
- else putchar( ' ' );
- b >>= 1;
- if( ++i % width == 0 ) putchar( '\n' );
- if( ++j >= size ) break;
- }
- }
- fclose( fp );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement