This is a short post about reading and writing most popular hdr formats.
Three most common hdr imaging formats are radiance hdr (.hdr, .pic), openexr (.exr) and tif.
Radiance hdr file consists of a plain text header, that holds some information like image resolution, and pixel data in rgbe (red, green, blue and exponent) format, that may be run-lenght encoded to provide compression.
You can find it's original code in Radiance software or implement it yourself, it's relatively easy.
You can also take a look at my code, or just modify it to use in your application.
OpenExr - Extended range format - stores color values as 16-bit or 32-bit floating-point numbers.
The openexr library provides support for 16-bit number representation and for reading and writing .exr files.
It is distributed for both Windows and Linux and can be easily built.
Using Imf::RgbaInputFile and Imf::RgbaOutputFile (ImfRgbaFile.h) is the easiest way to work with exr files, I used scanline-based io.
Tiff container is also a good way to store your hdr images. First, it supports 32-bit floating point pixel data, but this takes 12 bytes per pixel, making the images very heavy. Another way is to use LogLuv encoding, that uses 24 of 32 bits per pixel and so is the cheapest of popular hdr formats.
Tiff support is provided by libtiff. Previous versions of the library have cmakelists file, so you can easily build it on Windows.
I used libtiff version distributed with opencv.
Use tiffio.h to work with tif images. If you are also using opencv you'll have to undef COMPRESSION_NONE, or it will create a syntax error in opencv code.
Most information about tiff image is stored in so-called tags, managed with TIFFGetField and TIFFSetField.
TIFFTAG_BITSPERSAMPLE can be used to check if it is a 32-bit image and TIFFTAG_PHOTOMETRIC can be used to check if it uses LogLuv (PHOTOMETRIC_LOGL for gray images or PHOTOMETRIC_LOGLUV).
TIFFReadEncodedStrip and TIFFWriteEncodedStrip are the two functions to use for io.
This was some practical information about using openexr and libtiff, nomacs code for that is here.
To get info about how the data is stored, you can use the HDR book. It would also be cool to have a wikipedia article about that.