Base-64 Decode Bitmap
Decode Base64-encoded BMP bitmap data and render the image. Parses headers, color tables, and pixel data for 1-bit to 32-bit formats.
About
BMP (Windows Bitmap) files encode pixel data with a rigid binary header structure: a 14-byte BITMAPFILEHEADER followed by a 40-byte BITMAPINFOHEADER (DIB header). Misreading the pixel data offset, row padding (each scanline is padded to a 4-byte boundary), or the bottom-up row order produces corrupted output. This tool parses the full BMP binary structure from a Base64 string, supporting bit depths from 1-bit monochrome through 32-bit BGRA, including indexed color table formats. It renders the decoded bitmap to a canvas pixel-by-pixel, so you can visually verify encoded payloads, embedded sprites, or legacy bitmap assets without external software.
This tool approximates standard uncompressed BMP (BI_RGB). RLE-compressed bitmaps (BI_RLE8, BI_RLE4) and OS/2 variants are not supported. If your Base64 string lacks the BMP file header (bytes 0x42 0x4D), decoding will fail. Pro tip: many systems strip the BMP file header and encode only raw pixel buffers. Use the "Raw Pixel Mode" option if your data lacks headers.
Formulas
Row padding ensures each scanline aligns to a 4-byte boundary. The number of padding bytes per row:
Where w = image width in pixels, bpp = bits per pixel. The raw stride (bytes per row including padding):
For indexed formats (1-bit, 4-bit, 8-bit), pixel values are indices into a color table. Each color table entry is 4 bytes: B, G, R, 0x00 (reserved). For 16-bit (RGB555), each channel is extracted via bitmask:
BMP default row order is bottom-up. If the height field is negative, rows are stored top-down. The canvas Y coordinate for row i in bottom-up mode:
Reference Data
| BMP Field | Offset (bytes) | Size (bytes) | Description |
|---|---|---|---|
| Signature | 0 | 2 | Magic bytes: 0x42 0x4D ("BM") |
| File Size | 2 | 4 | Total file size in bytes |
| Reserved | 6 | 4 | Unused, must be 0 |
| Pixel Data Offset | 10 | 4 | Offset to start of pixel array |
| DIB Header Size | 14 | 4 | Size of info header (40 for BITMAPINFOHEADER) |
| Width | 18 | 4 | Image width in pixels (signed 32-bit) |
| Height | 22 | 4 | Image height (negative = top-down order) |
| Color Planes | 26 | 2 | Must be 1 |
| Bits Per Pixel | 28 | 2 | 1, 4, 8, 16, 24, or 32 |
| Compression | 30 | 4 | 0 = BI_RGB (none), 3 = BI_BITFIELDS |
| Image Size | 34 | 4 | Raw pixel data size (can be 0 for BI_RGB) |
| H Resolution | 38 | 4 | Pixels per meter (horizontal) |
| V Resolution | 42 | 4 | Pixels per meter (vertical) |
| Colors Used | 46 | 4 | Number of palette entries (0 = default) |
| Important Colors | 50 | 4 | Usually ignored, set to 0 |
| Row Padding | - | Variable | Each row padded to 4-byte boundary |
| Color Table (indexed) | 54 | 4 ร n | BGRA entries for 1/4/8-bit formats |
| 1-bit Palette Size | - | 8 | 2 colors ร 4 bytes |
| 4-bit Palette Size | - | 64 | 16 colors ร 4 bytes |
| 8-bit Palette Size | - | 1024 | 256 colors ร 4 bytes |
| 16-bit Layout (555) | - | 2/px | 5 bits R, 5 bits G, 5 bits B |
| 24-bit Layout | - | 3/px | B, G, R byte order (no alpha) |
| 32-bit Layout | - | 4/px | B, G, R, A byte order |