QR code library ported to Windows 8 based on the solution from twit88:
Recently I was looking for a QR code library to read and generate QR codes for Windows Metro style apps. Since I could not find one for Windows 8 but I found this excellent work from twitt88, I decided to make a port for Windows Metro
Using the code
Please notice that the attached code is based on the following library:
Please visit the site for additional solutions as well.
The next section shows how to use the library.
Note: The QR encoding and decoding functions using image in a byte array format.
Generating QR Code:
ThoughtWorks.QRCode.Codec.QRCodeEncoder _qrCodeEncoder = new
_qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
_qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
_qrCodeEncoder.QRCodeVersion = 0;
_qrCodeEncoder.QRCodeScale = 7;
string text = "Test text for QRcode";
QRCodeBitmapImage image = _qrCodeEncoder.Encode(text, System.Text.Encoding.UTF8);
Please notice that the encoder returns a
QRCodeBitmapImage which contains the image in a
byte array format. The
Utilities class contains
a static method that can be used to create a
WritableBitmap instance that can be used as a source of an
Reading QR Code:
QRCodeBitmapImage _image = new QRCodeBitmapImage(_imagetoBeRead, _width, _height);
decodedstring = _decoder.decode(_image, System.Text.Encoding.UTF8);
imageToBeRead is a
byte array of the image to be read. This can be created from a
WritableBitmap as the following line shows:
For using the
ToArray() method for the
WriteableBitmap you have to include the following namespace to your project:
Points of Interest
The code can be used for reading and generating QR codes.