BGRA to PNG Converter
Convert raw BGRA pixel data files into standard PNG images locally in your browser. Specify width and height to accurately decode binary arrays without data loss.
Ensure dimensions match the original file. Raw data lacks headers; incorrect sizes will cause diagonal skewing.
About
Raw BGRA files are headerless binary containers that store uncompressed graphical data. Unlike standard formats (PNG, JPEG), they contain no metadata regarding their own dimensions or color profiles. Every consecutive set of 4 bytes represents a single pixel's Blue, Green, Red, and Alpha channels. Attempting to render this data without explicit dimension mapping leads to memory alignment failures or severe diagonal skewing. This tool strictly performs a client-side byte-swap operation to transform the little-endian BGRA memory layout into the web-standard RGBA layout required by the Canvas API.
Because the format lacks a header, you must manually specify the Width and Height. If the provided dimensions do not perfectly match the binary payload size - calculated as Width × Height × 4 - the tool will execute a defensive partial render, warning you of the byte mismatch. This prevents structural memory crashes while allowing you to debug incorrect dimension estimates.
Formulas
The core rendering engine relies on calculating the exact byte array length and performing a hardware-level channel swap. The expected file size S in bytes is determined by:
During the conversion iteration, where i is the byte offset index (incrementing by 4), the matrix transformation shifts the little-endian sequence into standard web format:
Reference Data
| Resolution Name | Width W (px) | Height H (px) | Expected File Size (Bytes) |
|---|---|---|---|
| VGA | 640 | 480 | 1,228,800 |
| HD (720p) | 1280 | 720 | 3,686,400 |
| FHD (1080p) | 1920 | 1080 | 8,294,400 |
| QHD (1440p) | 2560 | 1440 | 14,745,600 |
| 4K UHD | 3840 | 2160 | 33,177,600 |
| Power of Two (Textures) | 512 | 512 | 1,048,576 |
| Power of Two (Textures) | 1024 | 1024 | 4,194,304 |
| Power of Two (Textures) | 2048 | 2048 | 16,777,216 |