Add new comment

An example code snippet

I post an example code snippet here. It is hard to find an example online for me:

void exif_callback(void *context, int tag, int type, int len, unsigned int ord, void *ifp) {
LibRaw_abstract_datastream* data = static_cast(ifp);
MyContext *mycontext = static_cast(context);
// read noiseProfile tag as an example
tag &= 0x0fffff; // Undo (ifdN + 1) << 20)
if (tag == 0xc761) {
double values[2];
data->read(values, sizeof(double), 2);
std::cout << values[0] << " " << values[1] << std::endl;
// store values into MyContext if you need
}
}

static LibRaw lr;
lr.open_file(filename);
MyContext context; // a custom struct just to save data
lr.set_exifparser_handler(exif_callback, &context);
lr.unpack();