Contents
The main LibRaw object (class) is created either without parameters or with flags determining the object behavior.
#include "libraw/libraw.h" ... LibRaw ImageProcessor(unsigned int flags=0); ...
Flags (several flags are combined via operator |, i.e., bitwise OR):
Three groups of methods are used for image processing
The results of processing are placed in the imgdata field of type libraw_data_t; the same data set contains fields that control the postprocessing and output.
All LibRaw API functions return an integer number in accordance with the return code convention. Please read the descriptions of this convention and LibRaw behavior in cases of fatal errors.
Opens a RAW file, reads metadata (EXIF) from it, and fills the following structures:
The function returns an integer number in accordance with the return code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
Before file opening, recycle() is always called; hence, if several images are processed in the batch mode, there is no need to call recycle() at the end of each processing cycle.
Unpacks the RAW files of the image, calculates the black level (not for all formats), subtracts black (not for all formats). The results are placed in imgdata.image.
Data reading is sometimes (not frequently) affected by settings made in imgdata.params (libraw_output_params_t); see API notes for details.
The function returns an integer number in accordance with the return code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
Reads (or unpacks) the image preview (thumbnail), placing the result into the imgdata.thumbnail.thumb buffer.
JPEG previews are placed into this buffer without any changes (with the header etc.). Other preview
formats are placed into the buffer in the form of the unpacked bitmap image (three components, 8 bits per component).
The thumbnail format is written to the imgdata.thumbnail.tformat field; for the possible values, see
description of constants and data structures.
The function returns an integer number in accordance with the return code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
Frees the allocated data of LibRaw instance, enabling one to process the next file using the same processor. Repeated calls of recycle() are quite possible and do not conflict with anything.
Destructor, which consists in calling recycle().
Analog of strerror(3) function: outputs the text descriptions of LibRaw error codes (in English).
Work of the library may cause two types of exceptional situations that require notification of the calling application:
An application may set its own callbacks that will be called in the case of such errors to notify the user (or the calling program).
typedef void (* memory_callback)(const char *file, const char *where); void LibRaw::set_memerror_handler(memory_callback func);
The user may set his or her own function called in the case of memory shortage. It is a void function receiving two string parameters:
The callback function is intended for information purposes: it notifies the user or the program code that processing is impossible.
If the user does not set his or her own handler, the standard one (output of error message in stderr) will be used.
One can set the null handler by passing NULL to set_memerror_handler; then no notifier function will be called. The same effect can be achieved by creating a LibRaw object with the LIBRAW_OPTIONS_NO_MEMERR_CALLBACK flag in the contructor.
In the case of memory shortage, processing of the current file is terminated and a notifier is called; all
allocated resources are freed, and recycle() is performed. The current call will return
LIBRAW_UNSUFFICIENT_MEMORY.
At an attempt to continue data processing, all subsequent calls will return LIBRAW_OUT_OF_ORDER_CALL.
Processing of a new file may be started in the usual way, by calling LibRaw::open_file().
typedef void (*data_callback)(const char *file, const int offset); void LibRaw::set_dataerror_handler(data_callback func);
The user can define his or her own function to be called in the case of error in the input data. It is a void function receiving two parameters:
The callback function is intended for information purposes: it notifies the user or the program code that processing is impossible.
If the user does not set his or her own handler, the standard one (output of error message in stderr) will be used.
One can set the null handler by passing NULL to set_memerror_handler; then no notifier function will be called. The same effect can be achieved by creating a LibRaw object with the LIBRAW_OPTIONS_NO_DATAERR_CALLBACK flag in the contructor.
In the case of error in the input data, processing of the current file is terminated and a notifier is called; all
allocated resources are freed, and recycle() is performed. The current call will return
LIBRAW_IO_ERROR.
At an attempt to continue data processing, all subsequent calls will return LIBRAW_OUT_OF_ORDER_CALL.
Processing of a new file may be started in the usual way, by calling LibRaw::open_file().
Instead of writing one's own Bayer pattern postprocessing, one can use the dcraw functions, which are called after the calls of open_file() + unpack() /+ unpack_thumb()/
Virtually all parameters that can be set through the dcraw command line are specified by assigning values to fields of the LibRaw::imgdata.params structure. The type of this structure is libraw_output_params_t; all fields are listed and described in sufficient detail in the description of data structures.
The function calculates the correct size of the output image (imgdata.sizes.iwidth and imgdata.sizes.iheight) for the following cases:
In the aforementioned cases, the function changes the fields of the image output size; note that this change cannot be repeated again.
The function should be used for information purposes; it is incompatible with dcraw_document_mode_processing() and dcraw_process() calls.
The function emulates dcraw -D: no interpolation, white balance, and color conversion.
It is called after calling LibRaw::unpack();
The function returns an integer number in accordance with the error code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
The function emulates the postprocessing capabilities available in dcraw.
Called after calling LibRaw::unpack();
The entire functionality of dcraw (set via the field values in imgdata.params) is supported, except for
The function is intended solely for demonstration and testing purposes; it is assumed that its source code will be used in most real applications as the reference material concerning the order of RAW data processing.
The function returns an integer number in accordance with the error code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
In spite of the abundance of libraries for file output in any formats, LibRaw includes calls that emulate the file output provided by dcraw. This is done primarily for easier verification of library work: the resultant files must be binary identical.
The function outputs the postprocessing results to a file in the PPM/PGM or TIFF format (the format is set via imgdata.params.output_tiff). The results are binary identical to those provided by dcraw.
The function returns an integer number in accordance with the error code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
Writes the thumbnail to a file in the PPM format for bitmap thumbnails and in the JPEG format for JPEG thumbnails, i.e., in the format completely identical to the results provided by dcraw.
The function returns an integer number in accordance with the error code convention: positive if any system call has returned an error, negative (from the LibRaw error list) if there has been an error situation within LibRaw.
[back to Index]