Data URI to Bitmap Converter
Convert Data URI strings to BMP bitmap images. Decode base64 images and save as uncompressed bitmap files with proper headers.
Paste Data URI or drop image file
Supports: JPG, PNG, GIF, WebP, SVG, BMP
About
Data URI to Bitmap conversion requires precise binary encoding to generate valid BMP files. Incorrect header construction leads to corrupted images that fail to open in standard viewers. This converter implements the Windows BMP v3 specification with 24-bit RGB color depth and mandatory 4-byte row alignment padding.
The tool processes Data URIs up to 10 MB, extracting the base64 payload and decoding it to raw pixel data via Canvas API. The BMP encoder calculates the exact file size as fileSize = 54 + height × rowSize, where rowSize includes padding bytes. Each pixel undergoes RGBA to BGR conversion with alpha channel removal, maintaining color accuracy while reducing file size by 25%.
Formulas
BMP file structure follows strict binary encoding rules for compatibility across platforms. The core formula for calculating the total file size accounts for header overhead and row padding alignment:
where the image data size includes mandatory padding:
Legend: width = image width in pixels, height = image height in pixels, rowSize = bytes per row including padding
Reference Data
| BMP Header Field | Offset (bytes) | Size (bytes) | Typical Value | Description |
|---|---|---|---|---|
| Signature | 0 | 2 | 0x424D ('BM') | File type identifier |
| File Size | 2 | 4 | Variable | Total file size in bytes |
| Reserved 1 | 6 | 2 | 0 | Application-specific |
| Reserved 2 | 8 | 2 | 0 | Application-specific |
| Pixel Offset | 10 | 4 | 54 | Start of pixel data |
| DIB Header Size | 14 | 4 | 40 | BITMAPINFOHEADER size |
| Image Width | 18 | 4 | Variable | Width in pixels |
| Image Height | 22 | 4 | Variable | Height in pixels |
| Color Planes | 26 | 2 | 1 | Must be 1 |
| Bits per Pixel | 28 | 2 | 24 | RGB color depth |
| Compression | 30 | 4 | 0 | BI_RGB (uncompressed) |
| Image Size | 34 | 4 | Variable | Pixel data size with padding |
| X Resolution | 38 | 4 | 2835 | Pixels/meter horizontal |
| Y Resolution | 42 | 4 | 2835 | Pixels/meter vertical |
| Colors Used | 46 | 4 | 0 | 0 = all colors |
| Important Colors | 50 | 4 | 0 | 0 = all important |