BGRA to PNG Converter

Takes a raw BGRA pixel byte file plus the width/height it was captured at, swaps the channel order back to RGBA, rebuilds a pixel buffer with transparency intact, 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, transparency-preserving PNG from a raw BGRA pixel byte dump, entirely in your browser, swapping the blue-first channel order back to the RGBA 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 BGRA to PNG Converter?

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

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

How BGRA to PNG Converter Works

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

For each 4-byte group it writes red (from the third byte), green (second byte), blue (first byte), and alpha (fourth byte, unchanged) into a new RGBA pixel buffer.

When To Use BGRA to PNG Converter

Use it to visualize a raw BGRA frame captured from Windows GDI/DirectX, a GPU texture readback, or camera hardware that outputs BGRA by default.

It's also useful for verifying a PNG-to-BGRA 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 RGBA, preserving transparency while fixing the red/blue swap.

Limitations

  • Requires knowing the exact width and height the raw dump was captured at.
  • Expects exactly 4 bytes per pixel; feeding it a 3-byte-per-pixel BGR dump will fail the byte-count check.

Examples

Visualize a DirectX surface readback

Input

A 4,096-byte raw BGRA file, width 32, height 32

Output

A viewable 32x32 PNG with correct colors and transparency

4,096 bytes divides evenly into 1,024 pixels of 4 bytes each, matching the declared dimensions, with channels reordered back to RGBA.

Reject a truncated file

Input

A 1,000-byte file with width 32, height 32 (expects 4,096 bytes)

Output

An error: "Expected 4096 bytes...but got 1000."

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 BGRA file was originally captured.
  • If colors look swapped, confirm your source data is actually BGRA and not RGBA before troubleshooting further.

Developer Notes

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

BGRA to PNG Converter Use Cases

  • Visualizing a raw BGRA frame captured from Windows GDI/DirectX or camera firmware
  • Round-trip testing a PNG-to-BGRA export pipeline
  • Recovering an image from a headerless BGRA 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 RGBA, which swaps red and blue in the output.

Tips

  • If you're not sure whether your data is RGBA or BGRA, 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