This is a preview/proposal for a C-API to zxing-cpp. If this turns out to be useful and practical, it will most likely be merged into the library itself so that it will be trivially accessible for everyone. If you have any comments or feedback, please have a look at zxing-cpp#583.
Probably the easiest way to play with the C-API is to either just modify the zxing-c-test.c file or copy the files zxing-c.h and zxing-c.cpp into your own project and link it to the standard zxing-cpp library.
The following is close to the most trivial use case scenario that is supported.
#include "zxing-c.h"
int main(int argc, char** argv)
{
int width, height;
unsigned char* data;
/* load your image data from somewhere. ImageFormat_Lum assumes grey scale image data. */
zxing_ImageView* iv = zxing_ImageView_new(data, width, height, zxing_ImageFormat_Lum, 0, 0);
zxing_DecodeHints* hints = zxing_DecodeHints_new();
/* set DecodeHints properties, if requried */
zxing_Result* result = zxing_ReadBarcode(iv, hints);
if (result) {
printf("Format : %s\n", zxing_BarcodeFormatToString(zxing_Result_format(result)));
const char* text = zxing_Result_text(result);
printf("Text : %s\n", text);
free(text);
zxing_Result_delete(result);
} else {
printf("No barcode found\n");
}
zxing_ImageView_delete(iv);
zxing_DecodeHints_delete(hints);
return 0;
}