BGR to PNG Converter

Takes a raw BGR pixel byte file plus the width/height it was captured at, swaps the channel order back to RGB, rebuilds a fully opaque RGBA pixel buffer, and lets you download the result as a standard PNG. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool rebuilds a viewable PNG from a raw BGR pixel byte dump, entirely in your browser, swapping the blue-first channel order back to the standard RGB the canvas API expects internally.

Since a raw dump carries no dimension metadata, you supply the original width and height and the tool reassembles rows from the flat byte sequence.

What Is BGR to PNG Converter?

A client-side raw-BGR-to-PNG converter that reads a headerless byte file (3 bytes per pixel: blue, green, red), reconstructs an RGBA pixel buffer with full opacity and corrected channel order, and paints it to a canvas for download as a PNG.

It's the exact inverse operation of the PNG to BGR converter.

How BGR to PNG Converter Works

The tool validates that the uploaded byte count exactly equals width times height times 3; any mismatch is rejected with a specific expected-byte-count error.

For each 3-byte group it writes red (from the third byte), green (second byte), and blue (first byte), plus a fixed alpha of 255, into a new RGBA pixel buffer.

When To Use BGR to PNG Converter

Use it to visualize a raw BGR frame captured from OpenCV, a legacy Windows bitmap pipeline, or camera hardware that outputs BGR by default.

It's also useful for verifying a PNG-to-BGR export round-trips correctly by converting it back and comparing.

Features

Advantages

  • Runs entirely client-side; no upload to a server.
  • Validates the byte count up front with a specific, actionable error message.
  • Correctly reorders channels back to RGB so the canvas renders true colors instead of a red/blue swap.

Limitations

  • Requires knowing the exact width and height the raw dump was captured at.
  • Always produces a fully opaque image, since raw BGR carries no transparency information to restore.

Examples

Visualize an OpenCV frame dump

Input

A 3,072-byte raw BGR file, width 32, height 32

Output

A viewable 32x32 opaque PNG with correct colors

3,072 bytes divides evenly into 1,024 pixels of 3 bytes each, matching the declared dimensions, and channels are reordered back to RGB.

Reject a truncated file

Input

A 50-byte file with width 10, height 10 (expects 300 bytes)

Output

An error: "Expected 300 bytes...but got 50."

The byte-count check catches truncated or mismatched dumps before any garbled image is produced.

Best Practices & Notes

Best Practices

  • Double-check the width and height against however the raw BGR file was originally captured.
  • If colors look swapped, confirm your source data is actually BGR and not RGB before troubleshooting further.

Developer Notes

The pure reconstruction logic lives in a lib function that validates the byte count against width x height x 3 before touching any DOM, then writes red/green/blue in the correct RGBA order into a freshly created PixelBuffer.

BGR to PNG Converter Use Cases

  • Visualizing a raw BGR frame captured from OpenCV or camera firmware
  • Round-trip testing a PNG-to-BGR export pipeline
  • Recovering an image from a headerless BGR pixel dump when dimensions are known

Common Mistakes

  • Entering the wrong width/height, which produces a garbled, skewed image even though every byte is technically valid.
  • Using this converter on data that's actually RGB, which swaps red and blue in the output.

Tips

  • If you're not sure whether your data is RGB or BGR, try both converters and see which produces natural-looking colors.
  • Keep the byte-count error message handy — it tells you exactly how many bytes were expected for your entered dimensions.

References

Frequently Asked Questions