在Windows Phone生成QR码使用ZXing 2.0 C#7.1端口

问题描述:

我无法生成芒果7.1 QR码与ZXing 2.0。
应该是相当直接的,但它不工作

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.

中的代码:

QRCodeWriter writer = new QRCodeWriter();
var bMatrix = writer.encode("Hey dude, QR FTW!", BarcodeFormat.QR_CODE, 25, 25);
var asBitmap = bMatrix.ToBitmap();            
image1.Source = asBitmap;



此搜索来自XAML。

image1 comes from the xaml.

bMatrix似乎包含了我所需要的数据,但此搜索从未显示出的事情。

bMatrix seems to contain the data that I need, but image1 never shows a thing.

所以我设法做一个解决方法。我不知道如果我的原代码,没有工作,由于斑马线C#端口的错误还是我做错了什么。总之,这里是我做过什么,以显示QR码。

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.

此搜索来自XAML。

QRCodeWriter writer = new QRCodeWriter();
var bMatrix = writer.encode("Hey dude! QR FTW!", BarcodeFormat.QR_CODE, width, height);

WriteableBitmap wbmi = new System.Windows.Media.Imaging.WriteableBitmap(width, height);

for (int y = 0; y < height; y++)
{
    for (int x = 0; x < width; x++)
    {
        int grayValue = bMatrix.Array[y][x] & 0xff;
        if (grayValue == 0)                        
            wbmi.SetPixel(x, y, Color.FromArgb(255, 0, 0,0));                                                    
         else
             wbmi.SetPixel(x, y, Color.FromArgb(255, 255, 255, 255));
     }
 }
 image1.Source = wbmi;