谷歌图QR code - 数据比2K + Asp.net更大 [英] Google Chart QR Code - Data is greater than 2k + Asp.net
本文介绍了谷歌图QR code - 数据比2K + Asp.net更大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用谷歌图的QR code,我有更多的发送数据,然后2K,我在
I am using Google Chart QR code , I have to send data more then 2k , I read document on
https://developers.google.com/chart/infographics/文档/ 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使用谷歌的数据QR - code
Can any one have sample that how can I send data using POST for Google QR - Code
推荐答案
我用zxing库来解决我的问题,我已经下载Zxing项目,并创建DLL然后引用该DLL到我的项目。
I have used zxing library to solve my problem, I have downloaded Zxing Project and create DLL of it then reference that DLL into my project.
编码
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;
这篇关于谷歌图QR code - 数据比2K + Asp.net更大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文