fillin out the bitmap header. also printing hex

main
ieee 802.11ac 1 year ago
parent b0fcce176b
commit bde692bcb7

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

@ -2,7 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
struct bmp_header {
struct HX_BMP_header {
uint8_t hdr_byte; // always 0
uint8_t bpp; // either 4 or 8, bits per pixel
uint16_t imgfmt; // always 3
@ -45,10 +45,12 @@ struct DDS_HEADER {
const DDS_PIXELFORMAT tmp_ddspf = {32, 0x41, 0, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000};
typedef struct DDS_HEADER DDS_HEADER;
typedef struct bmp_header bmp_header;
typedef struct HX_BMP_header HX_BMP_header;
bmp_header bitmapHeader;
DDS_HEADER ddsHeader = {'DDS ', 124, 0x100F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, tmp_ddspf, 0x1000};
HX_BMP_header bitmapHeader;
DDS_HEADER ddsHeader = {/*magic*/ 'DDS ', /*dwSize*/ 124, /*dwFlags*/ 0x100F, /*dwHeight*/ 0, /*dwWidth*/ 0, /*dwPitchOrLinearSize*/ 0, /*dwDepth*/ 0, /*dwMipMapCount*/ 0, /*dwReserved1[0]*/ 0,
/*dwReserved1[1]*/ 0, /*dwReserved1[2]*/ 0, /*dwReserved1[3]*/ 0, /*dwReserved1[4]*/ 0, /*dwReserved1[5]*/ 0, /*dwReserved1[6]*/ 0, /*dwReserved1[7]*/ 0,
/*dwReserved1[8]*/ 0, /*dwReserved1[9]*/ 0, /*dwReserved1[9]*/ 0, /*ddspf*/ tmp_ddspf, /*dwCaps*/ 0x1000};
int main(int argc, char** argv) {
if (argc != 2) {
@ -72,21 +74,27 @@ int main(int argc, char** argv) {
// 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);
printf(" 0x%02x ", c);
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 & 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 % 4 == 0) printf(" ");
if (filearraylen % 8 == 0) printf("\n");
} else {
printf("len: %i\n",filearraylen);
break;
}
}
bitmapHeader.bpp = filearray[1];
bitmapHeader.imgfmt = filearray[2];
bitmapHeader.width = filearray[4];
bitmapHeader.height = filearray[6];
bitmapHeader.bypl = filearray[9];
fclose(working_file);
return 0;
}
Loading…
Cancel
Save