C API

LibRaw C API is a wrapper around C++ API; therefore, virtually all documentation to C API functions is represented by a set of hyperlinks to the corresponding places in the description of C++ API.

Contents

  1. Initialization: libraw_data_t *libraw_init(unsigned int flags);
  2. Returned values
  3. Data loading
  4. Parameters getters/setters
  5. Auxiliary Functions
  6. Data Postprocessing, Emulation of dcraw Behavior
  7. Writing to Output Files
  8. Writing processing results to memory buffer

Initialization: libraw_data_t *libraw_init(unsigned int flags);

The function returns the pointer to the instance of libraw_data_t structure.
The resultant pointer should be passed as the first argument to all C API functions (except for libraw_strerror).

Returns NULL in case of error, pointer to the structure in all other cases.

Returned values

Functions of C API return EINVAL (see errno.h) if the null pointer was passed to them as the first argument. In all other cases, the C++ API return code is returned.

Data Loading from a File

int libraw_open_file(libraw_data_t*, const char *)
int libraw_open_file_ex(libraw_data_t*, const char *,INT64 bigfile_size)
WIN32: int libraw_open_wfile(libraw_data_t*, const wchar_t *)
WIN32: int libraw_open_wfile_ex(libraw_data_t*, const wchar_t *,INT64 bigfile_size)
See LibRaw::open_file()
int libraw_open_buffer(libraw_data_t*, void *buffer, size_t bufsize)
See LibRaw::open_buffer()
int libraw_unpack(libraw_data_t*);
See LibRaw::unpack()
int libraw_unpack_thumb(libraw_data_t*);
See LibRaw::unpack_thumb()

Parameters setters/getters

These functions provides interface to imgdata.params, .sizes and .color fields which works regardless of LibRaw versions used when building calling app and the library itself.

  • int libraw_get_raw_height(libraw_data_t *lr);
  • int libraw_get_raw_width(libraw_data_t *lr);
  • int libraw_get_iheight(libraw_data_t *lr);
  • int libraw_get_iwidth(libraw_data_t *lr);
  • float libraw_get_cam_mul(libraw_data_t *lr,int index);
  • float libraw_get_pre_mul(libraw_data_t *lr,int index);
  • float libraw_get_rgb_cam(libraw_data_t *lr,int index1, int index2);
  • int libraw_get_color_maximum(libraw_data_t *lr);
  • void libraw_set_user_mul(libraw_data_t *lr,int index, float val);
  • void libraw_set_demosaic(libraw_data_t *lr,int value);
  • void libraw_set_output_color(libraw_data_t *lr,int value);
  • void libraw_set_user_mul(libraw_data_t *lr,int index, float val);
  • void libraw_set_output_bps(libraw_data_t *lr,int value);
  • void libraw_set_gamma(libraw_data_t *lr,int index, float value);
  • void libraw_set_no_auto_bright(libraw_data_t *lr,int value);
  • void libraw_set_bright(libraw_data_t *lr,float value);
  • void libraw_set_highlight(libraw_data_t *lr,int value);
  • void libraw_set_fbdd_noiserd(libraw_data_t *lr,int value);
  • void libraw_set_ca_correction(libraw_data_t *lr,int ca_correc, float ca_red, float ca_blue);
  • void libraw_set_ca_correction(libraw_data_t *lr,int ca_correc, float ca_red, float ca_blue);
  • void libraw_set_cfalinenoise(libraw_data_t *lr,int cfaline, float linenoise);
  • void libraw_set_wf_debanding(libraw_data_t *lr, int wf_debanding, float wfd0, float wfd1, float wfd2, float wfd3);
  • void libraw_set_interpolation_passes(libraw_data_t *lr,int passes);

Auxiliary Functions

const char* libraw_version()
See LibRaw::version()
const char* libraw_versionNumber()
See LibRaw::versionNumber()q
bool LIBRAW_CHECK_VERSION(major,minor,patch)
See LIBRAW_CHECK_VERSION
unsigned libraw_capabilities()
See LibRaw::capabilities()
int libraw_cameraCount()
See LibRaw::cameraCount()
int libraw_cameraList()
See LibRaw::cameraList()
void libraw_get_decoder_info(libraw_data_t*,libraw_decoder_info_t *);
See LibRaw::get_decoder_info()
void libraw_unpack_function_name(libraw_data_t*);
See LibRaw::unpack_function_name()
void libraw_COLOR(libraw_data_t*,int row,int col);
See LibRaw::COLOR()
void libraw_subtract_black(libraw_data_t*);
See LibRaw::subtract_black()
void libraw_recycle_datastream(libraw_data_t*);
See LibRaw::recycle_datastream()
void libraw_recycle(libraw_data_t*);
See LibRaw::recycle()
void libraw_close(libraw_data_t*);
See LibRaw::~LibRaw()
const char *libraw_strerror(int errorcode);
See LibRaw::strerror
const char *libraw_strprogress(enum LibRaw_progress);
See LibRaw::strprogress
void libraw_set_memerror_handler(libraw_data_t*, memory_callback cb);
See LibRaw::set_memerror_handler()
void libraw_set_dataerror_handler(libraw_data_t*,data_callback func);
See LibRaw::set_dataerror_handler()
void libraw_set_progress_handler(libraw_data_t*,progress_callback func);
See LibRaw::set_progress_handler()

Data Postprocessing, Emulation of dcraw Behavior

Setting of Parameters

The postprocessing parameters for the calls described below are set, just as for C++ API, via setting of fields in the libraw_output_params_t structure:

 libraw_data_t *ptr = libraw_init(0);
 ptr->params.output_tiff = 1; //  output to TIFF
    

Fields of this structure are described in the documentation to libraw_output_params_t. For notes on their use, see API notes.

Emulation of dcraw Behavior

int libraw_raw2image(libraw_data_t*);
See LibRaw::raw2image
int libraw_free_image(libraw_data_t*);
See LibRaw::free_image
int libraw_adjust_sizes_info_only(libraw_data_t*);
See LibRaw::adjust_sizes_info_only()
int libraw_dcraw_process(libraw_data_t* lr);
See LibRaw::dcraw_process()

Writing to Output Files

int libraw_dcraw_ppm_tiff_writer(libraw_data_t* lr,const char *filename);
See LibRaw::dcraw_ppm_tiff_writer()
int libraw_dcraw_thumb_writer(libraw_data_t* lr,const char *fname);
See LibRaw::dcraw_thumb_writer()

Writing processing results to memory buffer

libraw_processed_image_t *libraw_dcraw_make_mem_image(libraw_data_t* lr,int * errcode)
See LibRaw::dcraw_make_mem_image()
libraw_processed_image_t *libraw_dcraw_make_mem_thumb(libraw_data_t* lr,int * errcode)
See LibRaw::dcraw_make_mem_thumb()