Created
July 17, 2020 03:17
-
-
Save yushulx/0e96b717c62e8f7074fe17085a2b5e12 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void DecodeBufferAsync(const FunctionCallbackInfo<Value>& args) { | |
if (!createDBR()) {return;} | |
Isolate* isolate = Isolate::GetCurrent(); | |
Local<Context> context = isolate->GetCurrentContext(); | |
// get arguments | |
unsigned char* buffer = (unsigned char*) node::Buffer::Data(args[0]); // file stream | |
int width = args[1]->Int32Value(context).ToChecked(); // image width | |
int height = args[2]->Int32Value(context).ToChecked(); // image height | |
int stride = args[3]->Int32Value(context).ToChecked(); // stride | |
int iFormat = args[4]->Int32Value(context).ToChecked(); // barcode types | |
Local<Function> cb = Local<Function>::Cast(args[5]); // javascript callback function | |
String::Utf8Value templateName(isolate, args[6]); // template name | |
char *pTemplateName = *templateName; | |
// initialize BarcodeWorker | |
BarcodeWorker *worker = new BarcodeWorker; | |
worker->request.data = worker; | |
worker->callback.Reset(isolate, cb); | |
worker->iFormat = iFormat; | |
worker->pResults = NULL; | |
worker->buffer = buffer; | |
worker->width = width; | |
worker->height = height; | |
worker->bufferType = RGB_BUFFER; | |
worker->stride = stride; | |
if (hasTemplate(pTemplateName)) { | |
// Load the template. | |
char szErrorMsg[256]; | |
DBR_InitRuntimeSettingsWithString(hBarcode, pTemplateName, CM_OVERWRITE, szErrorMsg, 256); | |
worker->useTemplate = true; | |
} | |
else { | |
worker->useTemplate = false; | |
} | |
uv_queue_work(uv_default_loop(), &worker->request, (uv_work_cb)DetectionWorking, (uv_after_work_cb)DetectionDone); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment