|
|
|
@ -1,17 +1,16 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint8_t hdr_byte;
|
|
|
|
|
uint8_t bpp;
|
|
|
|
|
uint16_t imgfmt;
|
|
|
|
|
uint16_t width;
|
|
|
|
|
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 height;
|
|
|
|
|
uint16_t bypl;
|
|
|
|
|
uint32_t zeroed;
|
|
|
|
|
uint16_t zeroed_2;
|
|
|
|
|
} bmp_header;
|
|
|
|
|
bmp_header input_hdr;
|
|
|
|
|
uint16_t bypl; // bytes per line
|
|
|
|
|
};
|
|
|
|
|
typedef struct bmp_header bmp_hdr;
|
|
|
|
|
bmp_hdr header;
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
if (argc != 2) {
|
|
|
|
|
printf("usage: %s <filename>\n", argv[0]);
|
|
|
|
@ -28,13 +27,14 @@ int main(int argc, char** argv) {
|
|
|
|
|
while (1) {
|
|
|
|
|
c = getc(working_file);
|
|
|
|
|
if (c != EOF) {
|
|
|
|
|
printf("%u ", c);
|
|
|
|
|
if (i % 4 == 0) printf("\n");
|
|
|
|
|
// dump everything in the file to stdout, adding a newline every 16th byte, then prints the file length
|
|
|
|
|
i++;
|
|
|
|
|
printf("%u ", c);
|
|
|
|
|
if (i % 16 == 0) printf("\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("\n%i\n",i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|