WinRT - QrCode.QrCodeReader Class is Marked Internal

Mar 25, 2014 at 3:41 AM
Hello,

Hope all is well!

I am currently using the WinRT winmd in a WinJS application to decode QR Codes. However, we do not have access to the QrCodeReader class as it is marked internal.

Is this functionality not available yet in WinRT or how else would I go about reading a QR Code. I've followed thru the example for reading a barcode but the requirement is QR Code.

Thanks in advance!
  • Jesse
Coordinator
Mar 25, 2014 at 11:26 AM
Because of the restrictions of WinRT components and the compatibility for WinJS there are only the top level classes BarcodeReader, BarcodeWriter and some dependencies available. But this classes are the only things you need to access the full functionality of ZXing.Net.
If you want to read only QR codes use the BarcodeReader class and set the property PossibleFormats which should contain only BarcodeFormat.QR_CODE.
Mar 25, 2014 at 2:03 PM
Thanks for the information and quick reply!

When I attempt to set the possibleFormats property I get the "WinRTError: No Such Interface Supported".
var qrCodeReader = new _zXing.BarcodeReader();

var barcodeFormats = [];
barcodeFormats.push(_zXing.BarcodeFormat.qr_CODE);

qrCodeReader.possibleFormats = barcodeFormats;
What did I blow up?

Thanks again!
Coordinator
Mar 25, 2014 at 9:18 PM
Sorry, the current version isn't fully compatible with WinJS. "possibleFormats" uses IList<T> as the type. Generics are not supported.
I fixed it with revision 88475
https://zxingnet.codeplex.com/SourceControl/changeset/88475
With the next version you can use it that way:
var qrCodeReader = new _zXing.BarcodeReader();
qrCodeReader.possibleFormats = [_zXing.BarcodeFormat.qr_CODE];
Mar 27, 2014 at 1:23 PM
No problem, and thanks again for the reply. My apologies for not thanking you sooner.

One last question: is it possible to wrap up my QR Code scanning logic in a WinRT component and call that from WinJS? This way, the ZXing.NET code is being interfaced via C# and not WinJS.

Thanks again for the guidance!
Coordinator
Mar 27, 2014 at 4:47 PM
It should be possible. I never tried that. You have to build your own WinRT component and I think you have to reference the ZXing.Net WinMD assembly (WinRT component). Not sure if that makes anything better. Would be nice if I can hear a success story from you.
Mar 27, 2014 at 4:58 PM
I will give it a try and see what happens. I'll reach out with any other questions or a success story!

Thanks again!
Mar 28, 2014 at 1:46 PM
Thanks again for your assistance. I was able to get this working using the WinRT Component / WinJS sample code you provide. You do not need to specify the possibleFormats property after all.

Also, I was able to get this to work via a stream thru the camera on the device vs. having to write a file or open a file on the device.

Thanks again for the assistance and my apologies for being slightly confused!
Mar 31, 2014 at 12:34 PM
Edited Mar 31, 2014 at 12:36 PM
psuphish05 wrote:
Also, I was able to get this to work via a stream thru the camera on the device vs. having to write a file or open a file on the device.
I'm very interested in streaming through the camera on the device in a WinJS solution, would it be possible to share your code or give some hints as to how you accomplished it?