I'm having trouble generating a QR code on mango 7.1 with ZXing 2.0. It should be pretty straight forward, but it's not working.
The code:
QRCodeWriter writer = new QRCodeWriter();
var bMatrix = writer.encode("Hey dude, QR FTW!", BarcodeFormat.QR_CODE, 25, 25);
var asBitmap = bMatrix.ToBitmap();
image1.Source = asBitmap;
image1 comes from the xaml.
bMatrix seems to contain the data that I need, but image1 never shows a thing.
Try setting the image source like this :
The easiest solution:
So I managed to do a workaround. I'm not sure if my original code didnt work due to a bug in the ZXing C# port or if I did something wrong. Anyhow, here is what I did to show the QR code.
image1 comes from xaml.
I run into the same problem. Assigning the WriteableBitmap directly to Image.Source didn't work. After some search I found a strengh Workaround which writes the WritableBitap into a MemoryStream using SaveJpeg method:
This worked unless the QR code was displayed in dark/light blue, not black/white. Telling this a friend he remebered that in Windows phone pixel Color is not a Byte, but an integer. With this knowledge and the sources of zxing I changed the ByteMatrix.ToBitmap method as follows:
And this solved the problem at all, even assigning the WritableBitmap directly to Image.Source. It seemed, the Image was correctly assigned, but the alpha value was transparent, which was removed when creating a jpeg.