[back to Index]

# LibRaw: 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. Auxiliary Functions
5. Data Postprocessing, Emulation of dcraw Behavior
   - Setting of Parameters
   - Emulation of dcraw Behavior
6. Writing to Output Files
7. 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()

## Auxiliary Functions

const char* libraw_version()
  See LibRaw::version()
const char* libraw_versionNumber()
  See LibRaw::versionNumber()
bool LIBRAW_CHECK_VERSION(major,minor,patch)
  See LIBRAW_CHECK_VERSION
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()

[back to Index]