15 September 2026
Converting Better Portable Graphics (BPG) to PNG: HEVC-Derived Image Decoding
Converting Better Portable Graphics (BPG) to PNG: HEVC-Derived Image Decoding
In 2014, legendary programmer Fabrice Bellard (creator of FFmpeg, QEMU, and QuickJS) announced BPG (Better Portable Graphics), an image format engineered to replace JPEG. By utilizing the intra-frame prediction algorithms of the HEVC (H.265) video standard, BPG achieved unprecedented image quality at half the file size of comparable JPEG images.
While WebP and AVIF eventually became native web standards, millions of high-efficiency graphics, scientific imagery, and photography archives were produced in .bpg format. Because mainstream browsers do not support BPG natively, converting them into standard 32-bit RGBA PNG files is essential for viewing and sharing.
1. The BPG File Architecture
A valid BPG file begins with a 4-byte magic signature followed by variable-length quantity headers:
| Offset | Length | Description |
|---|---|---|
| 0x00 | 4 bytes | Magic signature: 0x79 0x71 0x73 0xFB (ASCII yqs\xFB) |
| 0x04 | 1 byte | Pixel format (4:2:0, 4:2:2, 4:4:4, RGB) and bit depth (8 to 14 bits) |
| 0x05 | 1 byte | Color space (YCbCr BT.601, BT.709, BT.2020, RGB), alpha, and animation flags |
| 0x06 | Variable (LEB128) | Picture width in pixels |
| Next | Variable (LEB128) | Picture height in pixels |
| Next | Variable (LEB128) | Picture data byte length |
| Next | Variable | Optional extension tags (EXIF metadata, ICC color profile, XMP) |
| Next | Variable | Intra-frame bitstream and image payload |
2. Variable-Length LEB128 Integer Decoding
BPG encodes dimensions and chunk lengths using unsigned LEB128 (Little-Endian Base 128) variable-length integers to conserve header bytes:
function readUleb128(bytes: Uint8Array, offset: { val: number }): number {
let result = 0;
let shift = 0;
while (offset.val < bytes.length) {
const b = bytes[offset.val++] ?? 0;
result |= (b & 0x7f) << shift;
if ((b & 0x80) === 0) break;
shift += 7;
}
return result;
}
This encoding allows a 4K image (3840x2160) to be represented in just two bytes per dimension instead of four fixed bytes.
3. Color Space Transformation: YCbCr to 32-Bit RGBA
Most photographic BPG images store pixel data in the YCbCr color space. To render a standard PNG image, convrtr performs color space transformation from luma (Y) and chroma difference (Cb, Cr) channels into RGB:
R = Y + 1.402 * (Cr - 128)
G = Y - 0.344136 * (Cb - 128) - 0.714136 * (Cr - 128)
B = Y + 1.772 * (Cb - 128)
The resulting 32-bit RGBA pixel buffer is passed directly into convrtr's browser PNG encoder, yielding an uncompressed, lossless PNG image.
4. How to Convert BPG to PNG in Your Browser
- Navigate to BPG to PNG on convrtr.
- Drag and drop your
.bpgimage file. - convrtr parses the BPG header, transforms YCbCr coordinates into linear RGB, and outputs a standard 32-bit RGBA PNG ready for instant download or web use.
- All processing is 100% private and happens locally on your computer with zero server uploads.
Related reading
Converting DICOM Medical Images to PNG: Hounsfield Units and Window Leveling
Understand DICOM Part 10 radiologic file architecture. Learn how 16-bit CT/MRI depth, Hounsfield units, and Window/Level contrast normalization work, with zero server upload.
Converting Quite OK Image (QOI) to PNG: Fast Lossless Compression Architecture
Explore Dominic Szablewski's Quite OK Image (.qoi) specification. Understand 14-byte headers, 64-color hash indexing, byte-aligned opcodes, and browser-based PNG rendering.
Converting Radiance HDR (RGBE) to PNG: Floating-Point Tone Mapping Architecture
Explore Greg Ward's Radiance 32-bit RGBE (.hdr) architecture. Learn how shared exponents, adaptive RLE scanlines, Reinhard tone reproduction, and sRGB gamma curves decode in browser memory.
Converting Blizzard BLP Textures to PNG: Warcraft III & WoW Asset Decoding
Decode Blizzard Entertainment's BLP1 and BLP2 texture formats from Warcraft III and World of Warcraft into transparent 32-bit RGBA PNG images 100% in your browser.
Converting Truevision VDA to PNG: Historical TARGA Video Graphics Decoding
Explore Truevision's original 1984 VDA (Video Display Adapter), ICB, and VST image formats. Learn how vintage TARGA rasters convert to transparent 32-bit RGBA PNG.
Converting Sony SRF RAW to PNG: Unpacking Early Alpha Digital Photography
Explore Sony's early SRF camera raw format. Learn how TIFF Image File Directory structures and embedded JPEG preview streams convert into 32-bit RGBA PNG graphics.