Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1280
Infragistics BarcodeReder strange behaviour.
posted

Hi there,

I am using Infragistics BarcodeReader to process some documents. But the BarcodeReader behaves quite strange.

While it is scanning the same file, sometimes it give a barcode. Sometimes it doesn't.And sometimes it just throws exceptions ('System.OutOfMemoryException',  System.Runtime.InteropServices.COMException).

What I basically do is to convert some PDF's to PNG and let the Infragistics BarcodeReader decode the QR code, and I have tested with the following 3 files.

C:\Temp\Test\SConbitScan42990006.001.04-Certificate.pdf
C:\Temp\Test\SConbitScan42990006.001.03-Certificate.pdf
C:\Temp\Test\SConbitScan42990006.002.02-Certificate.pdf

And their corresponding PNG's

C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
C:\Temp\Test\QrFolder\SConbitScan42990006.002.02-Certificate.pdf.png

All files are included in the sample.

Main parts of the code:

        private static void ReadQrCode(string fileName)
        {
            var barcodeReader = new BarcodeReader();
            barcodeReader.DecodeComplete += BarcodeReader_DecodeComplete;
            var image = new BitmapImage(new Uri(fileName, UriKind.Relative));

            //Decoding an image.
            try
            {
                Console.WriteLine($"File name: {fileName}");
                barcodeReader.Decode(image);
            }
            catch (Exception e)
            {
                ...
            }
            finally
            {
                image = null;
                barcodeReader = null;
                GC.Collect();
            }
        }

        private static void BarcodeReader_DecodeComplete(object sender, ReaderDecodeArgs e)
        {
            var text = e.SymbolFound ? e.Value : "No QR code found";
           
            Console.WriteLine($"QR CODE: { text}\n ======== ");
        }

And the outputs in CONSOLE:

Exception of type 'System.OutOfMemoryException' was thrown. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.    at Infragistics.Controls.Barcodes.ImageProcessing.ConvertGrayScaleToRgb(Array pixels, Boolean hasAlpha)    at Infragistics.Controls.Barcodes.ImageProcessing.CreateImageFromPixelsArray(Byte[][] data, ImageData imageData, Boolean isImageZoomed)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap, Symbology symbologyTypes)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap)    at InfraBarcodeScannerConsole.Program.ReadQrCode(String fileName) in C:\Users\nawed\Desktop\WorkSpaceVS\TestApplication\InfraBarcodeScannerConsole\Program.cs:line 110

Insufficient memory to continue the execution of the program. System.OutOfMemoryException: Insufficient memory to continue the execution of the program.    at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette)    at Infragistics.Controls.Barcodes.ImageProcessing.CreateImageFromPixelsArray(Byte[][] data, ImageData imageData, Boolean isImageZoomed)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap, Symbology symbologyTypes)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap)    at InfraBarcodeScannerConsole.Program.ReadQrCode(String fileName) in C:\Users\nawed\Desktop\WorkSpaceVS\TestApplication\InfraBarcodeScannerConsole\Program.cs:line 110

MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003) System.Runtime.InteropServices.COMException (0x88980003): MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003)    at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette)    at Infragistics.Controls.Barcodes.ImageProcessing.CreateImageFromPixelsArray(Byte[][] data, ImageData imageData, Boolean isImageZoomed)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap, Symbology symbologyTypes)    at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap)    at DCMConsoleApplication.Program.ReadQrCode(String fileName) in C:\Users\nawed\Desktop\WorkSpaceVS\TestApplication\InfraBarcodeScannerConsole\Program.cs:line 110

File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
QR CODE: 33KC42990006.001.04
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
QR CODE: 33KC42990006.001.04
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
QR CODE: No QR code found
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
QR CODE: 33KC42990006.001.04

 ========

File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
QR CODE: No QR code found
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
QR CODE: 33KC63490101.014.01
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
QR CODE: 33KC63490101.014.01
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
QR CODE: 33KC63490101.014.01

 ========

File name: C:\Temp\Test\QrFolder\SConbitScan42990006.002.02-Certificate.pdf.png
QR CODE: No QR code found
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.002.02-Certificate.pdf.png
QR CODE: 33KC63490101.014.01
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.002.02-Certificate.pdf.png
QR CODE: No QR code found
 ========
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.002.02-Certificate.pdf.png
QR CODE: 33KC63490101.014.01

 ========

File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.png
QR CODE: No QR code found

 ========

File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.png
QR CODE: 33KC42990006.001.04

 ========

THE PNG FILES WERE TOO BIG FOR UPLOAD I GUESS.

InfraBarcode.rar
Parents Reply Children
No Data