|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
struct bmp_header {
|
|
|
|
|
uint8_t hdr_byte; // always 0
|
|
|
|
|
uint8_t bpp; // either 4 or 8, bits per pixel
|
|
|
|
|
uint16_t imgfmt; // always 3
|
|
|
|
|
uint16_t width;
|
|
|
|
|
uint16_t width;
|
|
|
|
|
uint16_t height;
|
|
|
|
|
uint16_t bypl; // bytes per line
|
|
|
|
|
};
|
|
|
|
@ -23,18 +24,31 @@ int main(int argc, char** argv) {
|
|
|
|
|
printf("error opening file\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
int c, i = 0;
|
|
|
|
|
|
|
|
|
|
int c, filearraylen = 0;
|
|
|
|
|
uint8_t* filearray = malloc(0x4000);
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
c = getc(working_file);
|
|
|
|
|
if (c != EOF) {
|
|
|
|
|
// dump everything in the file to stdout, adding a newline every 16th byte, then prints the file length
|
|
|
|
|
i++;
|
|
|
|
|
// dump everything in the file to an array (and stdout with binary representation for debugging, newlining every 8 indices)
|
|
|
|
|
filearray[filearraylen] = c;
|
|
|
|
|
filearraylen++;
|
|
|
|
|
printf("%u ", c);
|
|
|
|
|
if (i % 16 == 0) printf("\n");
|
|
|
|
|
printf("%u", (c & 0b10000000 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b01000000 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b00100000 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b00010000 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b00001000 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b00000100 ? 1 : 0));
|
|
|
|
|
printf("%u", (c & 0b00000010 ? 1 : 0));
|
|
|
|
|
printf("%u ", (c & 0b00000001 ? 1 : 0));
|
|
|
|
|
if (filearraylen % 8 == 0) printf("\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("\n%i\n",i);
|
|
|
|
|
printf("\nlen: %i\n",filearraylen);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fclose(working_file);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|