Converting Radiance HDR to Float RGB

The Radiance HDR format is defined as 8-bit R, G, B + 8-bit exponent. There is no 16-bit or float variant of it, but you can convert the individual 8-bit components into float RGB instead. Here’s the code:

unsigned char hdr_r, hdr_g, hdr_b, hdr_e;

// -- read hdr_r, hdr_g, hdr_b, hdr_e from the image as unsigned chars.

// Convert the 8-bit HDR RGBE components to RGB float.
float r, g, b, e;

e = ldexp( 1.0f, hdr_e - (int)(128+8) );
r = hdr_r * e;
g = hdr_g * e;
b = hdr_b * e;

This page was last modified 12:07, 28 Mar 2008.
This page has been accessed 2715 times.