This page hosts a formal specification of .bmp file format of Heroes of Might and Magic using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.
digraph {
rankdir=LR;
node [shape=plaintext];
subgraph cluster__heroes_of_might_and_magic_bmp {
label="HeroesOfMightAndMagicBmp";
graph[style=dotted];
heroes_of_might_and_magic_bmp__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
<TR><TD PORT="magic_pos">0</TD><TD PORT="magic_size">2</TD><TD>u2le</TD><TD PORT="magic_type">magic</TD></TR>
<TR><TD PORT="width_pos">2</TD><TD PORT="width_size">2</TD><TD>u2le</TD><TD PORT="width_type">width</TD></TR>
<TR><TD PORT="height_pos">4</TD><TD PORT="height_size">2</TD><TD>u2le</TD><TD PORT="height_type">height</TD></TR>
<TR><TD PORT="data_pos">6</TD><TD PORT="data_size">(width * height)</TD><TD></TD><TD PORT="data_type">data</TD></TR>
</TABLE>>];
}
heroes_of_might_and_magic_bmp__seq:width_type -> heroes_of_might_and_magic_bmp__seq:data_size [color="#404040"];
heroes_of_might_and_magic_bmp__seq:height_type -> heroes_of_might_and_magic_bmp__seq:data_size [color="#404040"];
}