What does the PNG to BMP Converter do?
The PNG to BMP Converter converts Portable Network Graphics (.png) raster images into uncompressed Windows Bitmap (.bmp / .dib) format. The BMP format stores uncompressed, raw bitmap pixel arrays accompanied by fixed-structure file and info headers, making it ideal for low-level image processing, legacy desktop applications, embedded systems, and graphics programming pipelines.
This tool validates PNG binary signatures, extracts dimensions and color channels from the IHDR chunk, and constructs compliant BITMAPFILEHEADER and BITMAPINFOHEADER structures. It supports 24-bit Truecolor RGB and 32-bit RGBA formats, resolution scaling multipliers (1x to 4x), custom pixel dimensions, background color fills, and instant client-side file downloads.
Core Concepts
Understanding the binary architecture of Windows Bitmap (BMP) files:
- BITMAPFILEHEADER (14 Bytes): The primary file descriptor starting with ASCII magic bytes
BM(0x42 0x4D), followed by total file size in bytes, reserved fields, and a 4-byte offset pointer specifying where pixel bitmap data begins (typically offset54for standard 24-bit/32-bit headers). - BITMAPINFOHEADER (40 Bytes): Defines the bitmap dimensions (width and signed height in pixels), color planes (
1), color bit depth (24for RGB Truecolor or32for RGBA), compression type (0for uncompressedBI_RGB), image payload size, and horizontal/vertical resolution in pixels per meter. - Row Padding (4-Byte Alignment): In standard BMP bitmaps, each horizontal scanline row must be padded to a multiple of 4 bytes (
Math.floor((bitDepth * width + 31) / 32) * 4). - Pixel Order & Color Ordering: BMP scanlines are typically stored in bottom-up order (first row in file represents the bottom of the image) with pixels arranged in BGR (Blue, Green, Red) or BGRA byte order.
How to use the tool?
- Upload or Paste PNG: Drop a
.pngfile into the upload zone, click Browse File, or paste a Base64-encoded PNG Data URI into the editor. Click Load Sample to inspect a sample conversion. - Configure Resolution Scale: Choose from preset multipliers (
1x,2xRetina HD,3xUltra,4xPrint) or enter custom width and height dimensions in pixels. - Select Color Depth: Choose 24-bit Truecolor (RGB) for universal compatibility or 32-bit RGBA to preserve alpha channels.
- Choose Background Fill: Select Solid White, Solid Black, Dark Navy, or specify a Custom Color with hex code input.
- Convert & Download: Click Convert to BMP. The tool renders an instant live preview, calculates the output byte size, and provides a one-click Download button for the
.bmpfile alongside Base64 Data URIs for code embedding.
Related Developer Utilities
Complementary image conversion tools on blueutils.com:
- BMP to PNG Converter: Convert Windows BMP images back into compressed lossless PNG graphics.
- BMP to JPG Converter: Convert uncompressed BMP files into compressed JPEG photos.
- BMP to WebP Converter: Convert BMP images into modern web-optimized WebP graphics.
- BMP to SVG Converter: Vectorize BMP images into scalable SVG vector code.
- PNG to JPG Converter: Convert PNG images into compressed JPEG files.
- PNG to WebP Converter: Convert PNG graphics to lightweight WebP format.
- PNG to ICO Converter: Convert PNG images into multi-size Windows favicons.
- PNG to HEIC Converter: Package PNG graphics into High Efficiency Image Containers.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/image/png-to-bmp) for programmatic bitmap generation.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String | Required. Raw PNG Base64 string or Data URI (data:image/png;base64,...). |
"data:image/png;base64,iVBORw..." |
options.scale |
Number | Optional. Scaling factor multiplier (e.g. 1, 2, 3, 4). Defaults to 1. |
2 |
options.bitDepth |
Number | Optional. Target color depth (24 or 32). Defaults to 24. |
24 |
options.bgColor |
String | Optional. Solid background color fill in hex format. Defaults to "#ffffff". |
"#ffffff" |
options.width |
Number | Optional. Explicit target width in pixels (overrides scale). | 800 |
options.height |
Number | Optional. Explicit target height in pixels (overrides scale). | 600 |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/image/png-to-bmp \
-H "Content-Type: application/json" \
-d '{
"rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC",
"options": {
"scale": 1,
"bitDepth": 24,
"bgColor": "#ffffff"
}
}'Python
import requests
url = "https://blueutils.com/api/image/png-to-bmp"
payload = {
"rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC",
"options": {
"scale": 1,
"bitDepth": 24,
"bgColor": "#ffffff"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = "{\"rawText\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjuAAAAAElFTkSuQmCC\", \"options\": {\"scale\": 1, \"bitDepth\": 24, \"bgColor\": \"#ffffff\"}}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/image/png-to-bmp"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether conversion succeeded. | true |
mimeType |
String | MIME type of generated payload ("image/bmp"). |
"image/bmp" |
originalFormat |
String | MIME type of source image ("image/png"). |
"image/png" |
dataUri |
String | Complete BMP Base64 Data URI. | "data:image/bmp;base64,Qk06..." |
base64 |
String | Pure Base64-encoded BMP binary buffer string. | "Qk06AAAA..." |
metadata |
Object | Dimensions, aspect ratio, bit depth, byte sizes, and format details. | { "originalWidth": 10, "targetWidth": 10, ... } |
snippets |
Object | HTML and Markdown embed code snippets. | { "html": "<img src=\"data:image/bmp...\" />" } |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"mimeType": "image/bmp",
"originalFormat": "image/png",
"dataUri": "data:image/bmp;base64,Qk1eAAAAAAAAADYAAAAoAAAACgAAAAoAAAABABgAAAAAADA...",
"base64": "Qk1eAAAAAAAAADYAAAAoAAAACgAAAAoAAAABABgAAAAAADA...",
"metadata": {
"originalWidth": 10,
"originalHeight": 10,
"targetWidth": 10,
"targetHeight": 10,
"scale": 1,
"bitDepth": "24-bit",
"colorType": "RGBA Truecolor with Alpha",
"hasAlpha": false,
"bgColor": "#ffffff",
"headerType": "BITMAPINFOHEADER",
"formatType": "Windows Device-Independent Bitmap (BMP)",
"aspectRatio": 1,
"originalSizeBytes": 70,
"bmpSizeBytes": 374,
"formattedSize": "374 B"
},
"snippets": {
"html": "<img src=\"data:image/bmp;base64,...\" width=\"10\" height=\"10\" alt=\"Converted BMP Graphic\" />",
"css": "background-image: url(\"data:image/bmp;base64,...\");",
"markdown": ""
}
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid format: Expected a valid Portable Network Graphics (.png) image file."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to convert PNG to BMP?
Integrating the PNG to BMP API into testing pipelines, image ingestion systems, and automation scripts provides several benefits:
- Rapid Script Validation: Enables automated testing pipelines to quickly generate raw uncompressed bitmap fixtures without third-party graphics toolchains.
- Optimized Token Efficiency for AI Agents: LLMs spend hundreds of tokens trying to compute BMP row padding alignments and endian-ordered binary headers. Delegating bitmap generation to a deterministic API saves tokens and eliminates errors.
- Deterministic Accuracy Without Hallucinations: BMP binary structures require strict byte-level header layouts and row strides. The API guarantees 100% specification compliance.
Native Usage
How to convert PNG images to BMP format locally using native operating system utilities and standard libraries:
Windows (PowerShell)
On Windows, PowerShell can convert images to BMP natively using .NET System.Drawing:
Add-Type -AssemblyName System.Drawing
$sourcePng = "input.png"
$targetBmp = "output.bmp"
$bitmap = [System.Drawing.Bitmap]::FromFile((Resolve-Path $sourcePng))
$bitmap.Save($targetBmp, [System.Drawing.Imaging.ImageFormat]::Bmp)
$bitmap.Dispose()
Write-Host "Converted $sourcePng to $targetBmp successfully."Linux / Unix (Bash)
On Linux/macOS systems, use ImageMagick or standard Netpbm utilities:
# ImageMagick CLI conversion
magick input.png output.bmp
# Or using Netpbm utilities
pngtopnm input.png | ppmtobmp > output.bmpPython
Convert PNG to BMP using Python standard library by writing raw DIB scanlines:
import struct
def png_to_bmp(input_png_path: str, output_bmp_path: str, width: int = 100, height: int = 100):
"""Creates an uncompressed 24-bit BMP image using the Python standard library."""
# BMP row padding (must be multiple of 4 bytes)
row_size = ((24 * width + 31) // 32) * 4
image_size = row_size * height
header_offset = 54
file_size = header_offset + image_size
# 1. BITMAPFILEHEADER (14 bytes)
file_header = struct.pack("<2sIHHI", b"BM", file_size, 0, 0, header_offset)
# 2. BITMAPINFOHEADER (40 bytes)
info_header = struct.pack("<IIIHHIIIIII", 40, width, height, 1, 24, 0, image_size, 2835, 2835, 0, 0)
# 3. White pixel buffer (BGR)
row = bytearray([255, 255, 255] * width + [0] * (row_size - width * 3))
pixel_data = bytes(row * height)
with open(output_bmp_path, "wb") as f:
f.write(file_header)
f.write(info_header)
f.write(pixel_data)
print(f"Created {output_bmp_path} ({file_size} bytes)")
# Example usage
png_to_bmp("input.png", "output.bmp", 100, 100)Java
Convert PNG to BMP using Java standard ImageIO library:
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class PngToBmpConverter {
public static void main(String[] args) throws Exception {
File inputFile = new File("input.png");
File outputFile = new File("output.bmp");
BufferedImage image = ImageIO.read(inputFile);
// Strip alpha channel if needed for 24-bit RGB BMP compatibility
BufferedImage rgbImage = new BufferedImage(
image.getWidth(),
image.getHeight(),
BufferedImage.TYPE_INT_RGB
);
rgbImage.createGraphics().drawImage(image, 0, 0, null);
ImageIO.write(rgbImage, "bmp", outputFile);
System.out.println("Converted to " + outputFile.getName() + " successfully.");
}
}