mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
Add a simple BMP parser. (#11)
This commit is contained in:
committed by
GitHub
parent
2f41f6e233
commit
92d0abc57d
@@ -8,6 +8,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed
|
|||||||
|
|
||||||
| Name | MIME | Path | Description |
|
| Name | MIME | Path | Description |
|
||||||
|------|------|------|-------------|
|
|------|------|------|-------------|
|
||||||
|
| BMP | `image/bmp` | `patterns/bmp.hexpat` | OS2/Windows Bitmap files |
|
||||||
| ELF | `application/x-executable` | `patterns/elf.hexpat` | ELF header in elf binaries |
|
| ELF | `application/x-executable` | `patterns/elf.hexpat` | ELF header in elf binaries |
|
||||||
| PE | `application/x-dosexec` | `patterns/pe.hexpat` | PE header, COFF header, Standard COFF fields and Windows Specific fields |
|
| PE | `application/x-dosexec` | `patterns/pe.hexpat` | PE header, COFF header, Standard COFF fields and Windows Specific fields |
|
||||||
| MIDI | `audio/midi` | `patterns/midi.hexpat` | MIDI header, event fields provided |
|
| MIDI | `audio/midi` | `patterns/midi.hexpat` | MIDI header, event fields provided |
|
||||||
|
|||||||
51
patterns/bmp.hexpat
Normal file
51
patterns/bmp.hexpat
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#pragma MIME image/bmp
|
||||||
|
#pragma endian little
|
||||||
|
|
||||||
|
struct BitmapFileHeader {
|
||||||
|
u8 bfType[2];
|
||||||
|
u32 bfSize;
|
||||||
|
u16 bfReserved1;
|
||||||
|
u16 bfReserved2;
|
||||||
|
u32 bfOffBits;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BitmapInfoHeader {
|
||||||
|
u32 biSize;
|
||||||
|
s32 biWidth;
|
||||||
|
s32 biHeight;
|
||||||
|
u16 biPlanes;
|
||||||
|
u16 biBitCount;
|
||||||
|
u32 biCompression;
|
||||||
|
u32 biSizeImage;
|
||||||
|
s32 biXPelsPerMeter;
|
||||||
|
s32 biYPelsPerMeter;
|
||||||
|
u32 biClrUsed;
|
||||||
|
u32 biClrImportant;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Colors {
|
||||||
|
u8 blue;
|
||||||
|
u8 green;
|
||||||
|
u8 red;
|
||||||
|
u8 reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Bitmap {
|
||||||
|
BitmapFileHeader bmfh;
|
||||||
|
BitmapInfoHeader bmih;
|
||||||
|
|
||||||
|
if ((bmih.biBitCount != 24) && (bmih.biBitCount != 32))
|
||||||
|
{
|
||||||
|
if (bmih.biClrUsed > 0 )
|
||||||
|
Colors rgbq[bmih.biClrUsed];
|
||||||
|
else
|
||||||
|
Colors rgbq[1 << bmih.biBitCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bmih.biSizeImage > 0 )
|
||||||
|
u8 lineData[bmih.biSizeImage];
|
||||||
|
else
|
||||||
|
u8 lineData[bmfh.bfSize - $];
|
||||||
|
};
|
||||||
|
|
||||||
|
Bitmap bitmap @ 0x00;
|
||||||
Reference in New Issue
Block a user