C# QR bit array decode

2019-07-13 13:28发布

I was wondering is there any libraries that can decode QR code bit array instead of image. For eaxample:

{
    {1,1,1,1,1,1,1,0,0,0,1,0,1,0,1,1,1,1,1,1,1},
    {1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1},
    {1,0,1,1,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1,0,1},
    {1,0,1,1,1,0,1,0,0,0,0,0,1,0,1,0,1,1,1,0,1},
    {1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1},
    {1,0,0,0,0,0,1,0,1,1,1,0,0,0,1,0,0,0,0,0,1},
    {1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1},
    {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
    {1,1,0,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,0},
    {1,1,1,1,1,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1},
    {0,1,1,0,0,0,1,1,0,1,1,1,0,0,1,1,1,1,1,0,1},
    {1,0,0,1,1,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1},
    {0,1,1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,0,0},
    {0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,1,0,1,0,0},
    {1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,0},
    {1,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,1,1},
    {1,0,1,1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1},
    {1,0,1,1,1,0,1,0,1,0,0,0,0,1,1,1,0,0,0,1,1},
    {1,0,1,1,1,0,1,0,0,1,1,1,0,1,1,1,0,1,1,0,1},
    {1,0,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0,0,0},
    {1,1,1,1,1,1,1,0,1,0,1,0,0,1,0,1,0,0,1,1,0}
}

Would become "Hi".

I don't need any of the image functionality.

标签: c# qr-code
2条回答
欢心
2楼-- · 2019-07-13 14:11

From the presentation of QrCode.Net, it seems that it will do what you are looking for as one of its features is:

Decoding QR code given as bit matrix

查看更多
姐就是有狂的资本
3楼-- · 2019-07-13 14:25

You could use zxing to decode the bit matrix. However, you need to convert the multidimensional integer array to jagged boolean array. Just convert '1' to 'true' and '0' to 'false'. Execute the following (assuming you have referenced the correct library) to get the result.

bool[][] bData; //this should be the converted bit matrix
com.google.zxing.qrcode.decoder.Decoder dec = new com.google.zxing.qrcode.decoder.Decoder();
com.google.zxing.common.DecoderResult result = dec.decode(bData);
查看更多
登录 后发表回答