Skip to main content
added 496 characters in body
Source Link

The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long.

bmp.h (provided) includes the definitions of the structures such as for BITMAPINFOHEADER. I am thinking in terms of memory storage/allocation and trying to understand the following:

If BITMAPINFOHEADER is 40 bytes and the first 4 bytes correspond to the size, the following 4 bytes correspond to the Width, ... how do the fields point to the subset of bytes? How does the dot notation access memory addresses?

typedef uint8_t  BYTE;
typedef uint32_t DWORD;
typedef int32_t  LONG;
typedef uint16_t WORD;

typedef struct
{
DWORD  biSize;
LONG   biWidth;
LONG   biHeight;
WORD   biPlanes;
WORD   biBitCount;
DWORD  biCompression;
DWORD  biSizeImage;
LONG   biXPelsPerMeter;
LONG   biYPelsPerMeter;
DWORD  biClrUsed;
DWORD  biClrImportant;
} __attribute__((__packed__))
BITMAPINFOHEADER;

EDIT

CASE 2

typedef char* string;  
typedef struct
      {  
           string name;
           string number;
      }
      person;

      int main(void)
      {
      person people[2];
      people[0].name = "Brian";
      people[0].number= "+1-222-999-1000";
      }

The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long.

bmp.h (provided) includes the definitions of the structures such as for BITMAPINFOHEADER. I am thinking in terms of memory storage/allocation and trying to understand the following:

If BITMAPINFOHEADER is 40 bytes and the first 4 bytes correspond to the size, the following 4 bytes correspond to the Width, ... how do the fields point to the subset of bytes? How does the dot notation access memory addresses?

typedef uint8_t  BYTE;
typedef uint32_t DWORD;
typedef int32_t  LONG;
typedef uint16_t WORD;

typedef struct
{
DWORD  biSize;
LONG   biWidth;
LONG   biHeight;
WORD   biPlanes;
WORD   biBitCount;
DWORD  biCompression;
DWORD  biSizeImage;
LONG   biXPelsPerMeter;
LONG   biYPelsPerMeter;
DWORD  biClrUsed;
DWORD  biClrImportant;
} __attribute__((__packed__))
BITMAPINFOHEADER;

The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long.

bmp.h (provided) includes the definitions of the structures such as for BITMAPINFOHEADER. I am thinking in terms of memory storage/allocation and trying to understand the following:

If BITMAPINFOHEADER is 40 bytes and the first 4 bytes correspond to the size, the following 4 bytes correspond to the Width, ... how do the fields point to the subset of bytes? How does the dot notation access memory addresses?

typedef uint8_t  BYTE;
typedef uint32_t DWORD;
typedef int32_t  LONG;
typedef uint16_t WORD;

typedef struct
{
DWORD  biSize;
LONG   biWidth;
LONG   biHeight;
WORD   biPlanes;
WORD   biBitCount;
DWORD  biCompression;
DWORD  biSizeImage;
LONG   biXPelsPerMeter;
LONG   biYPelsPerMeter;
DWORD  biClrUsed;
DWORD  biClrImportant;
} __attribute__((__packed__))
BITMAPINFOHEADER;

EDIT

CASE 2

typedef char* string;  
typedef struct
      {  
           string name;
           string number;
      }
      person;

      int main(void)
      {
      person people[2];
      people[0].name = "Brian";
      people[0].number= "+1-222-999-1000";
      }
Source Link

Filter - Structures & Headers

The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long.

bmp.h (provided) includes the definitions of the structures such as for BITMAPINFOHEADER. I am thinking in terms of memory storage/allocation and trying to understand the following:

If BITMAPINFOHEADER is 40 bytes and the first 4 bytes correspond to the size, the following 4 bytes correspond to the Width, ... how do the fields point to the subset of bytes? How does the dot notation access memory addresses?

typedef uint8_t  BYTE;
typedef uint32_t DWORD;
typedef int32_t  LONG;
typedef uint16_t WORD;

typedef struct
{
DWORD  biSize;
LONG   biWidth;
LONG   biHeight;
WORD   biPlanes;
WORD   biBitCount;
DWORD  biCompression;
DWORD  biSizeImage;
LONG   biXPelsPerMeter;
LONG   biYPelsPerMeter;
DWORD  biClrUsed;
DWORD  biClrImportant;
} __attribute__((__packed__))
BITMAPINFOHEADER;