Created
October 12, 2018 06:51
-
-
Save yushulx/c163808cf23a96a94fb486450bd27990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "bridge.h" | |
#include "DynamsoftBarcodeReader.h" | |
#include <stdio.h> | |
RustCallback cb; | |
int32_t register_callback(RustCallback callback) { | |
cb = callback; | |
return 1; | |
} | |
void c_decodeFile(const char *fileName, const char *pszLicense) | |
{ | |
void *hBarcode = DBR_CreateInstance(); | |
if (hBarcode) | |
{ | |
int ret = DBR_InitLicense(hBarcode, pszLicense); | |
STextResultArray *paryResult = NULL; | |
ret = DBR_DecodeFile(hBarcode, fileName, ""); | |
DBR_GetAllTextResults(hBarcode, &paryResult); | |
int count = paryResult->nResultsCount; | |
printf("Barcode found: %d\n", count); | |
int i = 0; | |
for (; i < count; i++) | |
{ | |
// printf("Index: %d, Barcode Type: %s, Value: %s\n", i, paryResult->ppResults[i]->pszBarcodeFormatString, paryResult->ppResults[i]->pszBarcodeText); | |
if (cb) | |
{ | |
cb(i, paryResult->ppResults[i]->pszBarcodeFormatString, paryResult->ppResults[i]->pszBarcodeText); | |
} | |
} | |
DBR_FreeTextResults(&paryResult); | |
DBR_DestroyInstance(hBarcode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment