0

From pset4 we know that a DWORD is defined as an unsigned 32bit integer from 0 through 4294967295 in decimal.

With example to pset4, in biCompression inside BITMAPINFOHEADER, how exactly is either of the "strings" (e.g. BI_RGB, BI_RLE8 or BI_BITFIELDS) stored in memory since they should be just integers? https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx

My guess is they are type-casted to integers as per their ascii values and stored as an array. I would like confirmation and clarification if possible.

Thank You.

1 Answer 1

1

BI_RGB, BI_RLE8, etc. are not "strings".

The BITMAPINFOHEADER structure indicates that biCompression can take on one of the following values:

BI_RGB        An uncompressed format.
BI_RLE8       A run-length encoded (RLE)...
BI_RLE4       An RLE format for bitmaps with 4 bpp ...
BI_BITFIELDS  Specifies that the bitmap is not compressed ...
BI_JPEG       Indicates that the image is a JPEG image.
BI_PNG        Indicates that the image is a PNG image.

This means there's a header file, or library somewhere that defines these constants, and they end up being mapped to integers in the order listed.

If you are implementing your own library, then the choice is yours on how you want to implement the specification.

In other words,

BI_RGB        0
BI_RLE8       1
BI_RLE4       2
BI_BITFIELDS  3
BI_JPEG       4
BI_PNG        5

There are multiple ways in which this can be implemented. For example, one mechanism is via macros (#define), and another is via enumerated types (enum).

https://www.typescriptlang.org/docs/handbook/enums.html provides a good description of enumerated types.

http://paulbourke.net/dataformats/bmp/BITMAP.H is an example of someone implementing their own definitions based on the specification.

1
  • thanks a lot ! .
    – Yan Bo Pei
    Commented Jun 15, 2018 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .