User Rating 0.0
Total Usage 0 times
Presets:
🖼️ Bitmap preview will appear here
Is this tool helpful?

Your feedback helps us improve.

About

Raw byte data represents pixel information in its most fundamental form: sequential octets encoding color channels per the selected bit depth. Misinterpreting byte order, row padding, or channel count produces corrupted output. A 640×480 image at 24-bit depth requires exactly 921,600 bytes (3 bytes per pixel). The BMP format adds row padding to align each scanline to 4-byte boundaries. Omitting this padding shifts every subsequent row. This tool parses decimal, hexadecimal, base64, and JSON array inputs, maps bytes to RGBA pixel data at the correct stride, and exports standards-compliant BMP files with proper BITMAPINFOHEADER structures or lossless PNG via Canvas.

The converter auto-detects optimal image dimensions from byte count when width is unspecified. It factors the total pixel count and selects the pair of factors closest to a 1:1 aspect ratio. For incomplete final rows the tool zero-pads remaining bytes. Note: this tool assumes linear byte order (no embedded headers or compression). If your source data contains file headers, strip them before conversion.

byte array bitmap converter image pixel data BMP PNG hex to image raw bytes

Formulas

The total byte count required for an uncompressed bitmap is determined by color depth and dimensions:

B = W × H × D8

Where B = total bytes, W = width in pixels, H = height in pixels, D = bit depth (1, 8, 24, or 32).

BMP row padding ensures each scanline aligns to a 4-byte boundary:

P = (4 (W × D8) mod 4) mod 4

Where P = padding bytes appended to each row. For 32-bit images, P is always 0 since 4 bytes per pixel inherently aligns.

Auto-dimension detection finds integer factor pair (w, h) of total pixel count N that minimizes:

|w h| min, where w × h N

BMP file size calculation:

FileSize = 14 + 40 + ColorTable + (W × D8 + P) × H

Where ColorTable = 0 for 24/32-bit, 1024 bytes (256 × 4) for 8-bit, and 8 bytes (2 × 4) for 1-bit.

Reference Data

Color DepthBytes/PixelChannelsTotal ColorsUse CaseRow Padding Rule
1-bit Monochrome0.1251 (packed)2Barcodes, QR masksPad to 4-byte boundary
8-bit Grayscale11256Medical imaging, heightmapsPad to 4-byte boundary
16-bit RGB55523 (packed)32,768Legacy displays, embeddedPad to 4-byte boundary
24-bit RGB33 (R, G, B)16,777,216Photos, standard graphicsPad to 4-byte boundary
32-bit RGBA44 (R, G, B, A)4,294,967,296Transparency, compositingNo padding needed (already aligned)
BMP File Structure
BITMAPFILEHEADER14 bytesSignature (0x42 0x4D = "BM"), file size, data offset
BITMAPINFOHEADER40 bytesWidth, height, bit depth, compression, image size
Color TableVariableRequired for ≤ 8-bit. 4 bytes per entry (B, G, R, 0x00)
Pixel DataVariableBottom-up row order, BGR channel order
Common Input Formats
Decimal CSV255, 128, 0, 255, 0, 128
Hex (0x prefix)0xFF, 0x80, 0x00, 0xFF, 0x00, 0x80
Hex (plain)FF 80 00 FF 00 80
JSON Array[255, 128, 0, 255, 0, 128]
Base64/4AAgACA (binary encoded)
C-style Array{0xFF, 0x80, 0x00}
Dimension Auto-Detection
100 pixels10 × 10Perfect square
1920 pixels48 × 40Closest factors to square
307,200 pixels640 × 480VGA resolution
2,073,600 pixels1920 × 1080Full HD

Frequently Asked Questions

This occurs when the specified width does not match the actual scanline width of your source data. Each row must consume exactly W × bytes-per-pixel bytes. If the width is off by even 1 pixel, every subsequent row shifts, creating a diagonal shearing artifact. Verify your width matches the original image dimensions, or use the auto-detect feature which factors the total pixel count to find matching dimensions.
Input bytes are interpreted in standard order: R, G, B (and A for 32-bit). This matches the memory layout used by Canvas ImageData and most programming languages. Note that the BMP file format internally stores pixels in BGR order - this tool handles the channel swap automatically during BMP export. If your source data is already BGR (e.g., from a raw BMP dump), swap the R and B channels in your source or the output colors will have inverted red/blue.
Each byte encodes 8 pixels. Bit 7 (MSB) is the leftmost pixel, bit 0 (LSB) is the rightmost. A 1 bit maps to white (255, 255, 255), a 0 bit maps to black (0, 0, 0). For a 100-pixel-wide image, each row consumes 13 bytes (with 4 unused bits in the last byte). BMP padding still applies to the byte-level row width.
The tool caps text input at 16 MB of raw text. For 24-bit RGB, this translates to approximately 5.3 million pixels (roughly 2300 × 2300). Canvas has its own limits - most browsers cap at 16,384 × 16,384 pixels. For very large arrays, use file upload instead of pasting text, as the FileReader API handles binary data more efficiently than string parsing.
BMP is uncompressed. Every pixel is stored verbatim, plus row padding bytes. A 100 × 100 image at 24-bit depth produces a BMP of 30,054 bytes (headers) + padded pixel data. PNG applies DEFLATE compression and delta filtering, often achieving 50 - 90% size reduction for images with uniform regions. Use PNG for distribution and BMP only when the specification demands uncompressed raster data.
Yes. Export the memory region as a binary file or hex dump. For frame buffers, you need to know the exact resolution and color depth. Common embedded formats include RGB565 (16-bit, not directly supported - convert to 24-bit first by expanding 5/6/5 bits to 8/8/8). Set the width to match the display's horizontal resolution. If the dump includes non-pixel header data, strip those bytes before input.