libpic

A modern C++ library for reading and writing the PIC file format.

Introduction

The Radiance PIC file format is a high dynamic range (HDR) image file format, and is a de factor standard for storing and exchanging HDR image data. The Radiance PIC file format is also known as the RGBE, XYZE and HDR file format, and is supported by several applications, such as HDRShop and Adobe Photoshop.

Libpic is a modern C++ library for reading and writing the PIC file format. Libpic is available under the GNU General Public License.

Features

Libpic currently supports the FORMAT and EXPOSURE variables. The COLORCORR, SOFTWARE, PIXASPECT, VIEW, PRIMARIES variables are parsed but ignored. Libpic supports reading and writing RLE compressed RGBE and XYZE data. Libpic includes functions to convert from the RGBE and XYZE to RGB and XYZ representation, and vice versa. For more information, refer to the PIC specification.

Libpic's PIC reader and PIC writer are easy to use and integrate. Libpic is a modern C++ library written in standard C++.

Libpic comes with the picheader, picmagic, pic2pic, exr2pic and pic2exr command line programs. The picheader command line program displays the header of a PIC file. The picmagic command line program adds the #?RADIANCE identifier to a PIC file. This identifier is missing in some PIC files, such as the Radiance Pictures. The pic2pic command line program supports transformations on PIC files. The pic2exr and exr2pic command line programs convert between the PIC file format and the OpenEXR file format, a high dynamic range image file format developed by Industrial Light & Magic.

The pic2pfm and pfm2pic command line programs convert between the PIC file format and the PFM file format, a high dynamic range image file format inspired by the Netpbm image file formats. These command line programs are in libpfm, a modern C++ library for reading and writing the PFM format, and not in libpic.

Author

Libpic was written by Ares Lagae. Ares Lagae is a researcher in the Computer Graphics Research Group at the Katholieke Universiteit Leuven, and a C++ enthusiast. In his spare time, he writes C++ libraries that he uses in his research. Libpic is one of these libraries. Other libraries include libpfm, a modern C++ library for reading and writing the PFM format.

Download

Libpic does not depend on any external libraries, except OpenEXR. Libpic was developed with gcc version 4.2.0.

Please send bug reports, feature requests, questions and comments to Ares Lagae.

Documentation

To install libpic, download the source distribution, unpack the archive (tar xzf pic-0.1.tar.gz), move into the directory (cd pic-0.1/), configure the package (./configure --prefix=/home/ares), compile the programs and libraries (make), install the programs and libraries (make install), and clean the package (make clean).

To use libpic, obtain a PIC file (image.pic), create an example program (pic.cpp),

#include <cassert>
#include <iostream>
#include <fstream>
#include <vector>
#include <pic.hpp>

int main(int argc, char* argv[])
{
  assert(argc == 2);
  try {
    std::ifstream istream(argv[1]);
    pic::pic_input_file pic_input_file(istream);
    pic::format_type format;
    double exposure;
    pic_input_file.read_information_header(format, exposure);
    pic::resolution_string_type resolution_string_type;
    std::size_t x_resolution, y_resolution;
    pic_input_file.read_resolution_string(resolution_string_type, x_resolution, y_resolution);
    assert(resolution_string_type == pic::neg_y_pos_x);
    std::size_t scanline_length = x_resolution;
    std::size_t number_of_scanlines = y_resolution;
    std::vector scanline(scanline_length);
    for (std::size_t scanline_index = 0; scanline_index < number_of_scanlines; ++scanline_index) {
      pic_input_file.read_scanline(&scanline[0], scanline_length);
    }
  }
  catch (pic::runtime_error& pic_runtime_error) {
    std::cerr << pic_runtime_error.what() << std::endl;
    return EXIT_FAILURE;
  }
}
compile the program (g++ -Wall -I ~/include pic.cpp -L ~/lib/ -l pic -o pic), and execute the program (./pic image.pic). In order to locate the locate the dynamic libraries, update the dynamic library search path of the linker (export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib). If libpic was installed system-wide (./configure withouth --prefix=/home/ares), then reconfigure the dynamic linker run time bindings (ldconfig). Alternatively, the example program can be linked statically (g++ -Wall -I ~/include pic.cpp -L ~/lib/ -l pic -static -o pic).

To uninstall libpic, move into the directory (cd pic-0.1/), uninstall the programs and libraries (make uninstall), move out of the directory (cd ..), remove the directory (rm -r pic-0.1/), and remove the source distribution (rm pic-0.1.tar.gz).

Libpic does not have detailed documentation. Please refer to the Doxygen documentation and to the source code of the pic2pic program that comes with libpic.

Ares Lagae - Personal site (disclaimer) -