首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌图表二维码-数据大于2k + Asp.net

谷歌图表二维码-数据大于2k + Asp.net
EN

Stack Overflow用户
提问于 2012-07-10 16:24:43
回答 2查看 1K关注 0票数 1

我正在使用Google Chart二维码,我必须发送超过2k的数据,我在上面阅读文档

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

上面写着

代码语言:javascript
复制
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为谷歌二维码

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-11 12:38:05

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

对进行编码

代码语言:javascript
复制
        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);

解码

代码语言:javascript
复制
        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;
票数 0
EN

Stack Overflow用户

发布于 2012-07-10 16:37:16

你可以这样做。您可以传递超过2K的chl

代码语言:javascript
复制
<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"  />

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11409347

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档