我正在使用Google Chart二维码,我必须发送超过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为谷歌二维码
发布于 2012-07-11 12:38:05
我使用了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-10 16:37:16
你可以这样做。您可以传递超过2K的chl
<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" />
https://stackoverflow.com/questions/11409347
复制相似问题