Error when trying to read a barcode

Home » Barcode SDK/ActiveX » Error when trying to read a barcode
Barcode SDK/ActiveX No Comments

Issue:
When I try to read a Data Matrix barcode with ReadDataMatrix passing NULL for the OutpString in order to get the length of the barcode returned by the function, the error code is set to BARCODEDMR_MEMORY_ERROR. Why would this happen ? The program has much memory at the point in which I make this call. If the barcode could not be found I would expect a BARCODEDMR_BARCODE_NOT_FOUND error.

Solution:
You cannot pass the CImage object to the ReadDataMatrix function directly.
Please try to convert the return value of the Detach() method with the GetDIBits() WinAPI call or the ConvertBitmapToDIB() function found in the BiDIB.dll of the Black Ice TIFF SDK, Image SDK or Document Imaging SDK.

HDIB dib = ConvertBitmapToDIB((HBITMAP)image->Detach(), NULL);
HDIB dib2 = ConvColorDIBtoGrayscale(dib, 0, FALSE);
ret = ReadDataMatrix(dib2, NULL, 5, &chk, (BYTE*)str, &angle, &append, &err);

Regards,
The Impact Support Team