1

我正在使用 Google Chart QR 码,我必须发送超过 2k 的数据,我阅读了关于

https://developers.google.com/chart/infographics/docs/qr_codes

它说

The data to encode. Data can be digits (0-9), alphanumeric characters, binary bytes data,
or Kanji. You cannot mix data types within a QR code. The data must be UTF-8 
URL-encoded.Note that URLs have a 2K maximum length, so if you want to encode more than 
 2K bytes (minus the other URL characters), you will have to send your data using POST.

任何人都可以有我如何使用 POST for Google QR 发送数据的示例 - 代码

4

2 回答 2

1

你可以这样做。您可以通过 chl 超过 2K

<form action='https://chart.googleapis.com/chart' method='POST' runat="server">
<input type="hidden" name="cht" value="qr"  />
<input type="hidden" name="chl" value="This is testing"  />
<input type='hidden' name='chs' value='300x200' />
<input type="submit"  />

于 2012-07-10T08:37:15.950 回答
0

我已经使用 zxing 库来解决我的问题,我已经下载了 Zxing 项目并创建了它的 DLL,然后将该 DLL 引用到我的项目中。

编码

        QRCodeWriter writer = new com.google.zxing.qrcode.QRCodeWriter();
        string str = string.Empty;
        for (int i = 0; i < 2000 ; i++)
            str += i;

        ByteMatrix byteMatrix = writer.encode(str, com.google.zxing.BarcodeFormat.QR_CODE, 300, 300);

        ImageConverter converter = new ImageConverter();
        // Sample of DexExpress Control 
        ASPxBinaryImage1.ContentBytes = (byte[])converter.ConvertTo(byteMatrix.ToBitmap(), typeof(byte[]));

        byte[] b = (byte[])converter.ConvertTo(byteMatrix.ToBitmap(), typeof(byte[]));
        string s = System.Convert.ToBase64String(b);
        //Sample of ASP.net Control
        image1.Attributes.Add("src", "data:image/png;base64," + s);

解码

        string strb64 = System.Convert.ToBase64String(b);

        QRCodeReader reader = new QRCodeReader();
        byte[] imageBytes = Convert.FromBase64String(strb64);
        MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);

        Bitmap bmp = new Bitmap(ms);

        LuminanceSource s = new RGBLuminanceSource(bmp, bmp.Width, bmp.Height);
        BinaryBitmap bb = new BinaryBitmap(new GlobalHistogramBinarizer(s));


        Result result = reader.decode(bb);

        //Store result into string
        string resultText = result.Text;
于 2012-07-11T04:38:04.530 回答