BMP Colors in BGR Order to RGB Order Converter
Convert BMP image color channels from BGR byte order to RGB order. Supports 24-bit and 32-bit BMP files with instant preview and download.
Drop a .bmp file here or click to browse
Supports 24-bit and 32-bit uncompressed BMP
About
The BMP (Bitmap) file format stores pixel color data in BGR byte order, not the RGB order that most rendering pipelines and image editors expect. Loading a BGR-ordered buffer into an RGB-expecting context produces images with swapped red and blue channels. Skin tones turn blue. Skies turn orange. The error is silent and systematic. This tool performs a direct byte-level swap of the first and third channel bytes in every pixel triplet (or quad for 32-bit), operating on the raw binary data without re-encoding or lossy compression. It handles DWORD row padding, bottom-up scanline order, and both 24-bit and 32-bit pixel depths. Processing is entirely client-side; your files never leave the browser.
This tool assumes uncompressed BMP files (BI_RGB compression, type 0). RLE-compressed or OS/2 variant BMPs are rejected with a diagnostic message. The output file preserves the original header metadata exactly; only the pixel data bytes are modified. Note: if your source file is already in RGB order (non-standard for BMP), running this converter will incorrectly swap it to BGR. Verify your source channel order before converting.
Formulas
The channel swap operates on each pixel in the raw byte buffer. For a 24-bit uncompressed BMP, the pixel data begins at byte offset O (read from header at 0x0A). Each scanline contains W pixels of 3 bytes each, padded to the nearest 4-byte boundary.
Where P = padding bytes per row, W = image width in pixels, and bpp = bytes per pixel (3 for 24-bit, 4 for 32-bit). The stride (total bytes per row) is:
For each pixel at row r, column c, the byte index into the pixel data region is:
The swap operation exchanges byte[i] (Blue) with byte[i + 2] (Red). The green channel at byte[i + 1] and alpha at byte[i + 3] (32-bit only) remain untouched.
buf[i] = buf[i + 2]
buf[i + 2] = temp
Reference Data
| BMP Property | Header Offset | Size (bytes) | Description |
|---|---|---|---|
| Magic Number | 0x00 | 2 | Must be 0x42 0x4D ("BM") |
| File Size | 0x02 | 4 | Total file size in bytes |
| Reserved | 0x06 | 4 | Application-specific; usually 0 |
| Pixel Data Offset | 0x0A | 4 | Byte offset to start of pixel array |
| Header Size | 0x0E | 4 | DIB header size (40 for BITMAPINFOHEADER) |
| Image Width | 0x12 | 4 | Width in pixels (signed int32) |
| Image Height | 0x16 | 4 | Height in pixels (negative = top-down) |
| Color Planes | 0x1A | 2 | Must be 1 |
| Bits Per Pixel | 0x1C | 2 | 1, 4, 8, 16, 24, or 32 |
| Compression | 0x1E | 4 | 0 = BI_RGB (uncompressed) |
| Image Data Size | 0x22 | 4 | Size of raw pixel data (may be 0 for BI_RGB) |
| H Resolution | 0x26 | 4 | Pixels per meter (horizontal) |
| V Resolution | 0x2A | 4 | Pixels per meter (vertical) |
| Colors Used | 0x2E | 4 | Number of palette colors (0 = default) |
| Important Colors | 0x32 | 4 | Number of important colors (0 = all) |
| Pixel Byte Order by Bit Depth | |||
| 24-bit BGR | 3 bytes/pixel | B0 G1 R2 → R0 G1 B2 | |
| 32-bit BGRA | 4 bytes/pixel | B0 G1 R2 A3 → R0 G1 B2 A3 | |
| Row Padding | 0-3 bytes | Each row padded to 4-byte (DWORD) boundary | |
| Scanline Order | - | Bottom-up if height > 0; top-down if < 0 | |