Sunday, August 1, 2010

WP7 ZXing Barcode

First of all I want to express my regret that I am not one of the 3.000 developers that received a WP 7 developer device (I read somewhere that there are more than 3.000 users that use Facebook from WP7). I really hoped to have a "real" device, but that's the way the cookie crumbles...
This weekend I had two days of WP 7 fun. What I've wanted to see was the use of ZXing in WP 7. There is already a C# port of the library in the ZXing trunk. Porting it to Silverlight it is quite simple (just have to replace ArrayList with generics lists and HashTable with Dictionary) more details here. So I've downloaded the latest csharp source code from ZXing trunk and compiled the library. This was the simple part because I wanted a "nice" test project. I've used the test images from the ZXing source zip as embedded resources and the gesture recognizer from Clarity Consulting this way the user is able to flick both direction between the test images. It was a project based learning because I've used MVVM and the application was following the pattern till I've ruined it with the CameraCaptureTask and PhotoChooserTask (I was not able to get them in the View Model because I don't receive the notification after I choose/capture a photo but if anyone of you can do it please enlighten me how it's done )

I cannot test CameraCaptureTask and PhotoChooserTask but maybe some of you, lucky enough to have a test device, can test it and let me know how/if it works (even in the beta dev tools the camera is poorly integrated with the apps - you will have to run again the app after selecting camera or photo and you should be able to see the selected photo in the central image of my app this way you can press the Decode button).

This is how the test project looks (don't forget to flick the image)

Here is the source code

Have a look also at this new post



  1. This comment has been removed by a blog administrator.

  2. This comment has been removed by a blog administrator.

  3. This comment has been removed by a blog administrator.

  4. hi dan were u able to test this on a real device? I just tested this on a real device and if i use a camera to capture it does not work. I think the size of the image analyzed for barcode needs to be adjusted for the full image instead of just small box. If u have an updated version, can u share how u resolved this ?

  5. I have tested on a real device and it works. I will test it again on my LG Optimus. What phone do you have?

  6. hi,
    i also tested but i have problem,
    as my camera always unable to the take full view of the bar code, is always on the top left corner of the camera. someone enlighten me pls

  7. I had a similar idea but was lucky enough to buy a used HTC Surround off of ebay a few months ago. After a few weeks of development and a few more of testing I released PhraseMeme Scanner in the marketplace. You can find more information about the app as well as the full source for ZXing Silverlight port from Http://

  8. Hi,

    nice code...
    BTW Daniel, Change the camera resolution to QVGA for barcode reading purpose... :-)
    Wish there was some way to get the same experience as in IPhone and Android. They have an overlay on the Camera UI...


  9. This comment has been removed by the author.

  10. Hi George,

    Have a look at my new post here:

  11. I downloaded the sample but when decode Data Matrix codes, it never works.

    Does anyone have the same problem?

    Thanks for the help

  12. Hello!
    Here is the port of ZXing 7.1 to Silverlight. Probably, it will be useful for somebody.

  13. Helo,u please tell how should i start for making a bussiness card application for windows phone 7 using zxing library of c sharp

  14. this is very helpfull thanx allot ...
    i am having an issue as i can access the camera and gallery in the emulator but when running on my device i cant access the camera or gallery ...