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.pdfC:\Temp\Test\SConbitScan42990006.001.03-Certificate.pdfC:\Temp\Test\SConbitScan42990006.002.02-Certificate.pdf
And their corresponding PNG's
C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.pngC:\Temp\Test\QrFolder\SConbitScan42990006.001.03-Certificate.pdf.pngC:\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.pngQR 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.pngQR 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.pngQR CODE: No QR code found
File name: C:\Temp\Test\QrFolder\SConbitScan42990006.001.04-Certificate.pdf.pngQR CODE: 33KC42990006.001.04
THE PNG FILES WERE TOO BIG FOR UPLOAD I GUESS.
Hello Nawed,
I have been investigating into this issue, and I have reproduced the exceptions that you are referring to, both with the sample project you have provided me and with an external sample project that attempts to read the barcodes on button click. It appears that the COM Exception that you are currently seeing has an Out Of Memory exception occurring at its root as well, so most of the exceptions you are currently seeing are related to Out Of Memory exceptions.
I believe this may be related to the dpi settings that you are setting on the Inkscape .png file that you are creating. I don't know much about the Inkscape command that you are passing to your ProcessStartInfo, personally, but currently it appears that you have the dpi set to 600, which is resulting in image files that are nearly 7MB on my end. I have been experimenting with your sample project in order to see if this happens with lower dpi scales, and so far, I have tested against 200 and 100 dpi scales, which lowers the size of the images significantly, and I am no longer seeing the exceptions that were occurring on your end with these dpi scales.
It is likely that this is being caused by the sizes of the images, but that doesn't explain why the BarcodeReader seems to read the images fine sometimes, but not others. I am going to look into this a little further with our development teams to see if there is more of an underlying explanation to this, and I hope to have more information for you soon.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
I have been investigating into this issue a bit further, and I have asked our engineering staff to take a closer look. To ensure that this issue receives attention, I have logged it in our internal tracking systems with a development ID of 227112. I have also created a private support case so that you can track this issue. This case has an ID of CAS-177722-D3N3H9 and you can access it after signing into your Infragistics account at https://ko.infragistics.com/my-account/support-activity. You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.