It's three-for-one QR Code Day
- Posted: Jan 23, 2012 at 6:00 AM
- 16,935 Views
- 3 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's Mobile Monday post isn't one project, but three. Yep, it's a three for one day...
We've all seen QR codes around, they are appearing on sites, in print, on TV and even tattoos. Four months ago we covered one way to consume them in a Windows Phone 7.1(5) app, Window Phone 7.5, ZXing and QR codes. Today we're going to highlight three other QR Code projects, one that will help you create them and two other ways to consume them in Windows Phone 7.1(5) apps.
The goal of the project is provding an easy to use, fully managed .Net library for handling QR code according to ISO/IEC 18004. Following features are planned: encoding, rendering (to: screen, file & stream), decoding, detection & recognition, artistic QR code.
The Goal of the ProjectThe goal of the project is to provide an easy to use, managed .Net library for:
- Crating QR code bit matrix from text – encoding.
- Rendering of QR code bit matrix to screen, into an image file or stream.
- Rendering of so called "artistic" QR codes (see below).
- Decoding QR code given as bit matrix.
- Detection and recognition of QR code captures.
- The library should support Windows Phone 7 and Silverlight
Recently I was looking for a .NET implementation of QR code generator. Most of components either use online services to generate and/or recognize QR code or the implementation was not “good enough” for my purposes. The most popular and very powerful Java implementation comes from google’s open source project code.google.com/p/zxing called ZXing (Zebra Crossing => Z=Zebra + X=Cross + ing).
There I found a one-to-one c# port of earlier version. The project is focusing on additional features and further development in Java so it seems that no one is taking care of c# branch.
As a start point I took a straight forward c# port of google’s QR code implementation from ZXing project.
I wrote a wrapper around and a demo application which is able to generate QR code from text as you type and save it to file.
In addition it contains a very naive and simple implementation of Artistic QR code generation. At the highest error correction level it is possible to create artistic QR codes that still scan correctly, but contain intentional errors to make them more readable or attractive to the human eye, as well as to incorporate colors, logos and other features into the QR code block.
Here's a snap of the app running;
And the Solution from the latest check-in (which ran for me the first time with no issues);
Now that we've generated a QR Code, let's look at reading it...
If you’ve updated Windows Phone 7.5, you might have noticed that it has some nice built-in functionality for reading QR Codes using Bing Vision search. After trying it out for a while, I pretty quickly started wondering how I could use this in an app, and equally quickly I was disappointed to find that there are no APIs available for 3rd party developers to access this feature.
After a short hunt online, I found an excellent library that can be used as an alternative, and I built a simple reader with it. Here are the basic steps to create one yourself:
- Create a new Windows Phone Project in Visual Studio
- Update the App Manifest
- Create the QR Reader Window and Output Area
- Directives and Variables
- Handle Navigation
- Add Camera Event Handlers
- Download the Barcode Library
- Add the Barcode Library to the Project
- Decode the QR Code Image
- Compile and Deploy
This project used a barcode library that I don't think I've seen before, messagingtoolkit-barcode
MessagingToolkit Barcode library is a C# barcode library that can be used in standalone Windows applications, ASP.NET web applications, and Windows Phone 7 applications.
The library current supports encoding and decoding of the following barcode types
- QR Code
- Data Matrix
- PDF 417
- Code 11
- Code 128
- Code 128-A
- Code 128-B
- Code 128-C
- Code 39
- Code 39 Extended
- Code 93
- Interleaved 2 of 5
- MSI 2 Mod 10
- MSI Mod 10
- MSI Mod 11
- Standard 2 of 5
- UPC 2 Digit Ext.
- UPC 5 Digit Ext.
- Code 39
- Code 93
- Code 128
- QR Code
- Data Matrix
- PDF 417
This library is based on the zxing library, with some additional features not available in the original code. You can freely use it for non-commercial purpose. To use it commercially, please consider making a payment to support this project here
And last, but not least, our third project of the day, a simple and re-usable QR Code control that makes adding QR Code consumption to your Windows Phone 7.1(5) app drag-n-drop easy
There are great libraries out there written or ported to C# that let us developers rock by standing on the shoulders of giants. Here’s one such project.
A phone developer who’s also an enthusiast of foursquare suggested a feature that I should add in a future release, and provided some sample code based on the zxing barcode library and the Silverlight port of it. I’m working on adding the new feature soon.
In the process I realized it would be a good and quick opportunity to ship such a simple but useful control to the phone development community, so I’ve gone ahead and pushed that control refactoring and implementation to GitHub, check it out: https://github.com/jeffwilcox/wpqr-control
The control is nice:
- Drop it on the design surface
- Wire up the ScanComplete event (and optionally the Error event)
- The control handles all the underlying image manipulation, scanning work, PhotoCamera initialization, etc.
Here’s what a simple sample app looks like in use. The control includes default border thickness and coloring properties that use the accent color and provide a nice visual separator:
Hopefully, with these three projects and the information and resources they provide, adding QR Code support to your apps should now be that much easier...